diff options
| author | raysan5 <raysan5@gmail.com> | 2016-04-08 00:21:21 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-04-08 00:21:21 +0200 |
| commit | cde2c1aa6db6577fa415d60280aa53a86b3cc97a (patch) | |
| tree | 19730664a7c721d73ed0012ba27c34a3084593a9 | |
| parent | aa22d979834eeddb849f45bba7c0f467b575e6db (diff) | |
| download | raylib-cde2c1aa6db6577fa415d60280aa53a86b3cc97a.tar.gz raylib-cde2c1aa6db6577fa415d60280aa53a86b3cc97a.zip | |
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()
| -rw-r--r-- | examples/resources/shaders/glsl330/depth.fs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/resources/shaders/glsl330/depth.fs b/examples/resources/shaders/glsl330/depth.fs new file mode 100644 index 00000000..06d399f9 --- /dev/null +++ b/examples/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 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); +}
\ No newline at end of file |
