prosperon/source/shaders/debugdepthfrag.glsl
John Alanbrook e745acad3e Project cleanup
Standard shaders and fonts now belong to the source directory
2022-08-05 21:16:04 +00:00

22 lines
619 B
GLSL

#version 330 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D depthMap;
uniform float near_plane;
uniform float far_plane;
// required when using a perspective projection matrix
float LinearizeDepth(float depth)
{
float z = depth * 2.0 - 1.0; // Back to NDC
return (2.0 * near_plane * far_plane) / (far_plane + near_plane - z * (far_plane - near_plane));
}
void main()
{
float depthValue = texture(depthMap, TexCoords).r;
//FragColor = vec4(vec3(LinearizeDepth(depthValue) / far_plane), 1.0); // perspective
FragColor = texture(depthMap, TexCoords); // orthographic
}