VoxelEngine/Lights/depthfragment.glsl

16 lines
330 B
Text
Raw Normal View History

2017-08-27 12:51:26 +02:00
#version 410
layout(location = 2) in vec3 pos;
uniform float near;
uniform float far;
void main()
{
float z = gl_FragCoord.z;
//convert to linear values
//formula can be found at www.roxlu.com/2014/036/rendering-the-depth-buffer
float c = (2.0 * near) / (far + near - z * (far - near));
gl_FragDepth = c;
}