Dynamic Light/Lightmap/Shadowmap

Okay, here I go with another one of my stupid questions. First of all, what the heck is the difference between a shadowmap and lightmap? Second of all, and this is kind of a not so simple question and I’m sure there are multiple answers, but how does one go about implementing each of these, and when would one implement each of them?

A shadowmap could be considered the same thing as a shadow buffer, which is in the light properties in Blender. These are your standard dynamic BGE shadows. They are good for dynamic scenes and lights. Shadow buffers are really depth buffers rendered from the camera’s point of view, and are used to compute shadows.

Alternatively, a shadowmap could be a texture that records how much contribution each point on a surface receives from a light. Basically, it records shadows, but is pre-baked. I don’t think this kind of shadowmap is possible in Blender, but could be implemented with a custom shader. Good for static lights and scenes that are too large for Blender’s shadow buffers to be practical.

A lightmap is a (usually pre-baked) texture that stores the overall lighting for a surface, potentially including AO, indirect lighting, and sometimes even shadows and sunlight. Light maps are added to the total lighting(they are often mixed with dynamic lights) for a surface. They are good for static AO and indirect lighting, but not always good for direct(directly from a light source) lighting, as they are incompatible with normal maps. I think this kind of lightmap was added to Blender in the Harmony branch, but I’ve never played around with it, so I don’t know how the new lightmaps work exactly, or how to enable them.

Well explained.

Just one remark:

I think you mean “from the light source’s point of view”. :wink:

Ah, thanks. That clears everything up.

Actually, I don’t quite get it anymore. Okay, I get what everything is, but I don’t understand how you use lightmaps. Or rather, since that doesn’t make since, are light maps simple the light raytrace rendered and then used as textures (or at least, this is how I understand them). But regardless, if that’s the case, doesn’t that mean that lightmap materials need to be shadeless? And is that’s truely how you use them does that also enable to use dynamic lighting at the same time (and what happens to specularity). If you can’t, then you can’t have anything dynamic since dynamic lights wouldn’t have any affect on the shadeless textures, and lightmaps can’t live update. Sorry for all these questions. I can’t really understand any papers written on them, plus I cant find a tutorial on how to use lightmaps in blender, or whether using dynamic light or lightmaps are “better”.
Thanks.

You can create a lightmap by creating a second set of UV’s for all your objects and giving them all unique, non-overlapping UV coords in this second set of UV’s. Add a new texture in the UV/image editor, select all the objects, and bake.

If you only want an AO only lightmap, then it’s a simple matter of selecting AO in the bake menu. Otherwise, it’s more complicated. To add direct lighting(sun lamps, point lamps, etc.) and shadows, I would bake with the “full render” option, with each object temporarily set to a white, non-specular material. I have no clue how to do indirect lighting, really.

You don’t need to make a material shadeless to use lightmaps. You can set the lightmap texture’s blend mode to “add”. This way it can work in conjunction with dynamic lighting and shading. Remember to only include static lighting in a lightmap(temporarily remove/disable all your dynamic lights before baking the lightmap).

I hope this cleared things up a bit.

God bless you.

Let me add that if you’re using normal mapping, you should still make the most imprtant lights in your scene real-time, as lightmaps ignore normal mapping. The advantage of lightmaps is that they can be used to display an unlimited amount of static lights for little cost, so they are a great complement to real-time lighting(use them for AO and smaller, less important lights).

EDIT: I think my previous comment about using the add blend mode for lightmaps was incorrect. I think the Harmony branch added support for proper lightmaps, I’ll have to check it out.

Ahh, I figured it out. You set the influence the object’s emit value in the texture properties. Unfortunately, it need to be a grayscale texture, as far as I can tell(I had to check the RGB to intensity button to get it to work). So no colored lighting for us:(.

Now, if you wanted to get fancy, you could probably implement proper RGB lighting easily with material nodes. Actually, I’m certain you could.