normalmap.vert
Variables and Uniforms
Input variables and Uniforms
add tangent space in variables
// added for LabA08 Normal Map
in layout(location=3) vec3 aTangent;
in layout(location=4) vec3 aBitangent;Uniforms
Move lightpos and viewpos from the fragment shader to the vertex shader as we are going to calculate lighting in the tangent space
uniform vec3 lightPos;
uniform vec3 viewPos;Outpu variables
add tangent space out variables
out vec3 tangentLightPos;
out vec3 tangentViewPos;
out vec3 tangentFragPos;comment out normal
in main()
Comment out the normal transform
as we are going to read the normal from the normal map in the fragment shader.
Generate the inverse (transpose) of the tangent space matrix TBN
Transform lightPos, viewPos and fragPos to the tangent space
Full Source Code
Last updated