Page 1 of 1

Stencil shadow artifacts, near clip collides shadow volume

Posted: Tue Jul 27, 2010 9:41 am
by farfpeuf
Hi I have shadow artifacts when the camera near clip plane collides with the shadow volume
I am using a directionnal light

near clip = 5
far clip = 0 (infinite)
ShadowFarDistance = 200.0f
ShadowTechnique = SHADOWTYPE_STENCIL_MODULATIVE

How can I Handle that please ?
on the left no artifcat, on the right we can see the shadow artifacts when the camera near clip collides with the shadow volume
on the left no artifcat, on the right we can see the shadow artifacts when the camera near clip collides with the shadow volume

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Wed Jul 28, 2010 11:19 am
by farfpeuf
the problem does not seem to appear when I use the Ninja model, and yet I checked my ogreMax exporter version is 1.7.1

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Wed Jul 28, 2010 1:52 pm
by farfpeuf
The artefacts seem to appear with unclosed shapes (like the ogre head)

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Fri Jul 30, 2010 10:56 am
by Dakiar
I have the same problem, let me know if you find a solution.

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Wed Oct 06, 2010 4:17 pm
by Nodrev
Hello,
Got the same problem, it's a loggued bug for Ogre 1.7 (.1 and maintenance repository too for the moment).
The strange thing is, that this bug doesn't exist in 1.6 versions, neither in the trunk 1.8 version...
I'm fed up with this, cause we can't switch our ogre version while this is not corrected. I don't want to say "why this is not corrected now", i know that if i want it corrected, i rather have to do it myself, due to the fact that stencil is not really popular anymore (and outdated for sure), but i have 40 diff files within those 3 version (1.6.5 / 1.7.1 / 1.8 ) and it's a mess to find the little line that changes everithing...
Anyway, if someone who works on this part (camera or frustrum or stencil shadow generation) on the 1.8 has an idea...

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Thu Oct 07, 2010 2:43 am
by frr171
I'm getting the exact same error
Image

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Mon Oct 11, 2010 8:58 am
by Nodrev
Hi,

Here some news about my researchs concerning this problem: I had already remarked that the stencil volumes mess up on the caps beetween sub-entities (even if there's no "visible" cap). So, i update all mesh and entities functions where the cap calculation was done with the trunk (1.8 ) version, but unfortunally, that's doesn't change anything. I check the extrusion programs too beetween those two version (i'm talking about 1.7 and 1.8 ), and there's no noticiable modification, expect a new program (anyway, that's not that, cause my cg does not support those programs). Viewports and frustrum classes are obviously the same (except a clear depth buffer in viewport if i remind well...).
So, the last big difference beetween 1.7 and 1.8 (except the normals animations and the entity instancing parts) that is left is the Depth Buffer management system. But here, i have to say that it's comes a little too low-level for me (:-(), but i'm pretty sure that there something related to this problem in there...

<edit>I forgot to mention that, obviously, my tests where done with closed meshes</edit>

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Mon May 23, 2011 11:01 am
by JonnyJP
Has this been fixed yet?

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Mon May 23, 2011 11:09 am
by Nodrev
It's ok with the trunk (1.8 ) version, but I did not test the 1.7.3...

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Mon May 23, 2011 12:28 pm
by JonnyJP
Ok thanks, I'm just trying 1.6.5 too (I read that that version didn't have the problem).

EDIT 1.6.5 seems to have the same problem. How do I get 1.8?

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Thu Jun 09, 2011 10:55 am
by JonnyJP
Does anyone know which files contained the bug fix in 1.8 please? I'd like to just put this fix in my 1.7.2 installation without getting all of 1.8.

Thanks

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Thu Jun 09, 2011 11:00 am
by Nodrev
I think that it's related to the depth buffer management... as it completely changed since 1.7, you can't do that...

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Thu Jun 09, 2011 12:25 pm
by JonnyJP
Ok, ta

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Tue Jun 14, 2011 3:39 pm
by Kaylx
God news everyone!

After trawling through the code changes between 1.7.2 and 1.8 I managed to track down and fix the stencil shadow artifact problem.

It's a massive change. See below:

OgreShadowCaster.cpp@158

Code: Select all

for ( ; ti != tiend; ++ti, ++lfi)
{
	assert(ti->vertexSet == eg.vertexSet);
	// Check it's light facing
	if (*lfi)
		preCountIndexes += increment;
}
break; // <----- Comment out this line
That's right. Remove that break statement and everything works again. So not really a massive change after all. ;)

Hope this helps everyone that's been suffering with this issue. :)

Regards,
Kaylx

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Tue Jun 14, 2011 3:41 pm
by JonnyJP
You're a star!!!

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Tue Jun 14, 2011 3:47 pm
by Nodrev
Great, I must have missed this point while comparing...

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Fri Nov 25, 2011 8:23 am
by dustbin1_uk
Just wanted to say THANK YOU! for resolving this!

I raised this a while back,
http://www.ogre3d.org/forums/viewtopic. ... 07#p445407

But I did not have the skill to sort it. Though you seem have nailed it simply.

Thank you again!

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Fri Jan 27, 2012 9:34 am
by muttob
Hello everyone,

i have the same problem with the shadows, but i can't find the OgreShadowCaster.cpp file only the .h file.

It would be great if someone could help me.


nice Greetings

Tobi

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Sat Jan 28, 2012 2:25 pm
by Kaylx
If you don't have the cpp files then i'm presuming you've installed the SDK and not the source package.
You'd need to download, modify and build the source package.

Alternatively wait till 1.8 is released, shouldn't be too long now. It has the fix in it.

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Thu Mar 01, 2012 3:30 am
by ekee
Kaylx, great job!
however, it did not fix the problem on my computer after I followed the instruction to comment out the "break" statement ...
btw, I'm revising the code based on 1.7.0RC1.
does that mean I might also have to modify the code somewhere else?

in ogre 1.7.0RC1, even the sample app has the fault:
stencilFault.PNG

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Thu Mar 01, 2012 10:15 am
by Kaylx
My 'fix' was for 1.7.2 and I didn't test it on any older version.

If you're still seeing the issue in 1.7.0RC1 then as you said it looks like more code has to changed to get things working. What code to modify though, i couldn't tell you i'm afraid.

May I ask, out of curiosity, why you're using a RC build and not a proper release?

Re: Stencil shadow artifacts, near clip collides shadow volu

Posted: Fri Mar 02, 2012 11:16 am
by ekee
thanks, i will try to figure it out what code to modify in order to make 1.7.0rc1 work.
it's a little bit complicated to explain why we stick to this RC build, it's not my decision to make though...
i hope our project can switch to a more stable version one day.