Site hosted by Angelfire.com: Build your free website today!
Star



Blender3D

DcModding

Upload Your Movies

Get Paint.NET!

deviantart page

Banner

Making LightMaps



lf0_landscape_field.dds

lf0_landscape_field.dds



lm_field_0.dds

lm_field_0.dds



1. Lightmaps are images the game uses to add lighting and shadows, to mark the time of day your scene is being filmed. Also a lightmap has a secondary function. The lightmap, being selectable, can produce different timing effects. The way it is used is more like a backdrop. Take the haunted set for instance, it has a sky light. And the sky above it has an image, a lightmap. Yet, instead of providing the amount of shade the sky is getting, it produces an image, if its day and cloudy or night and starry. Selectable with the lighting slider in environment settings.



2. Lightmaps can be made in Blender. Every object is attached to a lightmap. If you open a lightmap image in Photoshop, you'll see a lot of items on a set in the image. All of the objects share this image. So each object on a set uses two images total. One, the texture image, like grass image for the ground or sand image for the ground, bricks for a wall, or wallpaper. Marble for a kitchen counter. And the other image adds a shade to everything on the set, the set it self, actors props. The only items this second lightmap does not effect is objects whos material is set to self lit.



3. There are instances in which an object does not use a lightmap. Like the outlining ground objects around a set. Reason is these outlining stuff will never be in a camera angle or scene. This sucks because with the option of free camera angle, some of these objects will end up in a scene anyways, but will not change to lighting. So it is sometimes better to make your own set out of a Movies Game set, but deleting objects the set includes which will never be used in a scene. Like the plywood on the backside of a backdrop object. It will never be seen in a camera, so why have it? It looks better on the studio lot with the plywood. But if you are making your own set, you might not add this detail because the less items a set has, the less memory your hard drive stores, and also the faster your movie will get exported to your hard drive. In Blender, when I render a movie, It will take forever, at least on my computer. Because each frame has to render each object in it's proper order. I don't like waiting 45 seconds for one frame, and there may be 1500 frames to render for that scene. So I take a snap shot of the set in Blender. And make a 2d sprite for each object, or make it one backdrop. The ground and buildings all become just 2 faces of data. Then the scene renders much faster, only 12 seconds a frame. Still long but much shorter.



The same is in the Movies Game. The more Megabytes a set has, the longer it will take to render a movie. So keep that in mind. In short, if an item is not to be seen, why include in the set at all.



4. Lightmaps can also achieve a desired effect. I remade a Wild West lightmap once, the night time lightmap. I made the windows glow yellow with lantern light, and then had a brighter glow on the ground that was closer to the windows. When people walked by a window, there appearance became brighter. Even though it was night, some items and objects will have a different setting. The are two ways to accomplish this change. And easy way and a harder way. The easy way, the one I used, was to have the set imported and then the nighttime lightmap loaded. Then in buttons window select the LightMap uv map. In the UVWindow you'll now see the lightmap in it. Then I went to all the windows, and in edit mode selected the verts of the windows. Because a set object may share more then just the window, I did not select all verts in edit mode, just the window portion. Then in the uvwindow, seeing the map lit up for only the windows, I took a snapshot of the lightmap image. Next, loaded that snap shot in PaintDotNet and copied the parts that were lit up. Having only the selection of the windows and not the actual image, I then loaded the actual nighttime lightmap in PaintDotNet, pasted the selection over it, (just the windows are selected. If you have the image part pasted, select full transparency and the image part of selection disappears. If you are in a different layer, go back to the layer of the original lightmap) Then I added a color filter, yellow. And made it brighter. Then the windows glowed yellow. Then export the pic as another lightmap option.



(pic tut lightmap)

The next image. To make the ground and surrounding brighter due to window casting more light then the moon does, I selected only the area near the windows and increased their brightness, and exported as next light option.



The harder way would be to put a lamp just in front of the windows, making sure you set the lamp's degree of brightness to match a window casting light outwards, and then bake over the lightmap. You will need a larger lamp over the rest of the scene to mimic the moon. Maybe set the type of light that lamp cast to be blueish in color. Once all the lamps are in place you then bake the lightmap image.



(pic lamps on walls)

Here I put lamps near the set's actual wall lamp objects, then baked the effect into the lightmap.



If you do not know how much light a lamp should have, you can do more then one bake. At first bake, go into texture mode to see the result. In buttons window the light map will show instead of the texture if you press the right button. Same with which image the bake will apply to. It uses which uvmap is selected for viewing editing and baking. You will bake over the lightmap image instead of the texture, if you have that button pressed in buttons window. Blender will only show one uvmapped image at a time, unlike the movies game. In Blender, to render a scene, instead of using lightmaps, just use lamps. It is not impossible to produce lighting effects with more objects, though the work required makes this not a viable option. But in games, when a canon fires, there is a brief moment of flash, extra light. You could have a lamp pop into existence at that moment, and then disappear. Or you could have a larger object pop into place over the person or area near the canon, with alpha and brighter separate texture. Or using a copy of the texture only brighter. Or just have all objects replaced for a moment by identical ones using brighter textures. All of which, though possible, unnecessary due to Blender's lamps. Here, for now, I'll discuss only Movies Game lightmaps. I will later expand on lighting for Blender game engine, and for filming scenes.



5. Assuming your set has been saved as a .blend file, you may want to save it as a new .blend file for making lightmaps. Like, "set-my_new_set_lightmaps.blend". That way, if you have problems with making the lightmaps, you have the original file to append objects from. Blender is dicey when it comes to material references. Blender seems to remember things we told it to forget, and even when Blender does forget it, it gets post traumatic distress disorders and still remembers things. It's always good to have several blend files of your project, as we may venture into other directions and may desire to return.



To make a lightmap for a custom set. First have all the objects in place and ready. They all have there own textures for use. Now you must create a new uvmap for each object and title that map: "LightMap" using capitals L and M. Consider the objects with larger faces. A roof. A wall. The entire ground. These objects will need to cover more of the uvmap then the smaller objects. And keep their maps together on the image. When you project a uvmap of an object scale it to a small section of the texture image (lightmap image). Make sure you can fit all object's uv lightmap on one image. You can add tricks to. Like see a flag pole's shadow over the ground at different times of the day.



Since all the objects share the same lightmap image, we must position the uvmap carefully. In uvwindow create a new image. 1024x1024, or 2048x2048. Next, in buttons window, make a new uvmap. Then turn on the buttons for that uvmap. Go to each object one at a time and make this new uvmap and title this new uvmap "LightMap". After creating a buttons reference to the new uvmap, we must project this new map over the same newly create image in the uvwindow. Because once we have made a new lightmap it will be a copy of the first uvmap (projected on the object's diffuse texture image.) So we must re-project the new uvmap over the new image. Do this in exactly the way we made the original uvmap projection in edit mode. Some objects can share the same space over an image in the uvwindow, because they will always have the same lighting effect, like under a table and under a chair. But the walls will have different effects, like outdoors, when a shadow falls on one wall, it will not fall on another wall, so each of the walls may need to be separate uvmaps over the image. Baking will not like uvmap's overlapping. In a paint program you can fix that shared space (if you go that rout). From here on we will assume you are just going to have each object's faces have their own spot on the new Uvmap.



Once you have a new uvmap created and projected over the new image, move the uvmap to its own space over the image. Keep in mind that each object needs it's own space so consider how much space each object takes up or actually needs. A barrel needs only so much and a bucket needs only so much, while the ground needs maybe 20% or more of the image. If the image is large enough, each object can have a good amount of space. After placing the uvmap where you want, we need a way to know that part of the image is in use. So in the buttons menu, and the baking buttons (f10), deselect the "clear" button. This way each item we bake remains each time we bake. Then click on the "normals" button. We can bake normals with no lamps. And we did not add any lamps yet since for now we don't need any. So select normals button. Then click the "BAKE" button. In the uvmap window we will see the colors of the normals or faces baked on the image. This way we know where that object's placement on the map is. And we know that part of the image is in use by another object. Now in UV Window click on the save button and save it as a .jpeg image. Title it something like "new set uvmap area". This image will serve as a true map rather then an actual lightmap. It will be a map of all the objects you will bake later. It's purpose is so we know where to place the next Object's uvmap (LightMap.)



Now save over the blend file. Each time we save the image and then save the blend file. The image gets updated and the blend file gets updated. Sometimes you may want to save this image map (though it won't be used as a lightmp) because every now and then Blender will reset and the image will be restored and no normals will be baked to it anymore. So if you save this map image from time to time you can avoid missing where the last few object's normals were baked to. If Blender reset and the image becomes blank again, we can press the reload button. Now if we return to the blend file project at a later time, the image will have its updated normal baking on it. Always update the image, and we will always have our map. Other wise, we would have to go back to the objects we gave new lightmap uvs to and re-bake the image.



After saving over the old image and old blend file, you can turn off the object's visibility in 3d mode, or in the outliner window, turnoff the eyeball button, and in this way we know that object has had it's lightmap baked. Next, select the next object on the list. If you like, you can select all big objects on the set, all the object's with large flat faces and bake them first so that we know what larger portions of the image will be used. Then turn their visibility off to signal they are done. After each item we select, one at a time, we bake their uvmap, save over the image and save over the blend file. If you change your mind about an object's uvmap placement, load the image in Photoshop or Gimp or PainDotNet, and draw over the area will wish to change, then reload the image back in Blender and then move the map to somewhere else. You do not have to re-import the image, thus confusing Blender image reference. All you need do is press the reload button. If the map you just made on the current object is undesired, then before saving it just hit the reload button and it will vanish, then adjust the map as desired. All providing you never change the location of the image we are baking from it's folder location.



Once we have all of the objects projected over their own space on the single image we no longer have to use the image as a reference. Next we want to make the actual lightmap image. Right here we want to make another .blend file for this purpose. The one we are on currently will be the actual set we export. To finish up this .blend file we would go into the material buttons window and create a new reference for the lightmaps (f6). Where you see several bars stacked over each other, select the one below the diffuse and then press add new. There should be 4 names in the row or stack. And the order is "Diffuse", "Reflection", "Lightmap" and "Specular." If the object is a window you can add a reflection image to it. The game already has sevral to choose from. The third block or name in the stack called "Lightmap" is where we will add the new image to. Next to it is a button that once pressed gives us a drop down menu. Select image. Then way over at the right side we would load the image we will finally use as a lightmap. Since I make a copy in the folder location of the map for later reference, I will just select the new image we created earlier (for the reference map). That can be changed later if need be but since all the objects uvmaps are projected over it, to save time I will just use it for now. (It can be replaced in MED. The actual image we will bake in a second. In MED we can replace the reference one to that of the one we are about to bake. And even if that reference was a .jpg)



6. Now save the project as a new .blend file. Something like "My new set_making the lightmap image" or whatever, just a different .blend file. This .blend file we will only use to make the new lightmap image. Because of that, we will make a radical change to all the objects on the set. We will merge them all into one object. This is the easiest way. Doing so allows us to make the entire image at once. Other wise, if we used the other .blend file where all objects are separate, we would have to bake each actual map one object at a time. Time consuming when a different .blend file can do it all at once. And since we may want to make lots of adjustments to the lamps and lighting and locations of the lamps, we would want to see the results in one bake. So in this new .blend file, select all objects and join them all. All the materials have just be joined together as well, so I would go on to delete all the materials of this giant set object. In edit mode we can see the set's entire uvmap projected over the image. If you see one part's map over another, then you didn't keep track of each object's map placement. Go back to the other .blend file and redo that object's map. But assuming everything worked out well here, now we must make the new map. Add one new material. To clean things up, save the .blend file and then open it again. Save it again, then open it again. Do this three times, and all the deleted materials will be forgotten by Blender. And only one new material will still be there. The color of the material can remain it's default grey. Later we will change it's color for night time images.



7. All objects being joined, all materials deleted and one new material created, now we set up the lamps. You may wish to experiment with different lamps for the desired lighting effect. I use a giant spot above the set. We can scale the lamps to include the whole set. But you may just want to scale down the set, since it is now one object, to fit in the lamp. The Movies Game has 4 maps it uses solely for the studio lot. Since a set can be rotated to face four different directions, the set's shadow has four different angles from the game's sun. Does the game have a sun? It's all the images that mimic the sun. So to create these four first maps, place a spot lamp above the set, and move it to the side. The game's time of day is at 10 or 11 am so it will be a little off to the side rather then high noon. Now, click on the "clear" button the the buttons window. We want a new image. Now press bake. The image should take some seconds to be made. If it is rather large image or large set, several more seconds. Might have to wait awhile depending on the size. Once the image is finished we can see the end result in the view properties menu. Click on the texture view. The set will show a grey shadowed image over it. If you like it, save it as "lightmap1.jpg" or what ever. For the next image select your set and rotate it 90 degrees. Then press the bake button again. Then save this image "lightmap2.jpg". Do this four times for the first four images. The game can use up to nine lightmaps. I wish it could be endless. It would be great if somebody found an .ini file that decides that amount. But I think it may just be in the Game's .exe file. Oh well. Nine it is. the first four are only for the studio lot. It's not really necessary for filming movies. If you want you can use the first image four times. But lightmap number 5 is where we begin the fun.



Now, consider the first lightmap's time of day. High-noon? If you want the first map to be high noon, then place a spot lamp (or move the one you already have) directly over the set. The white lines of the lamp show if the set is within the lamp's area. If it isn't then scale the lamp until it is. Then press the bake button. You can title the map lightmap5 or even lightmap high noon. You can make as many images as you want and choose from them later what you actually want. Now, also to consider. The conditions of light on you set, depending on what kind of set it is, may vary. If you made a snowy set of Antarctica, then the sun would be low on the horizon at high noon. You could angle the lamp low but facing the set, and the shadows will end up being long shadows. If it is a cave set, here is what I would do. First place a single regular Blender lamp inside the cave. This kind of lamp doesn't mimic the way light is cast, it only tells Blender there is light here. Handy for making general illumination, but not so good for area brightness or shadows. So make another spot lamp and place it over the cave's entrance. High above is fine. This way, inside the cave, once we bake, the inside of the cave will be visible but the floor and walls near the entrance will have a sun brightness laying on it. The closer you get to the entrance, the brighter it becomes.



8. Night time requires a different feel. A different mood. Make the lamps have a mellow cast. And maybe change the color of the lamp's light to blue. Or change the set's material color to blue. If you have windows with lights inside, add a new material the verts of the windows and give that new material a yellow color. Then when we bake the difference in light will be on the objects. If it is a city street, there will be lamppost here and there. You can add a spot lamp to the area of the actual lamp and point it down to the ground. Baking will reveal the light of each lamp post shining on the ground.



Remember, each new lightmap you create, you do not want to save over the old one, save it as a new image each time. You will later open these images in Photoshop to make other adjustment, or if you like them as they are they must be converted to (DDS) format. Blender doesn't save in (.DDS) format, therefor we will do this externally with another program.



9. Once your images have been created we can do away with this .blend file. We can open up are previous .blend file now. Having renamed the images we made and converting them to (.DDS) and having placed them in the data\textures\lightmap folder, we can load the lm_myset1.dds image in Blender and have it reassigned to each object. This is a time consuming task. Why? Because each object must have the uvmap placed over the actual loaded lightmap image. And each material must know that the actual lightmap image is this new one we just loaded. All the objects already know that the .jpeg we created earlier used to be the lightmap. So why not export the set as a (.MSH) file letting it think this is still true? We can then open the mesh file with meshmanip or MED (The Movies Editor) and have the lightmap texture changed to the actual one from the textures\lightmap folder. It's one step in these programs and lots and lots of steps in Blender. Maybe your set only has four or five objects. In that case use Blender. Many sets will have up to a hundred or more objects. Not fun at all. Therefor I use MeshManip or MED to reassign the actual lightmap image we made. Otherwise, go to each uvmap and have it placed over the actual map. Then go to the materials buttons window and have each "LightMap" reference changed to the actual lightmap image we want. Then save the .blend file and open it again three times to tell Blender to forget the old (.jpg) image. Then export your set. The choice is yours as to which step you follow.



Note: MED does have a bug. A custom set made from scratch will not be affected by this bug. But if you had appended the "shape" group and the "shape" objects located in the forth blend layer, Med will scatter these in any (.MSH) file it generates. Proof of this can be found when any set we import that was generated from MED into Blender will open with a python error. And in the outliner you can see all the shape objects out of its shape empty pivot. Yet, if we import the same set from Rysto's all Movies Game meshes, there is no python error and the shapes are all in the shape pivot. So if you reassign the texture or run your set mesh through MED, you may have to import it back into Blender, to have the shapes fixed. What are these shapes? No one knows yet. But this is what happens to them when they are exported from MED. What I do when this happens is just load the (.MSH) back into Blender and select each shape object and then parent them to the shape empty. Running the preflight check after doing that gives all green lights again. That seems to fix them and the shapes being displaced seems to be the only (.MSH) bug I have found using MED. Just keep it in mind if you use MED to reassign the lightmap texture. On the other hand your custom set may not have any shapes at all in it. Then there is no problems anyways.



Update: If a mesh file was save to workspace using med then the shapes get out of the shape empty. But if a set is extracted with mesh extractor, then the shapes remain inside the empty and no python error.



10. The other lightmaps. There are two types of lightmaps each set uses in the game and for the game to use them they must both be present. The other is named "lf1_nameofyourset.dds" and "lf2_nameofyourset.dds" and so on. Not all sets have 9 lightmaps, but you can make as many as nine, and you can add more to sets that have less. Each one the game uses with the other light map, "lm_nameofset_0.dds" and so on. The lf_ version of a lightmap is casting light straight down on the set. There is no controlmesh that decides the actual layout of this lightmap. So you may have to do some trial and error image design for brand new images. You can make a color map and see it's layout over your set. I believe someone was showing images of this at DcModding.com. But this map also decides the degree of luminance everything has, even the actors and props and all else. You do not need Blender to make these images. Yet if you find out the exact placement of the image over your set, then you can reproduce the lighting in Blender and take a snap shot from above and then superimpose this over the image map you have for the set. Detail to items may or may not be necessary. Since this is a light overlay, just the amount of shading is all that is required. If someone walks around a corner at night, and that area is real dark, then make sure in this area that it is darker. Then actors walking into this area also walk into the shadow and themselves become darker.



Naming of the lightmaps is important. Though the game can handle other names if the maps are recognized for a different purpose other then the ones above, such as the skylight for the haunted set. It must have the numbers and must use the lm_ and then followed by a number at the end. Or have lf0_ or lf_1 or lf2_ at the front for that type of light map. Keep the name of the light map the same as your set mesh name. If you set mesh name is set_cave.msh then the light maps will be named lm_cave_0.dds and lm_cave_1.dds (and so on), and the other lightmap will be lf0_cave.dds and lf2_cave.dds (and so on). That's that, and all lightmaps are located in the data\textures\lightmaps folder of the game.



More:



(pic of shack lightmap)

Here I placed a lamp at the set's fireplace area and set the lamp's color to yellow. Then added the new lightmap as an extra one to the shack set. I did the same for the living room sets



(pic living room fireplace1)
(pic living room 2 lightmap)