import type { Texture } from '@luma.gl/core'; import type { ShaderPassPipeline } from '@luma.gl/shadertools'; export type SSAOShaderPassPipelineOptions = { normalSource?: 'reconstruct-from-depth' | 'normal-texture'; /** Fractional intermediate framebuffer resolution. Defaults to full resolution. */ resolutionScale?: number; }; type SSAOUniforms = { nearPlane: number; farPlane: number; radius: number; bias: number; intensity: number; useNormalTexture: number; }; type SSAOBindings = { depthTexture?: Texture; normalTexture?: Texture; }; export declare const ssaoEvaluate: { readonly name: "ssaoEvaluate"; readonly source: "fn advancedSceneUV(uv: vec2f) -> vec2f {\n return uv;\n}\n\nfn advancedLinearDepth(depth: f32, nearPlane: f32, farPlane: f32) -> f32 {\n return (nearPlane * farPlane) / max(farPlane - depth * (farPlane - nearPlane), 0.0001);\n}\n\nfn advancedDepthNormal(depthTexture: texture_depth_2d, depthTextureSampler: sampler, uv: vec2f) -> vec3f {\n let dimensions = vec2i(textureDimensions(depthTexture));\n let coordinate = clamp(vec2i(uv * vec2f(dimensions)), vec2i(0), dimensions - vec2i(1));\n let center = textureLoad(depthTexture, coordinate, 0);\n let right = textureLoad(depthTexture, min(coordinate + vec2i(1, 0), dimensions - vec2i(1)), 0);\n let up = textureLoad(depthTexture, min(coordinate + vec2i(0, 1), dimensions - vec2i(1)), 0);\n return normalize(vec3f((center - right) * f32(dimensions.x), (center - up) * f32(dimensions.y), 1.0));\n}\n\nstruct ssaoEvaluateUniforms {\n nearPlane: f32,\n farPlane: f32,\n radius: f32,\n bias: f32,\n intensity: f32,\n useNormalTexture: f32,\n};\n@group(0) @binding(auto) var ssaoEvaluate: ssaoEvaluateUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssaoEvaluate_sampleColor(\n sourceTexture: texture_2d, sourceTextureSampler: sampler, texSize: vec2f, texCoord: vec2f\n) -> vec4f {\n let sceneCoord = advancedSceneUV(texCoord);\n let depth = textureSample(depthTexture, depthTextureSampler, sceneCoord);\n let dimensions = vec2f(textureDimensions(depthTexture));\n let linearDepth = advancedLinearDepth(depth, ssaoEvaluate.nearPlane, ssaoEvaluate.farPlane);\n let reconstructedNormal = advancedDepthNormal(depthTexture, depthTextureSampler, sceneCoord);\n let textureNormal = normalize(textureSample(normalTexture, normalTextureSampler, sceneCoord).xyz * 2.0 - 1.0);\n let normal = normalize(mix(reconstructedNormal, textureNormal, ssaoEvaluate.useNormalTexture));\n let angle = fract(sin(dot(texCoord * dimensions, vec2f(12.9898, 78.233))) * 43758.5453) * 6.2831853;\n var occlusion = 0.0;\n for (var index: i32 = 0; index < 12; index++) {\n let sampleAngle = angle + f32(index) * 2.399963;\n let sampleRadius = (0.25 + 0.75 * f32(index + 1) / 12.0) * ssaoEvaluate.radius;\n let direction = vec2f(cos(sampleAngle), sin(sampleAngle));\n let sampleUv = clamp(texCoord + direction * sampleRadius / dimensions, vec2f(0.0), vec2f(1.0));\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, advancedSceneUV(sampleUv), 0);\n let sampleLinearDepth = advancedLinearDepth(sampleDepth, ssaoEvaluate.nearPlane, ssaoEvaluate.farPlane);\n let rangeWeight = smoothstep(ssaoEvaluate.radius * 2.0, 0.0, abs(sampleLinearDepth - linearDepth));\n let horizonWeight = max(dot(normal, normalize(vec3f(direction, 0.35))), 0.15);\n occlusion += select(0.0, rangeWeight * horizonWeight, sampleLinearDepth + ssaoEvaluate.bias < linearDepth);\n }\n let ambient = select(clamp(1.0 - occlusion / 12.0 * ssaoEvaluate.intensity, 0.0, 1.0), 1.0, depth >= 0.99999);\n return vec4f(vec3f(ambient), 1.0);\n}\n"; readonly bindingLayout: readonly [{ readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "normalTexture"; readonly group: 0; }]; readonly props: Partial & SSAOBindings; readonly uniforms: SSAOUniforms; readonly bindings: SSAOBindings; readonly uniformTypes: { readonly nearPlane: "f32"; readonly farPlane: "f32"; readonly radius: "f32"; readonly bias: "f32"; readonly intensity: "f32"; readonly useNormalTexture: "f32"; }; readonly propTypes: { readonly nearPlane: { readonly value: 0.1; }; readonly farPlane: { readonly value: 200; }; readonly radius: { readonly value: 7; readonly min: 1; readonly softMax: 32; }; readonly bias: { readonly value: 0.03; readonly min: 0; readonly softMax: 0.2; }; readonly intensity: { readonly value: 1.35; readonly min: 0; readonly softMax: 4; }; readonly useNormalTexture: { readonly value: 0; readonly min: 0; readonly max: 1; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; export declare function createSSAOShaderPassPipeline(options?: SSAOShaderPassPipelineOptions): ShaderPassPipeline<'ssaoRaw' | 'ssaoScratch' | 'ssaoBlurred'>; export declare const ssaoComposite: { readonly name: "ssaoComposite"; readonly source: "struct ssaoCompositeUniforms {\n debugMode: f32,\n};\n@group(0) @binding(auto) var ssaoComposite: ssaoCompositeUniforms;\n@group(0) @binding(auto) var ambientOcclusionTexture: texture_2d;\n@group(0) @binding(auto) var ambientOcclusionTextureSampler: sampler;\nfn ssaoComposite_sampleColor(\n sourceTexture: texture_2d, sourceTextureSampler: sampler, texSize: vec2f, texCoord: vec2f\n) -> vec4f {\n let color = textureSample(sourceTexture, sourceTextureSampler, texCoord);\n let ambient = textureSample(ambientOcclusionTexture, ambientOcclusionTextureSampler, texCoord).r;\n if (ssaoComposite.debugMode > 0.5) { return vec4f(vec3f(ambient), 1.0); }\n let rawOcclusion = clamp(1.0 - ambient, 0.0, 1.0);\n let contactOcclusion = smoothstep(0.03, 0.5, rawOcclusion);\n return vec4f(color.rgb * (1.0 - contactOcclusion * 0.48), color.a);\n}"; readonly bindingLayout: readonly [{ readonly name: "ambientOcclusionTexture"; readonly group: 0; }]; readonly uniformTypes: { readonly debugMode: "f32"; }; readonly propTypes: { readonly debugMode: { readonly value: 0; readonly min: 0; readonly max: 1; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; export {}; //# sourceMappingURL=ssao.d.ts.map