2014-12-04 00:13:59 +00:00
|
|
|
#version 150
|
|
|
|
|
2015-01-31 19:02:23 +00:00
|
|
|
in vec4 fragPosition;
|
|
|
|
|
2015-02-04 13:27:41 +00:00
|
|
|
uniform float farPlane;
|
|
|
|
|
2015-02-02 18:58:16 +00:00
|
|
|
out float gl_FragDepth;
|
2014-12-04 00:13:59 +00:00
|
|
|
|
|
|
|
void main() {
|
2015-02-05 12:19:51 +00:00
|
|
|
float nearPlane = 0.1;
|
|
|
|
float A = -(farPlane+nearPlane)/(farPlane-nearPlane);
|
|
|
|
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
|
|
|
|
float value = 0.5*(-A*length(fragPosition) + B)/length(fragPosition) + 0.5;
|
|
|
|
gl_FragDepth = value;
|
|
|
|
//gl_FragDepth = length(fragPosition)/farPlane;
|
2014-12-04 00:13:59 +00:00
|
|
|
}
|