Skip to content

Commit

Permalink
update the calculation and orthogonalization for bitangent
Browse files Browse the repository at this point in the history
  • Loading branch information
youkeyao committed Feb 20, 2022
1 parent dff3620 commit ad766cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/PostProcessing/CalcTangentsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,17 @@ bool CalcTangentsProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshIndex) {
tangent.x = (w.x * sy - v.x * ty) * dirCorrection;
tangent.y = (w.y * sy - v.y * ty) * dirCorrection;
tangent.z = (w.z * sy - v.z * ty) * dirCorrection;
bitangent.x = (w.x * sx - v.x * tx) * dirCorrection;
bitangent.y = (w.y * sx - v.y * tx) * dirCorrection;
bitangent.z = (w.z * sx - v.z * tx) * dirCorrection;
bitangent.x = (- w.x * sx + v.x * tx) * dirCorrection;
bitangent.y = (- w.y * sx + v.y * tx) * dirCorrection;
bitangent.z = (- w.z * sx + v.z * tx) * dirCorrection;

// store for every vertex of that face
for (unsigned int b = 0; b < face.mNumIndices; ++b) {
unsigned int p = face.mIndices[b];

// project tangent and bitangent into the plane formed by the vertex' normal
aiVector3D localTangent = tangent - meshNorm[p] * (tangent * meshNorm[p]);
aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]);
aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]) - localTangent * (bitangent * localTangent);
localTangent.NormalizeSafe();
localBitangent.NormalizeSafe();

Expand Down

0 comments on commit ad766cb

Please sign in to comment.