Game Engine Lightmaps

This tutorial explains the usage of the new mesh layers in blender for use in the game engine.
We will be modifying the FPS template, by Social. and using a UV script by z3r0d


Template
Script

Step, by step.

 In the included template the main mesh already contains UV coordinates and we will be using them as the first
set. I will be using the included script to generate the light-map coordinates, but you can use any other way of  generating
your coordinates. If you do plan to use other means of UV mapping you must keep the coordinate bounds inside the image window
in order to get the baked image to turn out.


 Select the main mesh and go into the editing buttons (F9). In the mesh panel you should see something like this.

 Next to the line 'UV Texture' press the New button to add our second set of coordinates. Name the newly created
coordinates to Lightmap. With the 'Lightmap' slot active, we need to create a new image to bake, and apply
the script. Go to the UV window (Shift F10). Select Image->New from the window's menu. The default settings 256x256
will do the trick.


 Go to the Text editor (Shift F11) and open the included script. With the main mesh selected execute the script (Alt+P)
Go back to the UV window (Shift F10) and enter Face select mode (F). you should see the newly created coordinates
in the UV window.

 Make sure to assign the new image to the mesh coordinates just created. Add a few lights to the scene; anyway you see fit.
When you are satisfied, bake the light map to the newly created image with (Alt+Ctrl+B)


Here is a picture of my resulting image, I placed spot, and point lamps in one cornner of the scene..


 If all is well you will be able to toggle between the two coordinates in the mesh panel. The 'Base' layer should show
the regular textures and the Lightmap layer should show the new image.



 Now we need to apply the GE materials to the mesh. We will assign both textures using multi-texturing, then use
the mapping panel to assign each coordinate to the texture. Start by selecting the main mesh and add a new material to it
in the 'Shading' buttons (F5).  Add two texture units to the mesh. The first texture will be a place holder (using 'TexFace').
The second unit will be the newly created image. Set the first unit's Tex to None, and the seconds Tex to image..


Go back to the material panel and activate 'TexFace' and 'Shadless'.


Select the first texture unit and go to the 'Map Input' panel. Toggle the UV button and in the UV text field enter 'Base'(first coordinates)
Do the same for the second image, except add Lightmap in the UV text field.


Go to the 'Map To' panel on the light-map texture and set the blend mode to 'Multiply'.


Press (P) and if all is well, you should see something like this


 


That does it for this example. Light mapping this way should be a breeze now!

snailrose...