Pre-calculated shadows

Can somebody help me with pre-calculated shadows?

How to use them…when use them…



thanks in advance!

Arturffs said:

Can somebody help me with pre-calculated shadows?
How to use them...when use them...

This is a rather complex question. I have recently built pre-created shadow maps on the world terrain into my game, and can give you a few hints for that specific case.

I render the shadow maps by casting rays from the terrain at the positions where the pixels are at. If the ray hits something (occlusion = 1), the pixel gets colored black, if it passes (occlusion = 0) it is a white pixel. I then extended that to make smooth shadows by casting sub-pixel rays and adding their weighted occlusion values to a "blackness" value for the shadow map pixel.

The generated lightmap can then be applied to the terrain simply by using multitexturing with modulative blending (and proper texture coordinates of course).
(In case you were wondering: I use BufferedImages to render the shadow maps to, and ImageIO to store them to disk)

As for when to use them, I'd say any time you can, because it will almost always be a LOT lighter on the cpu (or gpu) to use lightmaps than dynamic shadows, and smooth shadows are really easy to do without any additional computational or memory overhead.

I've seen Sunflow used for lightmap and ambient occlusion generation.  (http://sunflow.sourceforge.net/)

Blender is just as good. It has texture baking, radiosity, and ambient occlusion generation.