gedeng/Shader/depth-debug.fs
karl 3c35a730f5 Add basic setup for shadow rendering
adapted from the previous ECS project. working to some extent, but far from ideal
2021-05-20 00:15:58 +02:00

22 lines
557 B
GLSL

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