Archived

This topic is now archived and is closed to further replies.

Alload

Making shadow volumes and making them fast!

Recommended Posts

Alload    122
Making good looking real time shadow volumes are not an easy task, but when you have to do them fast it almost becomes impossible! So if you would like to present the optimizations you thought about building shadow volumes, it could be vrey helpful. In my engine, I build a shadow volume for each triangle in the scene (8 triangles to make one volume) and it''s pretty slow. Thus I''m trying to find a way to draw less triangles, but I haven''t found yet. If you have any idea?

Share this post


Link to post
Share on other sites
Tessellator    1394
+ If you have static geometry and static lights, you can precompute your shadow volumes. You can stick bounding boxes around the near/far capping tris for each volume, and test to see if they are visible quickly. If they''re not visible, then you dont need to draw ''em (the capping tris that is).

+ You only need to extrude silhouette triangles for the shadow volume (in most cases..), so I''d setup some functions like
object->GetExtrudedSilhouette(...)
object->GetFrontFacingTrisWithRegardToTheLight(...)
object->GetBackFacingTrisWithRegardToTheLight(...)
However, there aren''t really any good shortcuts for these functions (that I know of), so shadow volumes tend to be quite slow. (Drawing them is pretty slow anyway..)

+ If you are using OGL and attenuated light sources (like DoomIII), you can use glScissor() to contain rendering to just the area where the shadow is needed (i.e. the area effected by the light source). I expect you can set up a similar thing with D3D using alpha/clip planes/more stencil ops - haven''t really thought about it..

Other things i''d think about is not having self-shadowing on animating/dynamic objects. They''re cool when they are still, but when they (or the light) move, you get a nsty popping effect as the silhouette shifts across triangles. Also, no self shadowing means you can use a lower quality version of the mesh, which again speeds up shadow volume computation.

To be honest, I''ve only really started fidling with shadow volumes, but I may go back to using projected shadows since they''re just a damn sight faster and easier.(if not a "true" lighting solution).

Hope that gave you some ideas,
T

Share this post


Link to post
Share on other sites
CrazedGenius    156
If you are using DirectX, look at nVidia''s or ATI''s samples that involve using vertex shaders to extrude the volumes. I think there are OpenGL equivalents, but I''m not positive.

Also, (forgive the sales pitch - I try to only do so when it directly answers the question), I cover three different shadow methods in Real Time Rendering Tricks and Techniques in DirectX. The shadow volume technique is basically the same as the aforementioned samples, but I tried to provide more explanation than the sample code gives you. You might want to take a look at that.

The shader methods are quite fast. The require the objects to be rendered a couple of different times, but you can speed that up even more by creating optimized (less triangles) versions of the mesh to be used when you create the volumes.

Share this post


Link to post
Share on other sites
Alload    122
I think computing the possible silhouette is the next enhancement I will made.

Then we could compute an octree or a bsp for the shadow volumes...

Ah, shadow volume is so powerful but need so many optimizations to run fast enough.


I wonder if using stencil shadow volume along an older method could improve the framerate while not looking too ugly.

Share this post


Link to post
Share on other sites