uniform vec2 iResolution;
uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform sampler2D iDepthBuffer;
out vec4 FragColor;
const float farPlane = 100.0;
const float nearPlane = 0.1;
void main() {
vec2 uv = gl_FragCoord.xy / iResolution.xy;
float depth = texture(iDepthBuffer, uv).r;
// replace with position restore
float linearDepth = depth * 2.0 - 1.0;
linearDepth = (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - linearDepth * (farPlane - nearPlane));
linearDepth /= farPlane * 0.4;
FragColor = vec4(vec3(linearDepth), 1.0);
}