protot/data/shaders/fs_depthbuffer.glsl

23 lines
363 B
Plaintext
Raw Normal View History

2018-02-15 09:59:38 +01:00
#version 330 core
in vec2 ioUV;
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() {
float z = texture(uDepthTexture, ioUV).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
}