Jump to content
  • Advertisement
Sign in to follow this  

Stencil shadow volumes - general tips and advice?

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



After much hard work I have just finished my first implementation of stencil shadow volumes. It works perfectly about 98% of the time. But every now and then I see a small artifacts appear in isolated regions. It is so infrequent that it is probably acceptable but I think it might be worth going the extra mile to hunt down these artifacts.


But before I do that, I was wondering if anyone could offer some general tips or common sources of error that can create occasional artifacts.


Here are some of the measures I have tried (based on papers/articles i've read) to eliminate artifacts:


1. when determining if a triangle is facing the light, i take the dot product of the light-to-triangle vector with the triangle normal, and I return true if dotProduct > epsilon, where epsilon is a small positive value, rather than just zero.


2. when creating the front and back faces of the volume, I move the front-face along the direction of the light-vector by a small epsilon. Presumably this is because  "due to floating point errors we might encounter bizarre corruptions where the volume hides the front cap". Not sure i fully understand this but I thought it was worth a shot.


Neither of these fixed the occasional appearance of artifacts. Does anyone have any more tricks or tips that might help?


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!