How to create/implement lightmap?

Let me first say what my overall objective is, and then I’ll ask my question. I’m pretty new to game dev, so maybe lightmaps aren’t even what I should be looking at. So, my overall objective is to make my renders look better. The problem as far as I can tell is that everything is getting the same amount of shading, e.g. a cube in the shadow of a wall has the same color value all around and thus looks like a blob. From reading around, this is because only direct lighting is being used to calculate the cube’s final color and since it’s in the shade it gets just one color value. After further reading, it seems like the best way to get indirect lighting into the scene is to use lightmaps.

And now, my questions: how does one go about generating a lightmap? It seems other game engines generate them in their editors. What is the panda3d method? Then, once I have a lightmap, how do I apply it in the scene? Presumably, it’s some kind of texture, but does it need a specific texture mode (like what normal maps do)?

Lastly, some relevant facts about my setup: I’m using a simple scene of a room (no ceiling) with ambient light and a directional light, and the cube sits just off center in the room. I’m using the auto-shader to achieve the shadow effect I have currently. All my assets were created in blender 2.8 and exported to egg using the 2.8 fork of YABEE.

Thank you for your help!

I have not played much with light maps, but I would probably try to have Blender bake the light maps. The results of the light map needs to be multiplied with your diffuse, which you can do in a custom shader or use multi-texturing and making sure the lightmap is set to modulate, which is the default.

However, that being said, it doesn’t sound like shading is working correctly on your cube. While indirect lighting makes things look a lot nicer, your cube should still be shaded with direct lighting. In other words, all fragments of the cube should not be the exact same color.

Thank you for the response! I’ll follow the process in the links and see if it helps. I do have a couple follow up questions though: I read stuff about needing to make a second UV map for the light map, is this true in panda3d as well? Or just something other engines need? Also, since you don’t use light maps, what do you do normally to increase your graphics quality?

A second UV map is generally recommended for light maps since you usually do a single light map for a level. In other words, the UV coordinates for a diffuse map for a mesh are going to be different the UV coordinates needed to lookup the mesh in a light map.

I have not had a project recently that really needed indirect lights. I have gotten away with well-positioned direct lights. Light maps seemed like way to much of a pain to bother with. I have recently been looking into Image-based lighting to handling indirect lighting.

1 Like

Another way to do it that avoids all the issues with UV mapping is baking the lighting into the vertex colors of the model. However, the downside is that very large polygons will not show very detailed lighting; you need a certain amount of detail to be able to have distinctions in light values.

I’m not familiar with baking lighting into vertex colors. What’s the process for this?