import type { Texture } from '@luma.gl/core'; import type { ShaderPassPipeline } from '@luma.gl/shadertools'; import type { NumberArray16 } from '@math.gl/core'; /** Construction options for temporally stabilized screen-space reflections. */ export type SSRShaderPassPipelineOptions = { /** Fractional ray-tracing, history, and denoising resolution. Defaults to full resolution. */ resolutionScale?: number; }; type SSRTraceUniforms = { projectionMatrix: Readonly; inverseProjectionMatrix: Readonly; intensity: number; maxDistance: number; thickness: number; sampleCount: number; maxRoughness: number; frameIndex: number; }; type SSRTemporalUniforms = { inverseProjectionMatrix: Readonly; historyWeight: number; depthThreshold: number; }; type SSRSpatialUniforms = { inverseProjectionMatrix: Readonly; direction: [number, number]; maxRadius: number; depthSigma: number; }; type SSRCompositeUniforms = { inverseProjectionMatrix: Readonly; strength: number; debugMode: number; depthSigma: number; }; type SSRTraceBindings = { depthTexture?: Texture; normalTexture?: Texture; }; type SSRTemporalBindings = { depthTexture?: Texture; velocityTexture?: Texture; historyTexture?: Texture; previousDepthTexture?: Texture; }; type SSRSpatialBindings = { depthTexture?: Texture; normalTexture?: Texture; }; type SSRCompositeBindings = { reflectionTexture?: Texture; depthTexture?: Texture; normalTexture?: Texture; }; /** Stochastically traces roughness-aware reflection rays through G-buffer depth. */ export declare const ssrTrace: { readonly name: "ssrTrace"; readonly source: "const SSR_TWO_PI: f32 = 6.283185307179586;\n\nstruct SSRTraceUniforms {\n projectionMatrix: mat4x4f,\n inverseProjectionMatrix: mat4x4f,\n intensity: f32,\n maxDistance: f32,\n thickness: f32,\n sampleCount: f32,\n maxRoughness: f32,\n frameIndex: f32,\n};\n\n@group(0) @binding(auto) var ssrTrace: SSRTraceUniforms;\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 ssrTrace_reconstructViewPosition(uv: vec2f, depth: f32) -> vec3f {\n let clip = vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, depth, 1.0);\n let viewPosition = ssrTrace.inverseProjectionMatrix * clip;\n return viewPosition.xyz / max(viewPosition.w, 0.00001);\n}\n\nfn ssrTrace_projectViewPosition(position: vec3f) -> vec2f {\n let clip = ssrTrace.projectionMatrix * vec4f(position, 1.0);\n let normalizedDeviceCoordinate = clip.xy / max(clip.w, 0.00001);\n return vec2f(\n normalizedDeviceCoordinate.x * 0.5 + 0.5,\n 0.5 - normalizedDeviceCoordinate.y * 0.5\n );\n}\n\nfn ssrTrace_hash(value: vec2f, frameIndex: f32) -> f32 {\n let temporalPhase = fract(frameIndex * 0.61803398875) * SSR_TWO_PI;\n return fract(sin(dot(value, vec2f(12.9898, 78.233)) + temporalPhase) * 43758.5453);\n}\n\nfn ssrTrace_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let sceneCoord = texCoord;\n let normalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, sceneCoord, 0);\n let normal = normalize(normalRoughness.xyz * 2.0 - 1.0);\n let roughness = clamp(normalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, sceneCoord, 0);\n if (centerDepth >= 0.99999 || roughness >= ssrTrace.maxRoughness ||\n ssrTrace.intensity <= 0.0001) {\n return vec4f(0.0);\n }\n\n let viewPosition = ssrTrace_reconstructViewPosition(sceneCoord, centerDepth);\n let incidentDirection = normalize(viewPosition);\n let mirrorDirection = normalize(reflect(incidentDirection, normal));\n let pixelCoordinate = floor(sceneCoord * vec2f(textureDimensions(depthTexture)));\n let noise = ssrTrace_hash(pixelCoordinate, ssrTrace.frameIndex);\n let noiseAngle = noise * SSR_TWO_PI;\n let referenceAxis = select(\n vec3f(0.0, 1.0, 0.0),\n vec3f(1.0, 0.0, 0.0),\n abs(mirrorDirection.y) > 0.9\n );\n let tangent = normalize(cross(referenceAxis, mirrorDirection));\n let bitangent = normalize(cross(mirrorDirection, tangent));\n let roughnessCone = roughness * roughness * 0.32;\n let reflectedRay = normalize(\n mirrorDirection + (tangent * cos(noiseAngle) + bitangent * sin(noiseAngle)) * roughnessCone\n );\n let rayOrigin = viewPosition + normal * max(ssrTrace.thickness * 0.12, 0.025);\n\n var reflection = vec3f(0.0);\n var confidence = 0.0;\n var previousTravel = 0.06;\n var previousDepthDelta = -ssrTrace.thickness;\n let minimumSampleCount = ceil(\n ssrTrace.maxDistance / max(ssrTrace.thickness * 0.72, 0.12)\n );\n let effectiveSampleCount = min(96.0, max(ssrTrace.sampleCount, minimumSampleCount));\n for (var sampleIndex: i32 = 1; sampleIndex <= 96; sampleIndex++) {\n if (f32(sampleIndex) > effectiveSampleCount) {\n break;\n }\n let fraction = (f32(sampleIndex) - noise * 0.42) / max(effectiveSampleCount, 1.0);\n let travel = 0.08 + pow(max(fraction, 0.0), 1.3) * ssrTrace.maxDistance;\n let rayPosition = rayOrigin + reflectedRay * travel;\n if (rayPosition.z >= -0.04) {\n break;\n }\n let sampleCoord = ssrTrace_projectViewPosition(rayPosition);\n if (any(sampleCoord <= vec2f(0.0)) || any(sampleCoord >= vec2f(1.0))) {\n break;\n }\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n if (sampleDepth >= 0.99999) {\n previousTravel = travel;\n previousDepthDelta = -ssrTrace.thickness;\n continue;\n }\n let scenePosition = ssrTrace_reconstructViewPosition(sampleCoord, sampleDepth);\n let depthDelta = (-rayPosition.z) - (-scenePosition.z);\n let rayStepLength = max(travel - previousTravel, 0.001);\n let hitThickness = max(ssrTrace.thickness, rayStepLength * 1.2) + travel * 0.008;\n let crossesCandidateSurface = previousDepthDelta <= 0.0 && depthDelta >= 0.0;\n let screenTravelPixels = length((sampleCoord - sceneCoord) * texSize);\n var entersCandidateSurface = true;\n if (crossesCandidateSurface && depthDelta < hitThickness && screenTravelPixels > 1.25) {\n let candidateNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n entersCandidateSurface = dot(reflectedRay, candidateNormal) < -0.015;\n if (entersCandidateSurface) {\n var nearTravel = previousTravel;\n var farTravel = travel;\n var hitCoord = sampleCoord;\n for (var refinementIndex: i32 = 0; refinementIndex < 5; refinementIndex++) {\n let refinedTravel = (nearTravel + farTravel) * 0.5;\n let refinedPosition = rayOrigin + reflectedRay * refinedTravel;\n let refinedCoord = ssrTrace_projectViewPosition(refinedPosition);\n let refinedDepth = textureSampleLevel(depthTexture, depthTextureSampler, refinedCoord, 0);\n let refinedScenePosition = ssrTrace_reconstructViewPosition(refinedCoord, refinedDepth);\n if ((-refinedPosition.z) - (-refinedScenePosition.z) >= 0.0) {\n farTravel = refinedTravel;\n hitCoord = refinedCoord;\n } else {\n nearTravel = refinedTravel;\n }\n }\n reflection = textureSampleLevel(sourceTexture, sourceTextureSampler, hitCoord, 0).rgb;\n let screenEdge = min(\n min(hitCoord.x, hitCoord.y),\n min(1.0 - hitCoord.x, 1.0 - hitCoord.y)\n );\n let fresnel = mix(\n 0.32,\n 1.0,\n pow(1.0 - max(dot(-incidentDirection, normal), 0.0), 5.0)\n );\n let roughnessFade = pow(1.0 - roughness / max(ssrTrace.maxRoughness, 0.001), 1.5);\n let distanceFade = 1.0 - clamp(farTravel / ssrTrace.maxDistance, 0.0, 1.0);\n confidence = smoothstep(0.0, 0.09, screenEdge) * roughnessFade * fresnel *\n distanceFade * ssrTrace.intensity;\n break;\n }\n }\n previousTravel = travel;\n previousDepthDelta = select(-ssrTrace.thickness, depthDelta, entersCandidateSurface);\n }\n\n return vec4f(reflection, clamp(confidence, 0.0, 1.0));\n}"; readonly bindingLayout: readonly [{ readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "normalTexture"; readonly group: 0; }]; readonly props: Partial & SSRTraceBindings; readonly uniforms: SSRTraceUniforms; readonly bindings: SSRTraceBindings; readonly uniformTypes: { readonly projectionMatrix: "mat4x4"; readonly inverseProjectionMatrix: "mat4x4"; readonly intensity: "f32"; readonly maxDistance: "f32"; readonly thickness: "f32"; readonly sampleCount: "f32"; readonly maxRoughness: "f32"; readonly frameIndex: "f32"; }; readonly propTypes: { readonly projectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly intensity: { readonly value: 1.35; readonly min: 0; readonly softMax: 4; }; readonly maxDistance: { readonly value: 60; readonly min: 1; readonly softMax: 180; }; readonly thickness: { readonly value: 0.45; readonly min: 0.02; readonly softMax: 3; }; readonly sampleCount: { readonly value: 48; readonly min: 8; readonly max: 96; }; readonly maxRoughness: { readonly value: 0.88; readonly min: 0.1; readonly max: 1; }; readonly frameIndex: { readonly value: 0; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Reprojects previous-frame reflection radiance with velocity and rejects disocclusions. */ export declare const ssrTemporal: { readonly name: "ssrTemporal"; readonly source: "struct SSRTemporalUniforms {\n inverseProjectionMatrix: mat4x4f,\n historyWeight: f32,\n depthThreshold: f32,\n};\n\n@group(0) @binding(auto) var ssrTemporal: SSRTemporalUniforms;\n@group(0) @binding(auto) var historyTexture: texture_2d;\n@group(0) @binding(auto) var historyTextureSampler: sampler;\n@group(0) @binding(auto) var velocityTexture: texture_2d;\n@group(0) @binding(auto) var velocityTextureSampler: sampler;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var previousDepthTexture: texture_2d;\n@group(0) @binding(auto) var previousDepthTextureSampler: sampler;\n\nfn ssrTemporal_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrTemporal.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrTemporal_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let current = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let currentDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (currentDepth >= 0.99999) {\n return vec4f(0.0);\n }\n\n let velocity = textureSampleLevel(velocityTexture, velocityTextureSampler, texCoord, 0).xy;\n let previousCoord = texCoord - velocity;\n let validCoordinate = all(previousCoord >= vec2f(0.0)) &&\n all(previousCoord <= vec2f(1.0));\n let clampedPreviousCoord = clamp(previousCoord, vec2f(0.0), vec2f(1.0));\n let previousDepth = textureSampleLevel(\n previousDepthTexture,\n previousDepthTextureSampler,\n clampedPreviousCoord,\n 0\n ).r;\n let currentViewDepth = ssrTemporal_reconstructViewDepth(texCoord, currentDepth);\n let previousViewDepth = ssrTemporal_reconstructViewDepth(clampedPreviousCoord, previousDepth);\n let relativeDepthDifference = abs(previousViewDepth - currentViewDepth) /\n max(currentViewDepth, 0.0001);\n let validDepth = relativeDepthDifference < ssrTemporal.depthThreshold;\n\n let texel = 1.0 / vec2f(textureDimensions(sourceTexture));\n var minimumReflection = current;\n var maximumReflection = current;\n for (var sampleY: i32 = -1; sampleY <= 1; sampleY++) {\n for (var sampleX: i32 = -1; sampleX <= 1; sampleX++) {\n let sampleCoord = clamp(\n texCoord + vec2f(f32(sampleX), f32(sampleY)) * texel,\n vec2f(0.0),\n vec2f(1.0)\n );\n let neighborhoodReflection = textureSampleLevel(\n sourceTexture,\n sourceTextureSampler,\n sampleCoord,\n 0\n );\n minimumReflection = min(minimumReflection, neighborhoodReflection);\n maximumReflection = max(maximumReflection, neighborhoodReflection);\n }\n }\n\n let historyReflection = textureSampleLevel(\n historyTexture,\n historyTextureSampler,\n clampedPreviousCoord,\n 0\n );\n let validHistory = validCoordinate && validDepth && historyReflection.a > 0.001;\n if (!validHistory) {\n return current;\n }\n\n let hasCurrentSupport = maximumReflection.a > 0.001;\n if (!hasCurrentSupport) {\n return vec4f(\n historyReflection.rgb,\n historyReflection.a * ssrTemporal.historyWeight\n );\n }\n\n let clampedHistory = clamp(historyReflection, minimumReflection, maximumReflection);\n return mix(current, clampedHistory, ssrTemporal.historyWeight);\n}"; readonly bindingLayout: readonly [{ readonly name: "historyTexture"; readonly group: 0; }, { readonly name: "velocityTexture"; readonly group: 0; }, { readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "previousDepthTexture"; readonly group: 0; }]; readonly props: Partial & SSRTemporalBindings; readonly uniforms: SSRTemporalUniforms; readonly bindings: SSRTemporalBindings; readonly uniformTypes: { readonly inverseProjectionMatrix: "mat4x4"; readonly historyWeight: "f32"; readonly depthThreshold: "f32"; }; readonly propTypes: { readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly historyWeight: { readonly value: 0.86; readonly min: 0; readonly max: 0.97; }; readonly depthThreshold: { readonly value: 0.018; readonly min: 0.0001; readonly softMax: 0.1; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Saves the current scene depth for next-frame reflection disocclusion rejection. */ export declare const ssrDepthHistoryCopy: { readonly name: "ssrDepthHistoryCopy"; readonly source: "@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n\nfn ssrDepthHistoryCopy_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let depth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n return vec4f(depth, 0.0, 0.0, 1.0);\n}"; readonly bindingLayout: readonly [{ readonly name: "depthTexture"; readonly group: 0; }]; readonly passes: [{ readonly sampler: true; }]; }; /** Applies roughness-adaptive, depth/normal-aware reflection denoising in one direction. */ export declare const ssrSpatial: { readonly name: "ssrSpatial"; readonly source: "struct SSRSpatialUniforms {\n inverseProjectionMatrix: mat4x4f,\n direction: vec2f,\n maxRadius: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var ssrSpatial: SSRSpatialUniforms;\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 ssrSpatial_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrSpatial.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrSpatial_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let centerReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let centerNormalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0);\n let roughness = clamp(centerNormalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return vec4f(0.0);\n }\n let centerViewDepth = ssrSpatial_reconstructViewDepth(texCoord, centerDepth);\n let hasCenterReflection = centerReflection.a > 0.001;\n if (!hasCenterReflection && roughness >= 0.28) {\n return centerReflection;\n }\n let minimumRadius = select(5.0, 0.95, hasCenterReflection);\n let radius = clamp(\n max(roughness * roughness * ssrSpatial.maxRadius, minimumRadius),\n minimumRadius,\n 6.0\n );\n\n let centerNormal = normalize(centerNormalRoughness.rgb * 2.0 - 1.0);\n let texel = ssrSpatial.direction / vec2f(textureDimensions(sourceTexture));\n let centerWeight = select(0.0, 1.0, hasCenterReflection);\n var reflection = centerReflection * centerWeight;\n var totalWeight = centerWeight;\n var supportingSampleCount = 0u;\n for (var sampleIndex: i32 = 1; sampleIndex <= 6; sampleIndex++) {\n if (f32(sampleIndex) > ceil(radius)) {\n break;\n }\n for (var side: i32 = -1; side <= 1; side += 2) {\n let sampleCoord = clamp(\n texCoord + texel * f32(sampleIndex * side),\n vec2f(0.0),\n vec2f(1.0)\n );\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let sampleViewDepth = ssrSpatial_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrSpatial.depthSigma * ssrSpatial.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 16.0);\n let distanceWeight = exp(\n -f32(sampleIndex * sampleIndex) / max(2.0 * radius * radius, 0.1)\n );\n let sampleReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoord, 0);\n let confidenceWeight = smoothstep(0.001, 0.12, sampleReflection.a);\n let belongsToSamePlane = dot(centerNormal, sampleNormal) > 0.9995;\n let surfaceWeight = select(0.0, 1.0, hasCenterReflection || belongsToSamePlane);\n let weight = depthWeight * normalWeight * distanceWeight * confidenceWeight * surfaceWeight;\n if (weight > 0.001) {\n supportingSampleCount += 1u;\n }\n reflection += sampleReflection * weight;\n totalWeight += weight;\n }\n }\n\n if ((!hasCenterReflection && supportingSampleCount < 2u) || totalWeight <= 0.0001) {\n return centerReflection;\n }\n return reflection / totalWeight;\n}"; readonly bindingLayout: readonly [{ readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "normalTexture"; readonly group: 0; }]; readonly props: Partial & SSRSpatialBindings; readonly uniforms: SSRSpatialUniforms; readonly bindings: SSRSpatialBindings; readonly uniformTypes: { readonly inverseProjectionMatrix: "mat4x4"; readonly direction: "vec2"; readonly maxRadius: "f32"; readonly depthSigma: "f32"; }; readonly propTypes: { readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly direction: { readonly value: readonly [1, 0]; }; readonly maxRadius: { readonly value: 5; readonly min: 0; readonly max: 8; }; readonly depthSigma: { readonly value: 0.035; readonly min: 0.0001; readonly softMax: 0.2; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Composes stabilized reflection radiance or exposes reflection/confidence debug views. */ export declare const ssrComposite: { readonly name: "ssrComposite"; readonly source: "struct SSRCompositeUniforms {\n inverseProjectionMatrix: mat4x4f,\n strength: f32,\n debugMode: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var ssrComposite: SSRCompositeUniforms;\n@group(0) @binding(auto) var reflectionTexture: texture_2d;\n@group(0) @binding(auto) var reflectionTextureSampler: sampler;\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 ssrComposite_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrComposite.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrComposite_upsampleReflection(texCoord: vec2f) -> vec4f {\n let reflectionSize = vec2f(textureDimensions(reflectionTexture));\n let reflectionPosition = texCoord * reflectionSize - vec2f(0.5);\n let reflectionBase = vec2i(floor(reflectionPosition));\n let reflectionFraction = fract(reflectionPosition);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return textureSampleLevel(reflectionTexture, reflectionTextureSampler, texCoord, 0);\n }\n let centerViewDepth = ssrComposite_reconstructViewDepth(texCoord, centerDepth);\n let centerNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0).rgb * 2.0 - 1.0\n );\n\n var reflection = vec4f(0.0);\n var totalWeight = 0.0;\n for (var sampleY: i32 = 0; sampleY <= 1; sampleY++) {\n for (var sampleX: i32 = 0; sampleX <= 1; sampleX++) {\n let reflectionPixel = clamp(\n reflectionBase + vec2i(sampleX, sampleY),\n vec2i(0),\n vec2i(reflectionSize) - vec2i(1)\n );\n let sampleCoord = (vec2f(reflectionPixel) + vec2f(0.5)) / reflectionSize;\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let horizontalWeight = select(\n 1.0 - reflectionFraction.x,\n reflectionFraction.x,\n sampleX == 1\n );\n let verticalWeight = select(\n 1.0 - reflectionFraction.y,\n reflectionFraction.y,\n sampleY == 1\n );\n let sampleViewDepth = ssrComposite_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrComposite.depthSigma * ssrComposite.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 12.0);\n let weight = horizontalWeight * verticalWeight * depthWeight * normalWeight;\n reflection += textureLoad(reflectionTexture, reflectionPixel, 0) * weight;\n totalWeight += weight;\n }\n }\n return reflection / max(totalWeight, 0.00001);\n}\n\nfn ssrComposite_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let color = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let reflection = ssrComposite_upsampleReflection(texCoord);\n if (ssrComposite.debugMode > 1.5) {\n let confidence = clamp(reflection.a, 0.0, 1.0);\n let lowConfidence = vec3f(0.045, 0.08, 0.22);\n let highConfidence = vec3f(1.0, 0.7, 0.16);\n return vec4f(mix(lowConfidence, highConfidence, confidence), 1.0);\n }\n if (ssrComposite.debugMode > 0.5) {\n return vec4f(reflection.rgb * reflection.a, 1.0);\n }\n let reflectionWeight = clamp(reflection.a * ssrComposite.strength, 0.0, 1.0);\n return vec4f(color.rgb + reflection.rgb * reflectionWeight, color.a);\n}"; readonly bindingLayout: readonly [{ readonly name: "reflectionTexture"; readonly group: 0; }, { readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "normalTexture"; readonly group: 0; }]; readonly props: Partial & SSRCompositeBindings; readonly uniforms: SSRCompositeUniforms; readonly bindings: SSRCompositeBindings; readonly uniformTypes: { readonly inverseProjectionMatrix: "mat4x4"; readonly strength: "f32"; readonly debugMode: "f32"; readonly depthSigma: "f32"; }; readonly propTypes: { readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly strength: { readonly value: 1; readonly min: 0; readonly softMax: 2; }; readonly debugMode: { readonly value: 0; readonly min: 0; readonly max: 2; readonly private: true; }; readonly depthSigma: { readonly value: 0.04; readonly min: 0.0001; readonly softMax: 0.2; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Creates a roughness-aware, temporally stabilized screen-space reflection pipeline. */ export declare function createSSRShaderPassPipeline(options?: SSRShaderPassPipelineOptions): ShaderPassPipeline<'ssrRaw' | 'ssrHistory' | 'ssrHistoryDepth' | 'ssrScratch' | 'ssrReflection'>; export {}; //# sourceMappingURL=screen-space-reflections.d.ts.map