View Full Version : suppress self shadows
09-17-2005, 02:54 AM
i'm working with stencil shadow volumes and i'd like to get rid of those nasty self shadows on cylinders and spheres. does anyone have a good idea how to suppress those? it's no problem to keep certain geometry from receiving shadows at all, but i still want it to recieve shadows from other models, just not from itself. thx!
09-17-2005, 05:42 AM
Are you using different models to generate shadow polys from, then the models you're actually drawing for lighting? I dont see any other reason to have bad self shadowing :) When I use the same model, everything works nicely!
But to stop something self-shadowing I guess when you draw it you want the stencil to exclude the object itself. Well the first thing that comes to mind is:
Draw stencil volumes for scene into stencil (exclude model)
Draw model thats not self shadowing with lighting (only that model!)
Draw model volumes into stencil
Draw rest of scene with lighting
There might be a more optimal/less intrusive method though? :)
09-17-2005, 07:50 AM
If you use a very large polygon offset (or a vertex program) to push just the z-value of the shadow volumes to the back you can avoid 99% of all popping artefacts.
09-17-2005, 08:27 AM
The popping that occurs comes from phong (or gouraud if someone uses that :) ) shading, since it also illuminate backfaces. There are a few ways to deal with it.
1) N.L^value, to "narrow" the shading. In other words; make it less illuminated.
2) Renderer back-faces from the light source where stencil=1 and set stencil=0.
3) Disable self-shadowing (like DOOM 3).
09-17-2005, 10:25 PM
Another possible way to do it, might be easier to implement and work better with deferred shading:
If you sorted your shadow volumes so that you draw all the ones for objects that dont self shadow first, then zeroed the stencil buffer with the visible faces of those objects, then proceed as normal with the rest of your regular shadow volumes & lighting, it should work out. This would prohibit any non-self shadowing object from casting onto another non-self shadowing object though, and it might be a bit slower than cheifwiggums suggestion... but it lets you do all your volumes without switching gl state back and forth from rendering to stencil fill.
09-17-2005, 11:25 PM
09-17-2005, 11:32 PM
P.S. of course if you should only be attenuating the direct illumination term if you're stencil testing ambient & other stuff then that's just idiotic.
09-18-2005, 02:58 AM
wow thanks for the feedback. i'll give ChiefWiggum's suggestion a try and will also take a closer look at the code from r3.nu :)
09-18-2005, 06:55 AM
Originally posted by dorbie:
http://www.r3.nu/~cass/shadow_volumes/NonPoppingShadowVolumes.txt From the lenghty discussion I remember there were some problems with this technique (especially with concave objects) that were unsolved. Has that changed?
After all the things I tried I really found that the simplest solution is the best: Offset the shadow volumes away from the viewer. This avoids those artefacts that come from the fighting between gouraud shading and the discrete silhouette approximation.
09-18-2005, 11:25 PM
Offset the shadow volumes away from the viewer.what exactly does this mean? thx! :)
09-19-2005, 01:36 AM
Originally posted by Vexator:
Offset the shadow volumes away from the viewer.what exactly does this mean? thx! :) Add an appropriate value to the z-coordinate of the shadow volumes in eye view (the simplest solution is to use glPolygonOffset() with a factor of 0 and a high value for units)
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.