Browse Source

Added depth drawing shader

NOTE: It requires a depth texture as input, it should be configured on
rlgl, by default RenderTexture (fbo) uses Depth Renderbuffer instead of
Depth Texture. Check rlglLoadRenderTexture()
pull/109/head
raysan5 8 years ago
parent
commit
cde2c1aa6d
1 changed files with 27 additions and 0 deletions
  1. +27
    -0
      examples/resources/shaders/glsl330/depth.fs

+ 27
- 0
examples/resources/shaders/glsl330/depth.fs View File

@ -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 fragTintColor;
// 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);
}

Loading…
Cancel
Save