tangents
The tangents of the Mesh.
Read time 1 minuteLast updated 9 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public Vector4[] tangents { get; set; }
Remarks
Tangents are mostly used in bump-mapped Shaders. A tangent is a unit-length vector that follows Mesh surface along horizontal (U) texture direction. Tangents in Unity are represented as Vector4, with x,y,z components defining the vector, and used to flip the binormal if needed.
wUnity calculates the other surface vector (binormal) by taking a cross product between the normal and the tangent, and multiplying the result by tangent.w. Therefore, should always be 1 or -1.
wYou should calculate tangents yourself if you plan to use bump-mapped shaders on the Mesh. Assign tangents after assigning Mesh.normals or using Mesh.RecalculateNormals.
Note: To make changes to the Mesh.tangents, it is important to copy the tangents from the Mesh. Once the Mesh.tangents have been copied and changed, the Mesh.tangents can be reassigned back to the Mesh.