Normal map

From TrainzOnline
Revision as of 12:47, 5 September 2011 by Retro00064 (Talk | contribs)

Jump to: navigation, search

The normal map is an additional texture file used simulaneously with the diffuse map to allow per-pixel lighting control. An overview of the normal mapping technique can be found on wikipedia [1].

The color channels (red, green, blue) of the normal map determine the X, Y, and Z value for the pixel normal in tangent space. This information is not considered human-editable, and you should not attempt to manipulate these channels directly. Specifically, do not adjust the dimensions or contrast of an existing normal map. If you need to adjust the size of a normal map, you will need to rebuild the normal map using the original tools. If you need to adjust the bump height in a normal map, you will need to adjust the source geometry and rebuild the normal map using the original tools.

Editing the normal map in photoshop or similar will cause undefined behavior in-game. Additionally, any form of lossy compression (such as .JPG format) will destroy a significant amount of the information contained in a normal map. Do not use lossy formats for storing normal maps even as an intermediate step.

The alpha channel of the normal map is typically used to provide per-pixel control of the specular highlight. White gives a strong specular, suitable for metals and water. Black gives no specular, more suitable for dark earth. Grays are a mid-strength specular. It is safe to edit the alpha channel in a tool such as photoshop, provided that the color channels are not modified in any way.

If no alpha channel is specified, the normal map will default to a full white alpha channel. Since a white alpha channel indicates a strong specular, which will look strongly metallic or plastic on most textures, it is not usually suitable to provide a normal map with no alpha channel. For this reason, it is recommended that the .TGA file format is used for alpha channels.

Contents

How a Normal Map works

Normal maps work by modifying the normal of the pixel. Typically a normal will stick straight up from the surface; a normal map will rotate that normal on either the Y or X axis.

In the following example we look strictly at the red channel; which controls the X axis of the normal. The arrows represent the normals. In example A there would be no normal map applied so all the normals would point straight away from the surface. In example B a normal map would be applied, modifying the normals in the appropriate areas.

Normalhow01.jpg

There are a couple important things to note about this example. Let’s take a look at the red channel of the above example. On a given axis a normal can be rotated 90 degrees in either direction. The grayscale values in the normal map represent which way the normal is rotated. In our example a value of 0 would rotate the normal -90 degrees, for a value of 128 the normal would be rotated 0 degrees, and for a value of 255, the normal would be rotated +90 degrees. The green channel works in the same way.

Normalhow02.jpg

Examples

A typical normal map will look similar to the following image.

Note that this image is for illustration purposes only - jpg format is not appropriate for normal maps.

Normal map illustration

Displaying Normal maps in 3D Studio Max

Displaying normal maps in 3D Studio Max

The appropriate way to display a normal map in 3D Studio Max is to use a “Normal Bump” map in the bump slot of the material. If you load a map directly into this slot it will display/render, but is viewing the map as a bump map and will not display correctly.

Displaymax01.jpg

To display Trainz normal maps from within max we need to flip the Green channel to display the map correctly. This can be done within the material editor without having to actually modify the map.

In the properties for the Normal Bump under Channel Direction you need to check “Flip Green(Y)”. Lastly, load your normal map into the “Normal:” Slot.

Displaymax02.jpg

There’s one last step to displaying your normal maps within Max. There is a different way of previewing the normal map depending on which version of max you are using.

3D Studio Max 9 and below:

In the material editor for the material you want to display under the DirectX Manager rollout make sure to check “DX Display of Standard Material” In the upper right hand of the material editor there is a blue checkered box which will turn pink, indicating that you are using DX display of the material. Click that button to show the maps in the viewport.

Displaymax03.jpg

3D Studio Max 2008 and Above:

Click and hold on the blue and white checked box in the material editor. A popup will open with two options, a blue and white checked box and a pink and white checked box. Select the pink and white checked box to display the material as a DirectX shader in the viewport.

Displaymax04.jpg


Getting Started with Normal Mapping

Refer to this page for notes on setting up an asset to illustrate these techniques.


Baking Normal Maps Using Max

Baking Normal Maps in 3D Studio Max

Note that normal maps produced by Max typically have a reversed green (Y) channel. At the current time, this must be fixed after export by manually opening the resultant normal map in photoshop, selecting only the Green channel, and using the Invert (ctrl-I) tool. Failure to correct the green channel results in incorrect lighting effects within the game environment, destroying the effectiveness of the normal map.

Personal tools