summaryrefslogtreecommitdiff
path: root/advanced_lighting/5.parallax_mapping/shaders/parallax.vert
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-03-18 11:31:31 +0500
committerpryazha <pryadeiniv@mail.ru>2025-03-18 11:31:31 +0500
commitd65ddd07a43d5ffdcf2ddf90d6f86626cf9b92d8 (patch)
tree672efce6089ec9c1103be0c1b70a28ec415eeeab /advanced_lighting/5.parallax_mapping/shaders/parallax.vert
parentd64a159d05a45e75870f61c37f0defa94f03793e (diff)
Diffstat (limited to 'advanced_lighting/5.parallax_mapping/shaders/parallax.vert')
-rw-r--r--advanced_lighting/5.parallax_mapping/shaders/parallax.vert37
1 files changed, 37 insertions, 0 deletions
diff --git a/advanced_lighting/5.parallax_mapping/shaders/parallax.vert b/advanced_lighting/5.parallax_mapping/shaders/parallax.vert
new file mode 100644
index 0000000..a3451c3
--- /dev/null
+++ b/advanced_lighting/5.parallax_mapping/shaders/parallax.vert
@@ -0,0 +1,37 @@
+#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 {
+ vec3 frag_pos;
+ vec2 tex_coords;
+ vec3 tangent_light_pos;
+ vec3 tangent_view_pos;
+ vec3 tangent_frag_pos;
+} vs_out;
+
+uniform mat4 proj;
+uniform mat4 view;
+uniform mat4 model;
+
+uniform vec3 light_pos;
+uniform vec3 view_pos;
+
+void main(void)
+{
+ gl_Position = proj*view*model*vec4(apos, 1.0);
+ vs_out.frag_pos = vec3(model*vec4(apos, 1.0));
+ vs_out.tex_coords = atex_coords;
+
+ vec3 T = normalize(mat3(model)*atangent);
+ vec3 B = normalize(mat3(model)*abitangent);
+ vec3 N = normalize(mat3(model)*anormal);
+ 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*vs_out.frag_pos;
+}