View Full Version : Shadow volume rendering

Claus - TSI
09-29-2010, 10:22 AM
I don't know if this goes in the newb thread or in the advanced thread, but I'm a newb, so here it is.

I have an old OpenGL/CUDA application where I render thousands (3800+) of free standing quads and each quad throws a shadow using a shadow volume. The light source moves with time, so the "length" of the shadows change.
The app uses the fixed pipe line, resolution ~1920x980 on an Nvidia GTX480.

The vertices for the quads and the shadow volumes are calculated by a CUDA kernel and stored in a vertex buffer object in world coordinates.

As the shadows grow longer the rendering time goes up; it ranges from ~4 to ~65 ms for the same view.

So I have the following questions.
1. Is that spread in rendering time reasonable?
2. Would switching to shaders be likely to result in a decrease in rendering time?
3. Right now the shadow volumes are rendered in world coordinates. Would it make a difference if I switched to a coordinate system that matched the light direction?

09-29-2010, 11:44 AM
As you describe it, this looks like you are more limited by fillrate, rather than anything related to vertices.

You can verify that, when rendering to a much smaller window : you should see a reduction in rendering time, down to being vertex limited.

I think the biggest problem is overdraw of the shadow volumes, especially with long shadows, as it is likely that you end-up having rendered hundreds of time each pixel.

Can you post a typical "slow" screenshot ?
And a second one with shadow volumes as wireframe ?

Claus - TSI
09-29-2010, 12:36 PM
Thanks for your insight ZbuffeR!

You are right about the rendering time decreasing as I make the window smaller.
I have attached (I hope) two screen shots. filled.jpg shows the scene as it normally looks with nearly horizontal shadows and wireframe.jpg replaces the shadows with wireframes, not that makes much of a difference image wise since there are so many shadow volumes.

09-29-2010, 03:30 PM
You might want to try googling shadow volume optimizations. Most of the tricks involve scissoring the screen or limiting your shadow volumes. For example, if all the volumes go into a flat ground plane (or wall), you shouldn't be rendering geometry past that. That might significantly help your fill limitations.

Claus - TSI
10-01-2010, 08:49 AM
Thanks y'all for your suggestions.
I pretty much just cheated and made the shadow volumes shorter. Since this only affects the image when the light is parallel to the ground the shortened shadows are acceptable. They now render in 15 ms which is acceptable for now.