oglc/shader/include/depth.glsl

20 lines
411 B
GLSL

float getLinearDepth(float distance)
{
return distance/INF;
}
float getLogarithmicDepth(float distance)
{
// n roughly correlates to steepness of log curve
// TODO: what does this mean in mathematical terms??
float n = 2;
float f = INF;
float z = distance;
// logarithmic depth
float d = log(z*pow(E,n)/f)/n;
//d = d < 0 ? 1 : d;
return d;
//return max(0,d);
}