aboutsummaryrefslogtreecommitdiff
path: root/deps/raylib/examples/shaders/resources/shaders/glsl330/depth.fs
diff options
context:
space:
mode:
Diffstat (limited to 'deps/raylib/examples/shaders/resources/shaders/glsl330/depth.fs')
-rw-r--r--deps/raylib/examples/shaders/resources/shaders/glsl330/depth.fs27
1 files changed, 27 insertions, 0 deletions
diff --git a/deps/raylib/examples/shaders/resources/shaders/glsl330/depth.fs b/deps/raylib/examples/shaders/resources/shaders/glsl330/depth.fs
new file mode 100644
index 0000000..f7546bb
--- /dev/null
+++ b/deps/raylib/examples/shaders/resources/shaders/glsl330/depth.fs
@@ -0,0 +1,27 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0; // Depth texture
+uniform vec4 colDiffuse;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ float zNear = 0.01; // camera z near
+ float zFar = 10.0; // camera z far
+ float z = texture(texture0, fragTexCoord).x;
+
+ // Linearize depth value
+ float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
+
+ // Calculate final fragment color
+ finalColor = vec4(depth, depth, depth, 1.0f);
+} \ No newline at end of file