Jump to content
  • Advertisement
Sign in to follow this  
ic0de

Shadow volumes in glsl?

This topic is 2557 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

Does anybody know a good tutorial on how to do Shadow Volumes(not shadow mapping) in glsl? I've seen plenty of tutorials using the stencil buffer but those are all using the fixed function pipeline I need to do it with a shader.

Share this post


Link to post
Share on other sites
Advertisement
The stencil buffer is a key implementation detail of GPU shadow volumes, even when using shaders. You use the stencil buffer to determine whether a pixel is inside or outside the shadow volume, and then you only light the pixels outside the volume (using a shader, if you like).

The traditional method is:
Draw scene using only ambient lighting.
Do stencil buffer magic to create a stencil mask of "in" vs "out" pixels.
Draw scene using lighting shader, but only where stencil buffer is "out".

Share this post


Link to post
Share on other sites

The stencil buffer is a key implementation detail of GPU shadow volumes, even when using shaders. You use the stencil buffer to determine whether a pixel is inside or outside the shadow volume, and then you only light the pixels outside the volume (using a shader, if you like).

The traditional method is:
Draw scene using only ambient lighting.
Do stencil buffer magic to create a stencil mask of "in" vs "out" pixels.
Draw scene using lighting shader, but only where stencil buffer is "out".


Thank's for the good explanation, but is there a tutorial you could refer me to on doing this with GLSL?

Share this post


Link to post
Share on other sites
Do you really need a tutorial for that?
It is exactly the same, you still use the stencil, you just need to write a shader that outputs the shadow volume positions. Since color is not needed (as you should have called glColorMask(0,0,0,0) before), you can just output any color you want in the fragment shader (black, white, or whatever).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!