Function vertex::computeTangents

Function vertex::computeTangents#

Function Documentation#

void vertex::computeTangents(std::span<Vertex> vertices, std::span<const unsigned int> indices, std::size_t firstIndex = 0)#

Per-vertex tangent frame (xyz = tangent, w = handedness) from triangle UV gradients (Lengyel’s method), for every triangle in indices[firstIndex..]. Requires each touched vertex’s normal to already be final - run this after computeFlatNormals/fillMissingFlatNormals, never before. Degenerate UVs fall back to an arbitrary axis orthogonal to the normal instead of producing a NaN.