You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/files/shaders/lib/view/depth.glsl

25 lines
479 B
GLSL

#ifndef LIB_VIEW_DEPTH
#define LIB_VIEW_DEPTH
float linearizeDepth(float depth, float near, float far)
{
#if @reverseZ
depth = 1.0 - depth;
#endif
float z_n = 2.0 * depth - 1.0;
depth = 2.0 * near * far / (far + near - z_n * (far - near));
return depth;
}
float getLinearDepth(in float z, in float viewZ)
{
#if @reverseZ
// FIXME: Fixme, figure out how to calculate correct linear depth for reverse z
return -viewZ;
#else
return z;
#endif
}
#endif