export declare const ssao = "\nvarying vec2 vUv;\n\nuniform highp sampler2D depthTexture;\nuniform sampler2D normalTexture;\nuniform mat4 projectionViewMatrix;\nuniform mat4 cameraMatrixWorld;\n\nuniform sampler2D blueNoiseTexture;\nuniform vec2 blueNoiseRepeat;\nuniform vec2 texSize;\nuniform mat4 projectionMatrixInverse;\n\nuniform float aoDistance;\nuniform float distancePower;\nuniform float cameraNear;\nuniform float cameraFar;\nuniform int frame;\n\nuniform vec3[spp] samples;\nuniform float[spp] samplesR;\n\n#include \n#include \n#include \n\n// source: https://github.com/N8python/ssao/blob/master/EffectShader.js#L52\nvec3 getWorldPos(const float depth, const vec2 coord) {\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = projectionMatrixInverse * clipSpacePosition;\n\n // Perspective division\n vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;\n worldSpacePosition.xyz /= worldSpacePosition.w;\n\n return worldSpacePosition.xyz;\n}\n\nvec3 computeNormal(vec3 worldPos, vec2 vUv) {\n vec2 size = vec2(textureSize(depthTexture, 0));\n ivec2 p = ivec2(vUv * size);\n float c0 = texelFetch(depthTexture, p, 0).x;\n float l2 = texelFetch(depthTexture, p - ivec2(2, 0), 0).x;\n float l1 = texelFetch(depthTexture, p - ivec2(1, 0), 0).x;\n float r1 = texelFetch(depthTexture, p + ivec2(1, 0), 0).x;\n float r2 = texelFetch(depthTexture, p + ivec2(2, 0), 0).x;\n float b2 = texelFetch(depthTexture, p - ivec2(0, 2), 0).x;\n float b1 = texelFetch(depthTexture, p - ivec2(0, 1), 0).x;\n float t1 = texelFetch(depthTexture, p + ivec2(0, 1), 0).x;\n float t2 = texelFetch(depthTexture, p + ivec2(0, 2), 0).x;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getWorldPos(c0, vUv).xyz;\n vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / size.x, 0.0))).xyz\n : -ce + getWorldPos(r1, (vUv + vec2(1.0 / size.x, 0.0))).xyz;\n vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / size.y))).xyz\n : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / size.y))).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nhighp float linearize_depth(highp float d, highp float zNear, highp float zFar) {\n highp float z_n = 2.0 * d - 1.0;\n return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear));\n}\n\nvoid main() {\n float depth = textureLod(depthTexture, vUv, 0.).x;\n\n // filter out background\n if (depth == 1.0) {\n discard;\n return;\n }\n\n vec3 worldPos = getWorldPos(depth, vUv);\n vec3 normal = computeNormal(worldPos, vUv);\n\n#ifdef animatedNoise\n int seed = frame;\n#else\n int seed = 0;\n#endif\n\n vec4 noise = sampleBlueNoise(blueNoiseTexture, seed, blueNoiseRepeat, texSize);\n\n vec3 randomVec = normalize(noise.rgb * 2.0 - 1.0);\n vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));\n vec3 bitangent = cross(normal, tangent);\n mat3 tbn = mat3(tangent, bitangent, normal);\n\n float occluded = 0.0;\n float totalWeight = 0.0;\n\n vec3 samplePos;\n\n float sppF = float(spp);\n\n for (float i = 0.0; i < sppF; i++) {\n vec3 sampleDirection = tbn * samples[int(i)];\n\n // make sure sample direction is in the same hemisphere as the normal\n if (dot(sampleDirection, normal) < 0.0) sampleDirection *= -1.0;\n\n float moveAmt = samplesR[int(mod(i + noise.a * sppF, sppF))];\n samplePos = worldPos + aoDistance * moveAmt * sampleDirection;\n\n vec4 offset = projectionViewMatrix * vec4(samplePos, 1.0);\n offset.xyz /= offset.w;\n offset.xyz = offset.xyz * 0.5 + 0.5;\n\n float sampleDepth = textureLod(depthTexture, offset.xy, 0.0).x;\n\n float distSample = linearize_depth(sampleDepth, cameraNear, cameraFar);\n float distWorld = linearize_depth(offset.z, cameraNear, cameraFar);\n\n float rangeCheck = smoothstep(0.0, 1.0, aoDistance / abs(distSample - distWorld));\n rangeCheck = pow(rangeCheck, distancePower);\n float weight = dot(sampleDirection, normal);\n\n occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);\n totalWeight += weight;\n }\n\n float occ = clamp(1.0 - occluded / totalWeight, 0.0, 1.0);\n gl_FragColor = vec4(normal, occ);\n}\n"; //# sourceMappingURL=ssao.d.ts.map