Baking tangent space normal maps

Started by
1 comment, last by B_old 11 years, 7 months ago
I have a mesh with normals. During shading the tangent/bitangent is calculated from the normal and UVs on the fly, for usage of an existing normal map. The mesh can use any number of different normal maps and I want to generate a single tangent space normal map that covers the entire mesh.
In theory this is working. I transform the final world space normal that is usually used for shading (normal mapping + some optional normal trickery) into the calulated tangent space.
The problem is, that the tangent/bitangents sometimes "jump" between neighboring triangles although the mesh normals are smooth. This looks bad when the baked normal map is used later.
To illustrate my problem I have attached images that show the world space normal, the tangent, and the tangent space normal. While the world space normals are smooth, the tangent space normals are not. Especially on the left side of that image.

World space normals
[attachment=11098:WorldspaceNormal.png]

Tangents
[attachment=11096:Tangent.png]

Tangent space normals
[attachment=11097:TangentspaceNormal.png]

Any ideas how I could generate a smooth normal map?
Advertisement

The problem is, that the tangent/bitangents sometimes "jump" between neighboring triangles although the mesh normals are smooth.

The problem is, that normal/tangent/bitangents costruct a space which depends on the uv coords of the texture. If you always want to keep the classic normal (which points away from the surface), then your tangent spaces will flip the handness sometimes (handness= right hand or left hand coordination system ). This is very annoying and you need either to flip the normal to correct the handness or you need to store the handness and correct it on-the-fly.

Best example are mirrored textures, the tangent space flips at the mirror-edge, but the vertices can either save one or the other tangent space. In this case you need to split the vertex to get it right. It is similar to uv-splits.
I think I figured it out. The tangentspace calculation was a bit whacky. Changing that seems to solve the problem.

This topic is closed to new replies.

Advertisement