Sign in to follow this  

[Solved] Depthfail stencil shadows bug

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to avoid the problems with depthpass when the camara in inside the shadows, so I made some modifications to my old shadow code. Old code, depthpass: glCullFace(GL_BACK); glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); RenderVolume(); glCullFace(GL_FRONT); glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); RenderVolume(); New code, depthfail: glCullFace(GL_FRONT); glStencilOp(GL_KEEP,GL_INCR,GL_KEEP); RenderVolume(); glCullFace(GL_BACK); glStencilOp(GL_KEEP,GL_DECR,GL_KEEP); RenderVolume(); Now, I also modified the shadow volume geometry generation, and they're now capped in both sides. I can now go inside shadows without every shadow flipping out, but now there's another problem, some shadows appear from behind objects, like in this screenshot. This is the same scene, but with visible shadow volumes. Also, this is the setup done before rendering the shadows. glDisable(GL_LIGHTING); glDisable(GL_FOG); glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); glDepthMask(GL_FALSE); glShadeModel(GL_FLAT); glStencilFunc(GL_ALWAYS,1,$FFFFFFF); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); [Edited by - Relfos on February 16, 2008 12:19:31 PM]

Share this post


Link to post
Share on other sites
I believe you have to render the rest of your scene with
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR) after your shadow volume pass. Are you sure you got the siloheuttes right and that they are capped at both ends.

I've found winding orders to be a pain with this.

What method are you using to cap? Homogenous Coordinates? Depth Clamp NV?

neutrinohunter

Share this post


Link to post
Share on other sites
Quote:
Original post by Neutrinohunter
I believe you have to render the rest of your scene with
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR) after your shadow volume pass. Are you sure you got the siloheuttes right and that they are capped at both ends.

I've found winding orders to be a pain with this.

What method are you using to cap? Homogenous Coordinates? Depth Clamp NV?

neutrinohunter


I dont render the scene after the shadows, only a black quad over the screen.
I'm pretty sure the volume geometry is correct, I generate the volume by extruding quads to a very long distance (cant get it to work to infinite with homegenous coordinates, the volume just disappears...)
Then I add caps to the front and back of the volume by reusing the triangles inside the silhouete.

Also tried to use a infinite far plane, but I also cant make it to work, everything disappears again, probably a wrong projection matrix setup.

Share this post


Link to post
Share on other sites
Post your routine for your drawing of your shadows and your geometry, looks to me like the stencil problem isn't recognising the geometry as being stencilled, therefore when you put the quad over the screen, its essentially marking only the shadows.

Share this post


Link to post
Share on other sites
Thanks for the help, but already solved it ;D
The problem was actually with the volume capping. Altough the volume was closed, I was using the projected back faces for both the front and back of the volume.
By using the correct project faces from the silhoute, a different capping was created, and now everything works fine.

Share this post


Link to post
Share on other sites
Its always something simple, I realised yesterday that my siloheutte determination that I had been looking at for bugs for the best part of a week was actually working, and the box I had coded had the wrong winding order :|

And today I've realised that my Shadow Mapping code wasn't working with frame buffer objects because I was using a float instead of an int :|

Just out of interest, what sort of frame rate you get for the Quad drawing method, I'm using the Kilgard method out of "Robust Stencil Shadow Volumes Paper" and I was wondering how they would compare and whether I should bother implementing the other method (yours).

Share this post


Link to post
Share on other sites
Well, I used to build the volumes with triangles, and the capping still uses them.
Only the volume extrusion is built with quads, and theres probably some fps increase, since I'm rendering less vertices, a quad requires only four and an extrusion with triangles require six vertices. I dont have actual values to compare, tough :/

Share this post


Link to post
Share on other sites
Yeah, well I'm having trouble with trying to determine the siloheutte of a Sphere because I built it with triangle strips rather than triangles and something isn't right :P So was thinking of trying the stencil quad approach because it would be translating normals for the caps rather than what I am currently doing.

Looks good, couldn't see the picture before but the screenshot looks very nice. It a game?

neutrinohunter

Share this post


Link to post
Share on other sites

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this