summaryrefslogtreecommitdiff
path: root/advanced_lighting/3.2.point_shadows/shaders/depth.frag
diff options
context:
space:
mode:
Diffstat (limited to 'advanced_lighting/3.2.point_shadows/shaders/depth.frag')
-rw-r--r--advanced_lighting/3.2.point_shadows/shaders/depth.frag13
1 files changed, 13 insertions, 0 deletions
diff --git a/advanced_lighting/3.2.point_shadows/shaders/depth.frag b/advanced_lighting/3.2.point_shadows/shaders/depth.frag
new file mode 100644
index 0000000..f95c0f8
--- /dev/null
+++ b/advanced_lighting/3.2.point_shadows/shaders/depth.frag
@@ -0,0 +1,13 @@
+#version 330 core
+
+in vec4 frag_pos;
+
+uniform vec3 light_pos;
+uniform float far;
+
+void main(void)
+{
+ float light_distance = length(frag_pos.xyz-light_pos);
+ light_distance = light_distance/far;
+ gl_FragDepth = light_distance;
+}