1
0
forked from Rowland/EG
EG/Cesium-1.132/packages/engine/Source/Shaders/Builtin/Functions/reverseLogDepth.glsl
2025-08-25 17:48:13 +08:00

12 lines
342 B
GLSL

float czm_reverseLogDepth(float logZ)
{
#ifdef LOG_DEPTH
float near = czm_currentFrustum.x;
float far = czm_currentFrustum.y;
float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;
float depthFromNear = exp2(log2Depth) - 1.0;
return far * (1.0 - near / (depthFromNear + near)) / (far - near);
#endif
return logZ;
}