declare const _default: "\nvar computeSceneDepthMap: texture_2d;\n\n// the camera parameters the depth map was rendered with, laid out as camera_params: x: 1 / far\n// clip, y: far clip, z: near clip, w: 1 for an orthographic projection, 0 for a perspective one\nuniform computeSceneDepthCameraParams: vec4f;\n\n// the inverse of the view projection matrix the depth map was rendered with\nuniform computeSceneDepthViewProjectionInverse: mat4x4f;\n\n// the viewport the depth map was rendered with, in texels: x and y of its first texel, width and height\nuniform computeSceneDepthViewport: vec4u;\n\nfn sceneDepthSize() -> vec2u {\n return textureDimensions(computeSceneDepthMap, 0);\n}\n\nfn sceneDepthViewport() -> vec4u {\n return uniform.computeSceneDepthViewport;\n}\n\nfn sceneDepthNearClip() -> f32 {\n return uniform.computeSceneDepthCameraParams.z;\n}\n\nfn sceneDepthFarClip() -> f32 {\n return uniform.computeSceneDepthCameraParams.y;\n}\n\nfn sceneDepthLinear(texel: vec2i) -> f32 {\n let value = textureLoad(computeSceneDepthMap, texel, 0).r;\n let params = uniform.computeSceneDepthCameraParams;\n\n #ifdef SCENE_DEPTHMAP_LINEAR\n #ifdef SCENE_DEPTHMAP_RECIPROCAL\n // a coverage weighted average of the reciprocals of the depths, inverted back into a\n // depth. Zero is a texel nothing was rendered to, which reads as the far clip.\n return select(params.y, 1.0 / value, value > 0.0);\n #else\n return value;\n #endif\n #else\n // the depth buffer value, linearized for either projection\n let perspective = (params.z * params.y) / (params.y + value * (params.z - params.y));\n let orthographic = params.z + value * (params.y - params.z);\n return select(perspective, orthographic, params.w > 0.5);\n #endif\n}\n\nfn sceneDepthUnproject(ndc: vec3f) -> vec3f {\n let position = uniform.computeSceneDepthViewProjectionInverse * vec4f(ndc, 1.0);\n return position.xyz / position.w;\n}\n\nfn sceneDepthWorldPosition(texel: vec2i) -> vec3f {\n // the position of the texel within the viewport the camera rendered to\n let viewport = vec4f(uniform.computeSceneDepthViewport);\n let uv = (vec2f(texel) + 0.5 - viewport.xy) / viewport.zw;\n let ndc = vec2f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0);\n\n #ifdef SCENE_DEPTHMAP_LINEAR\n // the linear depth places the surface between the points of the texel on the near and the\n // far plane, along which the depth changes linearly\n let params = uniform.computeSceneDepthCameraParams;\n let nearPoint = sceneDepthUnproject(vec3f(ndc, 0.0));\n let farPoint = sceneDepthUnproject(vec3f(ndc, 1.0));\n return mix(nearPoint, farPoint, (sceneDepthLinear(texel) - params.z) / (params.y - params.z));\n #else\n // the depth buffer value is the depth the surface was projected to\n return sceneDepthUnproject(vec3f(ndc, textureLoad(computeSceneDepthMap, texel, 0).r));\n #endif\n}\n"; export default _default;