protot/data/shaders/fs_depthbuffer.glsl

23 lines
385 B
Plaintext
Raw Permalink Normal View History

2018-03-15 11:01:55 +01:00
#version 150 core
2018-02-15 09:59:38 +01:00
2018-04-05 12:39:30 +02:00
in vec2 ioFragTexCoords;
2018-02-15 09:59:38 +01:00
out vec3 outColor;
2018-02-15 09:59:38 +01:00
uniform sampler2D uDepthTexture;
uniform float uIsOrthographic;
uniform float uNear;
uniform float uFar;
2018-02-15 09:59:38 +01:00
void main() {
2018-04-05 12:39:30 +02:00
float z = texture(uDepthTexture, ioFragTexCoords).r;
float c;
if (uIsOrthographic == 1.0) {
c = z;
} else {
c = (2.0 * uNear) / (uFar + uNear - z * (uFar - uNear));
}
outColor = vec3(c);
2018-02-15 09:59:38 +01:00
}