mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-03 23:33:23 +08:00
Fix texture coordinate tangent and bitangent calculation
This commit is contained in:
@@ -115,19 +115,20 @@ private:
|
|||||||
vec.x = mesh->mTextureCoords[0][i].x;
|
vec.x = mesh->mTextureCoords[0][i].x;
|
||||||
vec.y = mesh->mTextureCoords[0][i].y;
|
vec.y = mesh->mTextureCoords[0][i].y;
|
||||||
vertex.TexCoords = vec;
|
vertex.TexCoords = vec;
|
||||||
|
// tangent
|
||||||
|
vector.x = mesh->mTangents[i].x;
|
||||||
|
vector.y = mesh->mTangents[i].y;
|
||||||
|
vector.z = mesh->mTangents[i].z;
|
||||||
|
vertex.Tangent = vector;
|
||||||
|
// bitangent
|
||||||
|
vector.x = mesh->mBitangents[i].x;
|
||||||
|
vector.y = mesh->mBitangents[i].y;
|
||||||
|
vector.z = mesh->mBitangents[i].z;
|
||||||
|
vertex.Bitangent = vector;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vertex.TexCoords = glm::vec2(0.0f, 0.0f);
|
vertex.TexCoords = glm::vec2(0.0f, 0.0f);
|
||||||
// tangent
|
|
||||||
vector.x = mesh->mTangents[i].x;
|
|
||||||
vector.y = mesh->mTangents[i].y;
|
|
||||||
vector.z = mesh->mTangents[i].z;
|
|
||||||
vertex.Tangent = vector;
|
|
||||||
// bitangent
|
|
||||||
vector.x = mesh->mBitangents[i].x;
|
|
||||||
vector.y = mesh->mBitangents[i].y;
|
|
||||||
vector.z = mesh->mBitangents[i].z;
|
|
||||||
vertex.Bitangent = vector;
|
|
||||||
vertices.push_back(vertex);
|
vertices.push_back(vertex);
|
||||||
}
|
}
|
||||||
// now wak through each of the mesh's faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices.
|
// now wak through each of the mesh's faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices.
|
||||||
|
|||||||
Reference in New Issue
Block a user