declare const _default: "\n// the chunk can be included more than once - by the composition and the effects it composes\n#ifndef _SCREENDEPTH_INCLUDED_\n#define _SCREENDEPTH_INCLUDED_\n\nvar uSceneDepthMap: texture_2d;\n\n#ifndef SCREENSIZE\n #define SCREENSIZE\n uniform screen_size: vec4f;\n#endif\n\n#ifndef VIEWMATRIX\n #define VIEWMATRIX\n uniform matrix_view: mat4x4f;\n#endif\n\n#ifndef LINEARIZE_DEPTH\n #define LINEARIZE_DEPTH\n\n #ifndef CAMERAPLANES\n #define CAMERAPLANES\n uniform camera_params: vec4f; // x: 1 / camera_far, y: camera_far, z: camera_near, w: is_ortho\n #endif\n\n fn linearizeDepth(z: f32) -> f32 {\n if (uniform.camera_params.w == 0.0) { // Perspective\n return (uniform.camera_params.z * uniform.camera_params.y) / (uniform.camera_params.y + z * (uniform.camera_params.z - uniform.camera_params.y));\n } else {\n return uniform.camera_params.z + z * (uniform.camera_params.y - uniform.camera_params.z);\n }\n }\n#endif\n\nfn delinearizeDepth(linearDepth: f32) -> f32 {\n if (uniform.camera_params.w == 0.0) {\n return (uniform.camera_params.y * (uniform.camera_params.z - linearDepth)) / (linearDepth * (uniform.camera_params.z - uniform.camera_params.y));\n } else {\n return (linearDepth - uniform.camera_params.z) / (uniform.camera_params.y - uniform.camera_params.z);\n }\n}\n\n// Retrieves rendered linear camera depth by UV\n//\n// Note that there is no SCENE_DEPTHMAP_PACKED decode here, unlike in the GLSL chunk. WebGPU can\n// always render to float textures, so no producer of the scene depth map falls back to packing the\n// depth into RGBA8 on this backend. RenderPassPrepass asserts this.\nfn getLinearScreenDepth(uv: vec2f) -> f32 {\n let textureSize = textureDimensions(uSceneDepthMap, 0);\n let texel: vec2i = vec2i(uv * vec2f(textureSize));\n\n #ifdef SCENE_DEPTHMAP_LINEAR\n #ifdef SCENE_DEPTHMAP_RECIPROCAL\n\n // a coverage weighted average of the reciprocals of the depths, inverted back into a\n // depth. Zero is a pixel nothing was rendered to, which reads as the far clip.\n let recip: f32 = textureLoad(uSceneDepthMap, texel, 0).r;\n return select(uniform.camera_params.y, 1.0 / recip, recip > 0.0);\n #else\n return textureLoad(uSceneDepthMap, texel, 0).r;\n #endif\n #else\n return linearizeDepth(textureLoad(uSceneDepthMap, texel, 0).r);\n #endif\n}\n\n#ifndef VERTEXSHADER\n // Retrieves rendered linear camera depth under the current pixel\n fn getLinearScreenDepthFrag() -> f32 {\n let uv: vec2f = pcPosition.xy * uniform.screen_size.zw;\n return getLinearScreenDepth(uv);\n }\n#endif\n\n// Generates linear camera depth for the given world position\nfn getLinearDepth(pos: vec3f) -> f32 {\n return -(uniform.matrix_view * vec4f(pos, 1.0)).z;\n}\n\n#endif\n"; export default _default;