Normal/Height maps now working from models, and are only applied to models that have them.
This commit is contained in:
parent
4efe72b8d8
commit
8b41591360
8 changed files with 170 additions and 12 deletions
31
43-normal-maps/shaders/43-framebuffers.vert.glsl
Normal file
31
43-normal-maps/shaders/43-framebuffers.vert.glsl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in vec2 aTexCoords;
|
||||
layout (location = 3) in vec3 aTangent;
|
||||
layout (location = 4) in vec3 aBitangent;
|
||||
|
||||
out vec3 FragPos;
|
||||
out vec3 Normal;
|
||||
out vec2 TexCoords;
|
||||
out vec4 FragPosLightSpace;
|
||||
out mat3 TBN;
|
||||
|
||||
uniform mat4 projection;
|
||||
uniform mat4 view;
|
||||
uniform mat4 model;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragPos = vec3(model * vec4(aPos, 1.0));
|
||||
Normal = transpose(inverse(mat3(model))) * aNormal;
|
||||
TexCoords = aTexCoords;
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||
|
||||
vec3 T = normalize(vec3(model * vec4(aTangent, 0.0)));
|
||||
vec3 B = normalize(vec3(model * vec4(aBitangent, 0.0)));
|
||||
vec3 N = normalize(vec3(model * vec4(aNormal, 0.0)));
|
||||
TBN = mat3(T, B, N);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue