From 3c4a88761b9de6fcf663fdcdbedbd42afade819f Mon Sep 17 00:00:00 2001 From: daeunSong Date: Thu, 13 Aug 2020 17:53:03 +0900 Subject: [PATCH] Fix texture coordinate tangent and bitangent calculation --- includes/learnopengl/model.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/learnopengl/model.h b/includes/learnopengl/model.h index 9ccc557..24732d0 100644 --- a/includes/learnopengl/model.h +++ b/includes/learnopengl/model.h @@ -115,19 +115,20 @@ private: vec.x = mesh->mTextureCoords[0][i].x; vec.y = mesh->mTextureCoords[0][i].y; 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 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); } // now wak through each of the mesh's faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices.