2016-08-11

Increasingly the 3D industry is adopting the standard of Mikktspace for calculating tangent space for normal mapping and other effects which rely on accurate and consistent calculation of tangent space from one application to another. Blender, xNormal, Unity, Substance Painter and Unreal Engine are just a few I can think of which now use Mikttspace off the top of my head. I'm personally attempting to recode my own projects to adopt this standard too. Trying to anyway.. Because standards are important and any well intentioned coder would want to adhere to them when possible, and I certainly would like to.

But there are very few resources on how Mikktspace works as it is a relatively new thing and what little resources there are, are usually scarce on details and very technical, not very user friendly to understand, or assume the coder has a certain level of knowledge which is a bit above the average newbie just starting out who needs things explained more carefully.

Could anyone here provide either a link to a clear example on how Mikktspace works and how to implement it, with a simple explanation of how the maths and code works in a way which is not limited to just one language, or perhaps even type up a really clear explanation right here?

I'll select the most simple to understand & complete answer as the correct answer. Hopefully many others will find this question through Google.

For the sake of example, lets suppose a programmer has a mesh object, with a index of vertices, each with a position, normal and UV coordinate, and list of triangles which reference that index.

For example:

Vertex: { X Y Z NX NY NZ S T }

VertexIndex: A list of Vertex

Triangle: { V1 V2 V3 }
(in correct winding order for normal direction)

TriangleList: A list of Triangle

In simple terms, how would one go about calculating per vertex a tangent vector (TX TY TZ) and bitangent vector (BX BY BZ) for each vertex in a way which conforms to Mikktspace?

Show more