Skip to content

Commit

Permalink
Normal mapping gram-schmidth bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyDeVries committed Nov 23, 2016
1 parent fad0497 commit 621f28f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int main()
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
// Render normal-mapped quad
glm::mat4 model;
model = glm::rotate(model, (GLfloat)glfwGetTime() * -10, glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // Rotates the quad to show normal mapping works in all directions
model = glm::rotate(model, (GLfloat)glfwGetTime() * -0.1f, glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // Rotates the quad to show normal mapping works in all directions
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
glUniform3fv(glGetUniformLocation(shader.Program, "lightPos"), 1, &lightPos[0]);
glUniform3fv(glGetUniformLocation(shader.Program, "viewPos"), 1, &camera.Position[0]);
Expand Down
3 changes: 2 additions & 1 deletion src/5.advanced_lighting/4.normal_mapping/normal_mapping.vs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ void main()
vs_out.Normal = normalize(normalMatrix * normal);

vec3 T = normalize(normalMatrix * tangent);
vec3 B = normalize(normalMatrix * bitangent);
vec3 N = normalize(normalMatrix * normal);
T = normalize(T - dot(T, N) * N);
vec3 B = cross(N, T);
mat3 TBN = transpose(mat3(T, B, N));
vs_out.TBN = TBN;

Expand Down

0 comments on commit 621f28f

Please sign in to comment.