Optimize iPhone Games by Baking Texture Light Maps in Maya 2010

February 8 2010, 12:07pm

Episode 23

Watch Video Play NowHD Streaming Video iPhone VideoYouTube

Coming up on today’s epsiode: Optimize your iPhone games performance by Baking Texture Light Maps using Maya 2010. Today will be using Maya Baked Lightmaps to speed up game performance. The trick is getting fewer texture draw calls by baking your shadows into the texture.

First will start by creating a texture sheet. A texture sheet holds all of the textures that are used to make up characters and other models in the game. So by combining textures into one file, you can get a faster performance by using less cycles for each texture. For this tutorial we’ll be combining all the textures that make up this cell room. For this example we’ll use a size of 1024×786. After all the textures are combined, make sure even plain color shaders are also in the Texture sheet. Link all your texture UVs to the sheet. Now we’ll Adjust the lighting in the scene, check the render to see the were the shadow are casting. Now Select all polygons and in the polygons menu under Mesh < Combine Create a automatic poly projection for all the ploys in the polygons menu under Create < UVs < Automatic Mapping Option Box Using the default settings, under UV Set make sure the UV set name is: lightmap hit apply Go into your UV Texture Editor and select the new UV set under: UV Sets < and then the lightmap uv set You can switch to original uv coordinates if you need to here While still having the ploys selected go to the Render Menu Under: Lighting/Shading < Batch Bake (metal ray) Option Box The under Settings options check Back Shadows, the rest should be ok under Texture Bake Set Override Color mode < only light Under prefix: use the name of the room to easily spot them out For the iPhone will use the X and Y resolution of 256×256. Didn’t get any higher quality with a higher number so, We can leave the Number of samples to 4. Fill Texture seams at: 3.0 Make sure Override mesh UV set assignments is checked with the UV set name to: lightmap Click on convert to bake the map, This shouldn’t take too long Ok, now if we look in our project file under renderData/mentalray/lightmap/. You can see the room0_lightmap.tif Maya created. Open it up to check it out, Pretty good Ok we now have both of the UV sets in the scene and the baked lightmap. Now we have to go to each object in the visible scene and create a Layered Texture shader for each. Then we have to attach the textures and UVs to the baked shadow’s UV set. We can do this by right clicking on an object Assign new Texture < layeredTexture Object goes green, The first layer will hold the lightmap file. Add another file node and link it to the lightmap. For the Blend mode use: multiply. now we can go to the second layer and select a file node. We’ll link that to the color texture sheet. The blend mode should be at: none. Now we can link the UV sets together for this object and it’s texture. To set up the UV relationship we’ll go Under Window < Relationship Editors < UV Linking < UV-centric Scroll down to find the texture for this object. By default both are linked to the color texture. Select the lightmap and link it to the lightmap UVs Map1 should deselect the light map UVs from the color UVs. Now let’s test link by going into the UV Texture Editor and switching between the sets. Now lets do a test render of the scene with the light off. If linked properly the shadows from any objects should still be in the render! Now we just have to attach each object and texture to the lighmap UVs, thats how to bake light maps in maya. Hope this helps in optimizing your next iPhone/iPad game.

blog comments powered by Disqus