mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Normal mapping gram-schmidth bugfix.
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user