diff options
author | pryazha <pryadeiniv@mail.ru> | 2025-02-19 22:26:48 +0500 |
---|---|---|
committer | pryazha <pryadeiniv@mail.ru> | 2025-02-19 22:26:48 +0500 |
commit | f9ad6fa902c1167d7622ee7af2617d14b62bee21 (patch) | |
tree | 9d78792cf360ed871616a9ea66c4237018292aa7 /advanced_lighting/4.normal_mapping/shaders/normal_map.vert | |
parent | 926cbd0d49890772f911e6a6bedb7835605ced89 (diff) |
quite a lot of changes that I, of course, are not going to describe;)
Diffstat (limited to 'advanced_lighting/4.normal_mapping/shaders/normal_map.vert')
-rw-r--r-- | advanced_lighting/4.normal_mapping/shaders/normal_map.vert | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/advanced_lighting/4.normal_mapping/shaders/normal_map.vert b/advanced_lighting/4.normal_mapping/shaders/normal_map.vert new file mode 100644 index 0000000..3b089b5 --- /dev/null +++ b/advanced_lighting/4.normal_mapping/shaders/normal_map.vert @@ -0,0 +1,36 @@ +#version 330 core +layout(location = 0) in vec3 apos; +layout(location = 1) in vec3 anormal; +layout(location = 2) in vec2 atex_coords; +layout(location = 3) in vec3 atangent; +layout(location = 4) in vec3 abitangent; + +out VS_OUT { + /* mat3 TBN; */ + vec3 frag_pos; + vec3 tangent_light_pos; + vec3 tangent_view_pos; + vec3 tangent_frag_pos; + vec2 tex_coords; +} vs_out; + +uniform mat4 proj; +uniform mat4 view; +uniform mat4 model; + +uniform vec3 light_pos; +uniform vec3 view_pos; + +void main(void) +{ + vs_out.frag_pos = vec3(model * vec4(apos, 1.0)); + vs_out.tex_coords = atex_coords; + 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))); + mat3 TBN = transpose(mat3(T, B, N)); + vs_out.tangent_light_pos = TBN * light_pos; + vs_out.tangent_view_pos = TBN * view_pos; + vs_out.tangent_frag_pos = TBN * vec3(model * vec4(apos, 0.0)); + gl_Position = proj * view * vec4(vs_out.frag_pos, 1.0); +} |