Skip to content

Commit

Permalink
Merge pull request #531 from KhronosGroup/fix/tangent_space
Browse files Browse the repository at this point in the history
Fix handedness of MikkTSpace tangent output [521]
  • Loading branch information
UX3D-kanzler authored Jan 30, 2024
2 parents f99994e + 109d10a commit efa0ce6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/gltf/primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,11 @@ class gltfPrimitive extends GltfObject

const tangents = generateTangents(positions, normals, texcoords);

// convert coordinate system handedness to respect output format of MikkTSpace
for (let idx = 0; idx < tangents.length; idx += 4) {
tangents[idx+3] = -tangents[idx+3] // Flip w-channel
}

// Create a new buffer and buffer view for the tangents:
const tangentBuffer = new gltfBuffer();
tangentBuffer.byteLength = tangents.byteLength;
Expand Down

0 comments on commit efa0ce6

Please sign in to comment.