3
$\begingroup$

In tangent space there is the normal of the geometry which represents the Z axis in tangent space, and the tangent and bitangent.

My first question is does the tangent represent the X or Y axis in tangent space? (Bitangent would then just be the other axis)

My second question is about how the tangent and bitangent is determined. The Z axis is just the geometry normal, but how are the tangent and bitangent determined, as there are an infinite amount of possible tangents to a given normal. Or formulated a little differently: If I were to put the X and Y axis of tangent space into the global coordinate system, how would they be oriented tangent to the normal?

$\endgroup$

2 Answers 2

5
$\begingroup$

For normal mapping, (tangent, bitangent, normal) is (X, Y, Z).

The tangent and bitangent are computed from a UV map (that's why you need one to get tangents). The idea is they're picked so they point along the U and V axes in the map. Or put differently, if you draw lines on the texture in the U and V directions, the tangent and bitangent go in the direction of the lines.

U and V direction in UV space correspond to tangent and bitangent direction

That's the basic theory anyway, the precise computation is very involved with many problems involving order and topology to consider. I believe Blender uses the standard MikkTSpace algorithm but I couldn't tell you any details.

$\endgroup$
3
  • $\begingroup$ The tangent and bitangent are computed from a UV map (that's why you need one to get tangents) But what if my mesh doesn't have any UV maps? There have been cases where I used a procedural noise as input for the normal map node and it worked perfectly fine, although the mesh didn't have any UV maps available. $\endgroup$ May 15 at 17:04
  • $\begingroup$ If I have multiple Textures with UV maps will, which I can access through the UV node, will Blender be smart enough to take the correct UV map for each texture each time or does it always only take the active UV map? $\endgroup$ May 15 at 17:05
  • 2
    $\begingroup$ I believe it uses the tangents from the UV map you set on the Normal Map node. I don't know what it does if there isn't a UV map. In Python, it won't let you calc tangents if there isn't one. $\endgroup$
    – scurest
    May 15 at 17:14
2
$\begingroup$

A tangent is simply a unit vector perpendicular to the normal, of which there are infinitely many (consider any rotation of an existing tangent around the normal vector is also a tangent). For most uses of tangents and tangent spaces you will want a consistent direction to to the tangent.

For tangent normal mapping this direction is defined using UV coordinates as defined in scurest's answer, however there are other uses of tangents where UV coordinates may not be available, so another convention may be used.

For example Blender's Corrective Smooth modifier preserves detail by recording vertex offsets in tangent space for the base, smoothed mesh and then reprojecting them in the tangent space of the deformed, smoothed mesh. For this to work the spaces in each case need to be consistent. In order to make this consistent a direction for the tangent is defined using the vertex order triangles that the vertex is a member of (I can't remember the exact details of this, but its in the code somewhere).

As far as the mesh tangents provided in the material node editor are calculated, I'm not sure, but I suspect without UVs they would use a similar trick to the corrective smooth modifier.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.