1. The Normal Map:
In games, the normal map is used to add details to low-poly geometry. Â The information can be extracted from a high-resolution mesh and then applied to the in-game model to improve its aspect. The major advantage of this technique is that it can vastly improve the look of a low-res asset without having a big impact on rendering performance.
Here is how it all works.
As mentioned in the low-res portion of this tutorial, lighting an object in a real-time 3d environment is done using normals, which are a vertex attribute. Â The major disadvantage of this technique is that the shading quality is proportional with the number of polygons.
Building a next gen object is almost synonym with using normal maps. Â Instead of relying of mathematical procedures to determine the way light is reflected off a surface, the "per pixel" lighting method uses a normal map to define the normal's direction in every point of its geometry. Â The major advantage is that the normals can be calculated from a high-res version of the asset. Â Each pixel in the normal map will define the normal of that point in 3d space, as follows: the three colour channels R (red), G (green) and B (blue) will determine the X (red), Y (green) and Z (blue) values of the normal. Â There are two types of normal maps used in games:
A. Object (World) Space Normal Map.
Can be easily identified by the fact that it looks like a rainbow. Each colour channel defines the absolute coordinates of the normal in world space. This type of map is used for static, non-deformable objects and it is usually avoided as it is hard to change in Photoshop after it is generated.
B. Tangent Space Normal Map.
Can be easily recognised by being predominantly blue. Each pixel defines the deviation of the normal from the value calculated with the "per vertex" method, by using a local co-ordinate system (X, Y, Z will instead be U, V, N). This is the most used type of normal maps in games as it is easy to edit in Photoshop and it can be applied to deformable meshes.
A good idea is to save a new scene before starting to prepare the scene for baking. Â This will ensure that all the settings used for baking are saved separately in this new scene and are easy to go back to in case of anything needing a re-bake.
All the meshes should be recombined by following these rules:
- The low-res geometry will be separated in such a way that every object has only one material. Â For example, the door geometry will be separate from the door window, even if in the final scene they will probably be merged together. Â Naming these meshes should be done by using a simple to follow naming convention like this: body_low, glass_low, interior_low.
- As mentioned before, intersections must be avoided by separating objects because they can cause artefacts in the baked textures. Â For example, if the interior has intersections, I will separate it into different objects that will intersect each other but will not contain intersections themselves. Â Naming should be something like interior_low 1, interior_low 2.
- The high-res geometry will be recombined in a similar way to the low-res geometry. Â Each previously created low-res geometry should have a corresponding high-res counterpart, named something like: body_high, glass_high, interior_high, etc.
These naming rules will help speed up baking by making each high-res/low-res pair easier to select. And don't forget to apply Smooth on the high-res meshes before baking!
Texture baking in Maya can be done by using the Transfer Maps utility found under Lighting/Shading > Transfer Maps.
The "target meshes" section is for the low-res meshes and the "source meshes" section is for the high-res versions. The settings in the next image are a good starting point for baking. The settings that usually need tweaking are "Search envelope" and "Max search depth":
For each pair of meshes, a normal map will be generated. Â If there is more than one normal map for one particular material, these baked normal maps can be recombined in Photoshop by using the Overlay blend mode.
The combined textures can be loaded on the bump channel of a Phong material. Â The "Use as" drop-down box in the bump2d node has to be set to "Tangent Space Normals" for the normal map to be correctly displayed when high quality rendering is enabled (Renderer > High Quality Rendering in the viewport menu)
This is how the mesh looks with normal vertex based shading.
This is how the mesh looks with normal maps applied in High Quality Rendering.
1. The Ambient Occlusion Map:
This is a bit easier to explain.Â Basically, the ambient occlusion (AO) map contains the amount of "visibility" stored for each pixel. Â The more occluded that point is in 3d space, in relation to its surroundings, the darker the pixel will be on the AO texture. Â I will not go into detail about how this is calculated; I will stick to showing how it is generated and used. Â Because occlusion is influenced by all the objects in the scene, this map does not require the low and high-res models to be separated to minimise the number of intersections.
Texture generation is similar in steps to the generation of normal maps. Â The next image presents some of the settings used. One thing to mention is that, for the AO baking, the "Max Search Depth" setting is ignored. Â This is replaced by "Occlusion Max Distance", which usually requires a value larger than 50 to give proper results.
The value for "Occlusion rays" is directly proportional to the quality of the final texture and the rendering time. Â For a test render, a value of 16 will be enough, but to obtain a smooth texture I use a much higher value, usually a power of 2 (64, 128). Â Be careful: high values in this field will cause the rendering time to increase dramatically!
The resulting image is a greyscale that can be put on top of the painted colour texture using Multiply.Â This will add depth to the diffuse texture, making it look more realistic.
Usually, ambient occlusion maps take more time to bake than normal maps, so some patience is required. Â Do a lot of test renders with low "Occlusion Rays" values to make sure all the details show up on the map before doing a full resolution render, which can take more than half an hour to complete!
Now that these textures have been baked, you are ready to move on to the next and final chapter of this tutorial, texturing.
< previous page continued on next page >