Lightmaps & shadows

Hi all, I’m trying to do what some people call “lightmaps”. This is no texture or multitexturing related question, but more about a method to perform this (even if I don’t know exactly how to render a shadow).

So let me explain what I exactly want to do :

First I want to cast shadows from a single light source. This light source is STATIC (the sun), it won’t move, so I want to perform a minimum of calculations each frame. Of course I can perform a lot of precalculations while the app is loading, I can even store the results in a file.
I want to use this to cast shadows from trees, as they are lit by the sun. The leaves of my tree are rendered with alpha textures, and I want theses “holes in the polys” to be rendered on the ground shadows. The ground is NOT flat, and I want the tree to self shadow if necessary.
The best, I think, would be to store these shadows in a file (so what should I store exactly ?), and to render them as if it were textured on the objects of my scene (by multitexturing or any other way)

Second I want to perform the same thing, but with multiple light sources (for indoor lightmapping). If shadows overlap, then the “resulting shadow color” will be darker.

Any suggestions, any links, any help of any kind would be much appreciated.


PS : At the moment I am reading a pdf written by Mark Kilgard from nVidia about stencil shadows, is it the best way for my problem ?

[This message has been edited by Master Lolo (edited 01-09-2002).]

You can’t use stencil for alpha-cutout or alpha-blend shadows. I would say that your best bet is to use projected shadows when generating your terrain light map.

You can use projected shadows to do self-shadowing, if you sort each polygon based on distance-from-light, and draw nearest-first, and update the light map after every intersecting (as viewed from the light) polygon is drawn. This is not fast, but could be OK for load-time work, if you want self-shadowing with alpha cut-out or blending.

You think right. You should apply a lightmap texture on all static objects in your scene. These textures can be generated before rendering even a frame(it’s done when you design the scene). You should determine for each lightmap texel if it’s visible by the light source. If yes it should have a brighter colour. You can do this with all lights. An easy way to do this is rendering the scene from the texel’s point of view, with every geometry having e.g. black colour except for light sources, which have e.g. white colour. The more white is visible, the lighter is the lightmap texel. This also solves the problem of the leaves too.

However this light model is not really lifelike, it produces sharp shadows. The most popular method for lightmapping is radiosity. E-mail me if you want to know more about that.

You can find fine information on real-time shadows on nvidia’s site.

Hope this is what you wanted, cheers

Bartha Tamás

[This message has been edited by kistompika (edited 01-09-2002).]

Yes, yes you two are certainly right ! But I need more details :
jwatte, do your projected shadows agree with kistompika’s method ? As I don’t know much about this, I must ask you if this would be the fastest way … ?
kistompika, can you explain a bit clearer your method, I don’t get it …

thx for your help