Sub topic 2
What a tangent-space normal map stores
This chapter assumes you know basic Blender navigation, UV unwrapping with seams, and what a shading normal is. It explains what the pixels of a tangent-space normal map mean, so that the bake settings in later chapters make sense and bake artifacts become easier to read.
A normal map stores directions, not colors
A shading normal is a unit vector that tells the renderer which way a surface faces at a point. Lighting depends on the angle between that vector and the light. A low-poly face has one flat normal, or a smoothly interpolated one, so it can't show small dents or ridges.
A normal map is an image that supplies a replacement normal for every texel. Each pixel stores three numbers, the X, Y and Z components of a vector, in the red, green and blue channels. The renderer reads the pixel, decodes the vector, and uses it in the lighting calculation. The geometry is unchanged. Silhouettes stay low-poly, but the shading looks like the high-poly surface.
Each component of a unit vector lies between -1 and 1, but an image channel holds values from 0 to 1 (0 to 255 in 8 bits). The mapping is:
- Encode:
color = vector * 0.5 + 0.5 - Decode:
vector = color * 2 - 1
A color value of 0.5 therefore means "zero in this axis".
What "tangent space" means
The vector in a pixel isn't in world or object coordinates. It is expressed in a small coordinate frame attached to the surface at that point, called tangent space. The frame has three axes:
- Tangent (T): the direction of increasing U in the UV map. This is the X axis, stored in red.
- Bitangent (B): the direction of increasing V in the UV map. This is the Y axis, stored in green.
- Normal (N): the low-poly surface's own normal. This is the Z axis, stored in blue.
Because the vector is relative to the surface, the stored direction means "tilt this far from the base normal". That's why a flat area of the map holds one constant value, whichever way the face points in the world.
| Tilt relative to the surface | Red (X) | Green (Y) | Blue (Z) |
|---|---|---|---|
| None, matches the base normal | 0.5 | 0.5 | 1.0 |
| Toward +U (right in the UV editor) | above 0.5 | 0.5 | below 1.0 |
| Toward -U | below 0.5 | 0.5 | below 1.0 |
| Toward +V (up in the UV editor) | 0.5 | above 0.5 | below 1.0 |
| Toward -V | 0.5 | below 0.5 | below 1.0 |
The no-tilt row, about (128, 128, 255) in 8 bits, is the familiar lavender-blue of a normal map. Blue stays high everywhere because a normal must point out of the surface, so its Z component is positive. A map with large areas of red, yellow or green usually means something is wrong, such as the wrong color space or a broken bake.
Where the tangent frame comes from
The tangent frame is computed from the low-poly mesh, not stored in the image. For each vertex, Blender derives T and B from how the UV map is laid out over the faces, using the MikkTSpace algorithm. This is the standard that most game engines and bakers, including Substance Painter, follow.
Two consequences follow:
- The map is only correct for the UV layout and mesh it was baked on. Editing the UVs or changing the mesh's smooth/flat shading after the bake changes the frame, and the details look skewed.
- The renderer and the baker must compute the frame the same way. If the target engine uses a different tangent basis, you get shading errors that look like seams along UV borders. Later chapters cover this under troubleshooting.
The Normal Map node in Blender takes its tangent frame from a UV map. Its UV Map field can name a specific map. If it is left empty, Blender uses the active render UV map.
Why a baked map works for only one mesh
During a bake, Blender fires a ray from each texel of the low-poly surface toward the high-poly surface. It reads the high-poly normal where the ray hits, converts that normal into the low-poly texel's tangent frame, and writes the result as a color. The map is a record of how the high-poly surface differs in orientation from the low-poly one at each texel.
Where the two surfaces agree, the stored vector is the base normal and the pixel is (0.5, 0.5, 1.0). Where the high-poly surface tilts, the pixel shifts toward red, green or both. A bevel running along U darkens or brightens red on its two sides. A groove running along V does the same in green.
Decoding a pixel by hand
The following script runs in plain Python 3, with no Blender needed. It encodes a normal tilted toward +U, then decodes it again, so you can check the formulas from above.
import math
def encode(n):
"""Unit vector (x, y, z) -> 8-bit RGB."""
return tuple(round((c * 0.5 + 0.5) * 255) for c in n)
def decode(rgb):
"""8-bit RGB -> unit vector (x, y, z)."""
v = [(c / 255) * 2 - 1 for c in rgb]
length = math.sqrt(sum(c * c for c in v))
return tuple(c / length for c in v)
flat = (0.0, 0.0, 1.0)
tilted = (0.3, 0.0, math.sqrt(1 - 0.3 ** 2))
print("flat ->", encode(flat))
print("tilted ->", encode(tilted))
print("decoded ->", tuple(round(c, 3) for c in decode(encode(tilted))))The flat normal encodes to (128, 128, 255). The tilted normal encodes to about (166, 128, 249): red rises because of the +U tilt, green stays at its midpoint, and blue drops slightly. Decoding gives back roughly (0.30, 0.00, 0.95). The decoded vector is not exactly the original because 8-bit storage rounds each channel, which is why the decode step renormalizes the length.
Color space and the Y convention
Two properties of the image decide whether the decoded vectors are right.
- Color space. The numbers are data, not colors. The image must be set to Non-Color so Blender doesn't apply the sRGB curve before decoding. If the image is treated as sRGB, the mid-values shift and flat areas no longer decode to (0, 0, 1). The next chapters cover setting this on the bake target.
- Green channel direction. Blender's Normal Map node expects the OpenGL convention, where green increases toward +V. Some engines, such as Unreal Engine by default, expect DirectX, where green points toward -V. A map with the wrong convention shows dents as bumps along one axis. The OpenGL versus DirectX chapter handles this.
What the map does not store
A normal map changes shading only. It does not store height, so it can't move silhouettes, cast self-shadows, or add parallax. It also doesn't store occlusion, which is why a separate ambient occlusion map, covered in the next chapter, is baked alongside it. Very large height differences between the high and low mesh can't be captured faithfully either, because the map only records orientation. That limit is why the later chapters on cage and max ray distance matter.
Exercise
A baked normal map shows up in a material as mostly yellow-green instead of lavender-blue, and the surface lights incorrectly. The Image Texture node is connected straight to the Principled BSDF Normal input. Name two likely causes and what each pixel value should be for a flat area.
Show answer
A flat area should store about (0.5, 0.5, 1.0), or (128, 128, 255) in 8 bits. First cause: the image is set to sRGB instead of Non-Color, which shifts the stored values. Second cause: the image is connected directly to the BSDF Normal input, with no Normal Map node. Without that node, the colors are never decoded with c * 2 - 1 and converted from tangent space, so the shader treats the raw colors as a vector. Fix both by setting the image to Non-Color and routing it through a Normal Map node set to Tangent.