PDA

View Full Version : Shadow Volumes + Lightmaps.



MrShoe
04-23-2003, 10:45 PM
Ok, say i had a level which is basically a single big hallroom. there were a number of lights which dont move and there were models located inside the room. I was thinking of precalculating lightmaps for the room, and using stencil shadows for the models. However, i think i read somewhere that combining lightmaps and shadow volumes was bad, and didnt look good. Is this true?

JustHanging
04-23-2003, 11:14 PM
Quite true. The biggest problem is, that stencil shadows typically create very hard shadows and lightmaps very soft ones. Combining them looks really bad. You could use projected shadow textures instead of stencil shadows, they'll propably be faster and can more easily be made to produce similar shadows to lightmaps.

Another problem is double shadowing, meaning that the shadows cast by moving objects will also darken the areas already in shadow. Easiest way to fix this is to have a seperate lightmap for each light.

-Ilkka

hunsoul
04-23-2003, 11:26 PM
Originally posted by JustHanging:
...Another problem is double shadowing, meaning that the shadows cast by moving objects will also darken the areas already in shadow. Easiest way to fix this is to have a seperate lightmap for each light.

-Ilkka

Could you write down this method with more details, please? What do you do if you have a separate lightmap for each light?

JustHanging
04-24-2003, 12:08 AM
There are several ways, here's one. I assume you know how to do basic lightmapping and projected shadow textures. You will need destination alpha, so make sure you run in a 32 bit mode.

First draw one pass, where you draw the abmient light. Set all alpha to one.

Set depthfunc to GL_EQUAL

Then for each light:
-Draw the shadows for the objects with color writes disabled. Set alpha to 0 in the shadows. You should use multiplicative blending to get the overlapping shadows right.
-Then add the light from the light's lightmap. Use the blending function GL_DST_ALPHA, GL_ONE
-If there are more lights to add, clear the alpha channel back to 1.

If you can use a seperate blending function for color and alpha (geforce 3 and up, I think), you can set alpha to 1 while adding the light.

When you're done with the lights, modulate with the textures.

-Ilkka

davepermen
04-24-2003, 05:04 AM
if you use stencil shadows bether use the same approach for the room. but precalc the shadows, means pre-intersect the static constant shadow volumes with the static constant scene, generate those shadow-triangles.

would look more consistent => 99% nicer. and is still very fast. on ati.com there's the funny demo with the balls that make sound. they used that technique. its described in some papers.