Normal Mapping

Normal Mapping

Idea #

Store surface normal vectors in a RGB texture. Normals can be stored in two coodinate spaces.

  1. Object space:
    • Normal can be applied as it is read from the texture.
    • Not reusable between objects: They were baked for one specific geometry, so it only works for one mesh, and also no character animation is possible.
  2. Tangent space:
    • Reusable maps

Using tangent space normals #

To convert the tangent-space normals to object-space normals we need the Tangent Fram Matrix. The TSM is then just a transformation matrix from tangent space to object space. It looks like this:

normal_mapping_6184a0058dd83abf15e86218ffd3fea69185765c.svg

With:

  • normal_mapping_4a7416ffb0b58d425fe49b67638a2ff2895d5c91.svg Tangent vector
  • normal_mapping_d098b8f44b17c6dbe43d69fae0898aaf3440be5c.svg Binormal vector
  • normal_mapping_088ec82d3de63cb29f7118a6af61c24ba969bee6.svg Normal vector
  • normal_mapping_088ec82d3de63cb29f7118a6af61c24ba969bee6.svg, normal_mapping_d098b8f44b17c6dbe43d69fae0898aaf3440be5c.svg and normal_mapping_4a7416ffb0b58d425fe49b67638a2ff2895d5c91.svg are unit length and orthogonal onto each other
  • Tangent vector points in the normal_mapping_7e5f9a81d231115ca9a2128e0ccbf8910e179ebb.svg direction

  • Binormal points in the normal_mapping_6b3469b464d22b645afaa9df43895f5789481f99.svg direction

Getting the Tangent and Binormal #

Similar to the vertex normal, the tangent and bitangent are stored as vertex attributes and then get interpolated for the fragment shader. Like the vertex normal, the the tangent and bitangent also need to be renormalized to have unit length, since the interpolation messes with the length.

How normal maps are created #

  1. Have a high resolution mesh
  2. Create a lower resolution mesh from it
  3. Calculate the “delta” and strore as a normal map

Alternatives #

Calendar October 22, 2023