PDA

View Full Version : Shadows...



Rados
10-20-2002, 11:10 AM
I'm making a portal based engine and i want to add shadows to it. But, I can't decide between Stencil Shadow Volumes and Shadow Maps.

At first it would seem that the shadow maps are faster because you render less polygons per light (only the back facing polys) and then just render the normal scene with the shadow map texture as a second texture.
But, what if I have more than 1 light? I would have to render the geometry 2 times per light, and that sucks.

So I created a stencil shadow volume demo. It only renders the scene once + the shadow volumes + scene texture quads (see below). It worked like this:
-Render the scene with lighting, bump-mapping...
-Save the scene to a texture.
-Render a transparent black quad over the whole scene (alpha = 1 - ambient light value)
-For every light:
-Render the shadow volumes in the stencil.
-Render the scene texture over the whole screen (alpha = light value)
-Clear the stencil buffer
-End for every light

This avoids the re-rendering the geometry again for every light.

This is somehow faster (i think) for multiple lights and complex scenes than the shadow maps because I render the scene into a texture and then I just paste the blended texture over the screen (and the stencil test rejects the pixels that are in shadows)...

So I thought if I use the shadow maps and I could somehow convert the shadow map data into the stencil buffer, rendering would be faster (because i would render less polys per pass then the shadow volumes).
Does anyone know how to do that?

zed
10-20-2002, 07:27 PM
what was doom3 doing a scene, something like 50x passes or something crazy.
on a personal note i just added multiple dot3 lights to my engine this requires a pass per light (on my hardware) but i found it affects rendering speed very little perhaps 25% with 10 lights on screen.
i guess the moral of the story is dont sweat about multiple passes, todays hardware love them (maybe not as much as a ps2 does but http://www.opengl.org/discussion_boards/ubb/smile.gif )

jwatte
10-20-2002, 09:00 PM
You have to render your scene once per light no matter which shadow technique you use. That's because things that are in shadow from one light may receive light from another light. Stencil can't solve that any better than shadow maps.

ToolChest
10-21-2002, 04:41 AM
I need to upgrade my card... I have a gf2 if I go over 4 passes full screen my frame rate is in the 20's... http://www.opengl.org/discussion_boards/ubb/frown.gif

What hardware are you running? How many over samlpes average are you doing? Whats your screen rez? I take it the gf2 is more or less dead... http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks for the info...

John.

[This message has been edited by john_at_kbs_is (edited 10-21-2002).]

Mazy
10-21-2002, 05:22 AM
I use gf3, and i aggre that multipass is not that bad that some might think.
http://mazy.annat.nu/images/opengl/multishadow.jpg

i know, no FPScounter, but it is around 30-35 fps ( you have to trust me :-) and most fps drop is due to using nvidias Render_to_depth_texture 2 times..

but 77passes per frame, and 30fps something, and no vertexspeedup (just normal vertexarrays)

ToolChest
10-21-2002, 08:02 AM
Originally posted by Mazy:
I use gf3, and i aggre that multipass is not that bad that some might think.
http://mazy.annat.nu/images/opengl/multishadow.jpg

i know, no FPScounter, but it is around 30-35 fps ( you have to trust me :-) and most fps drop is due to using nvidias Render_to_depth_texture 2 times..

but 77passes per frame, and 30fps something, and no vertexspeedup (just normal vertexarrays)

Ya, that sounds about right. I looked at the nvidia site and the gf2 pro's fill was 800m pixels and the gf3 is 3.8b. Also my screen rez is 1024x768 not 640x480.

I've been holding out for the new nvidia card (when ever its coming out http://www.opengl.org/discussion_boards/ubb/frown.gif)...

Thanks!

John.