PDA

View Full Version : question on Shadow Volumes...



MickeyMouse
09-09-2002, 01:23 AM
hi people!

i'm currently working on implementing shadow volumes for my engine and i have question about it.......

What is good way of determining how big should be shadow volume?

in most OpenGL examples i saw shadow casting edges are extruded to "infinity" which is not a problem since there's usually ONE room with some stuff inside.....

It becomes complicated when there're many connected rooms and i have to decide which lights should "produce" shadows in which rooms (or on which polys)...

I'm a bit confused about it because i can't see an ideal solution for this...

thanks for any help

AdrianD
09-09-2002, 01:57 AM
search on this forum for "stencil volumes" or "shadow valumes" and you will get all the answers you are searching for. ("shadow" is also a good keyword to search for...)

MickeyMouse
09-09-2002, 03:15 AM
i did. not only here http://www.opengl.org/discussion_boards/ubb/frown.gif

okapota
09-09-2002, 05:32 AM
if you are doing stencil-shadows withought attenuation than there might be problems that i cant think about right now.
but anyway, here is what you should do-
for each light draw the scene with this light's SV.
if you do it this way, and everyobject casts a shadow, there wont be any problems.

MickeyMouse
09-09-2002, 05:50 AM
theoretically there won't be any problem when everything casts shadows of every light...

but it's obvoius that you can't consider all lights you have in your game level when doing shadow volumes - the performance will suffer.....therefore i think i should consider only those of lights that have considerable influence to geometry currently visible on the screen

just a thought - wouldn't it be nicer if we had light_volumes instead of shadow_volumes http://www.opengl.org/discussion_boards/ubb/smile.gif, so that we had to render scene black first and then for every light_volume overbrighting some places?

Lars
09-09-2002, 07:32 AM
Shadowvolumes work like this. You first do an ambient pass with your object(s).
Second you mask out the areas in the stencilbuffer where no light is coming to with the rendering of the volume.
third you draw your lighted object(s) with additive blending.
You do steps 2 and 3 for each light and then modulate your scene with a final pass to apply textures and such.

If you have attenuated lights, you can limit your volumes by scissoring (that is in another thread in here).

And you could also limit your volume, but you have to be shure that it is closed and that you handle the special cases where the camera is inside the volume, or the volume gets clipped and so on.

Lars

MickeyMouse
09-10-2002, 12:35 AM
Thanks for your replies.

But is there any way of avoiding shadow volume going through wall from one to another room?
Let's say the wall is not flat but rough, so shadow volume couldn't be just "cut" along that wall.

To clarify in the viewport you can see both rooms next to each other, but these rooms don't see each other (being in one of them you can't see the other one). And in both of them there's light source which produces shadows. Ok, and i don't want shadow from one room to be visible in the other one.

Now in order to avoid some artifacts of shadow of first room visible in second room would it require some expensive shadow volume cutting, so it is not visible on the other side of wall?

Did anybody have similar problems?

dorbie
09-10-2002, 12:45 AM
You don't draw the shadows, you draw the illuminated surfaces tested against shadow volumes. This is very significant because it makes a huge difference.

If an object from one room casts a shadow in the adjecent room, the walls of the room itself will also cast a shadow into that room, and that means that the entire room and contents will fail the stencil test for the illuminating light pass, so your problem does not exist with a correctly implemented stencil tested lighting engine. The real reason to trim the shadows is to avoid unnecessary overhead when rendering the stencil increments & decrements.

Carmack mentions that he uses beam trees for shadow volumes and in an interview suggested that he clips some volumes to the beam trees, not to avoid visible artifacts but to reduce the pixel fill overhead from stencil volume walls.