16 lines
330 B
Text
16 lines
330 B
Text
|
#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;
|
||
|
}
|