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()
This commit is contained in:
parent
aa22d97983
commit
cde2c1aa6d
1 changed files with 27 additions and 0 deletions
27
examples/resources/shaders/glsl330/depth.fs
Normal file
27
examples/resources/shaders/glsl330/depth.fs
Normal 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…
Add table
Add a link
Reference in a new issue