# Strange issue with shadow volumes

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

## Recommended Posts

finally i've finished my shadow volumes demo. Works (i hope...) but there's a strange bug (maybe it's strange for me but not for you ogl-gurus), here's a screen: http://www.neoborn.com/users/b3rs3rk/shadow%20bug.jpg in a nutshell, i don't know why, but it's rendered also the base of the volume, instead of being rendered only the part on the floor. Anyone knows how to fix this? PS: a special thank to rodzilla who helped me a lot with his advices :)

##### Share on other sites
It looks like this is simply the result of leaving the shadow volume open at the base. The volume should be a closed surface, so in this case, you'll need to render an extra quad to close off the bottom.

##### Share on other sites
looks like both the near and far shadow volume caps are wound the wrong way. Try reversing them...
Then again if you are uisng depth-pass shadows, then you should not be using near/far shadow caps.

##### Share on other sites
tryed, but nothing changes :/

##### Share on other sites
Hmmm could you post your code ? It's difficult to guess with the screenshot only.
Are you doing z-pass or z-fail ? Still drawing the shadow as a big blended gray quad (not sure but in this case I'd draw caps even in z-pass mode) ?

##### Share on other sites
in my render function I clear the buffers, draw the scene (a simple room and a shadow caster quad) and then i do these passes:

glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );    glStencilFunc( GL_ALWAYS, 0, 255 );	glDisable( GL_LIGHTING );		glDepthMask( GL_FALSE );	glDepthFunc( GL_LEQUAL );	glEnable( GL_CULL_FACE );    glEnable( GL_STENCIL_TEST );	glCullFace(GL_BACK);	glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);	Quad.DrawShadow(LightPos,100);		glCullFace(GL_FRONT);	glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);	Quad.DrawShadow(LightPos,100);    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );	glDepthMask( GL_TRUE );    glCullFace( GL_BACK );	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);	glStencilFunc( GL_EQUAL, 0, 255 );	glColor4f( 0.0f, 0.0f, 0.0f, 0.5f );	glEnable( GL_BLEND );	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );	glPushMatrix();	glLoadIdentity();	glBegin( GL_TRIANGLE_STRIP );		glVertex3f(-0.1f, 0.1f,-0.10f);		glVertex3f(-0.1f,-0.1f,-0.10f);		glVertex3f( 0.1f, 0.1f,-0.10f);		glVertex3f( 0.1f,-0.1f,-0.10f);	glEnd();	glPopMatrix();	glDisable( GL_BLEND );	glDisable( GL_STENCIL_TEST );	glDisable( GL_CULL_FACE );

##### Share on other sites
OK, seems you're doing z-pass.
Do you draw caps for your shadow volume (I'm pretty sure you don't) ?

A solution for your problem would be to draw caps. A better one (to me) would be to make sure you draw shadows on objects only (the problem on your screenshot is shadow that's cast "in the air"). You could use the z-buffer for this : objects are wherever the z value is smaller than 1.0.

glEnable(GL_DEPTH_TEST); // test the depth
glDepthFunc(GL_GREATER); // and draw only when the z value is < 1.0

And don't forget to reset this mess after drawing the shadow quad...

Hope this helps.

##### Share on other sites
this way i get rendered only the base of the volume o_O

maybe i should try rendering the caps :/ ( how ? )

##### Share on other sites
I assume you didn't forget to reset the depth range right after drawing the quad (glDepthRange(0.0, 1.0)).

Drawing caps is easy :
- render all triangles of your shadow casting object that don't "see" the light (i.e. light is in their "back") ;
- render all other faces displaced using the function you used to extend the shadow volume (i.e. translate all vertices 100 units away from the point light IIRC).

##### Share on other sites
Quote:
 Original post by rodzillaI assume you didn't forget to reset the depth range right after drawing the quad (glDepthRange(0.0, 1.0)).Drawing caps is easy :- render all triangles of your shadow casting object that don't "see" the light (i.e. light is in their "back") ;- render all other faces displaced using the function you used to extend the shadow volume (i.e. translate all vertices 100 units away from the point light IIRC).

shouldn't it be

- render all faces of your shadow casting object that "see" the light (i.e. light is in their "front") ;
- render the same faces displaced using the function you used to extend the shadow volume (i.e. translate all vertices 100 units away from the point light IIRC) but with vertics in reverse order.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633685
• Total Posts
3013322
×