import type { Buffer, Texture } from '@luma.gl/core'; import type { ShaderPassPipeline } from '@luma.gl/shadertools'; import type { NumberArray3, NumberArray16 } from '@math.gl/core'; /** Construction options for clustered participating-media integration. */ export type ClusteredVolumetricLightingShaderPassPipelineOptions = { /** Fractional integration, history, and denoising resolution. Defaults to full resolution. */ resolutionScale?: number; }; type ClusteredVolumetricTraceUniforms = { projectionMatrix: Readonly; inverseProjectionMatrix: Readonly; inverseViewMatrix: Readonly; directionalLightDirectionView: Readonly; directionalLightColor: Readonly; fogColor: Readonly; godRayPosition: readonly [number, number]; density: number; heightFalloff: number; fogHeight: number; anisotropy: number; directionalIntensity: number; pointLightIntensity: number; godRayIntensity: number; godRayDensity: number; godRayDecay: number; godRaySampleCount: number; godRaysOnly: number; maxDistance: number; sampleCount: number; shadowStrength: number; clusterCountX: number; clusterCountY: number; clusterCountZ: number; maxLightsPerCluster: number; pointLightCount: number; clusterNearPlane: number; clusterFarPlane: number; }; type ClusteredVolumetricTemporalUniforms = { inverseProjectionMatrix: Readonly; inverseViewProjectionMatrix: Readonly; previousViewProjectionMatrix: Readonly; historyWeight: number; depthThreshold: number; }; type ClusteredVolumetricDepthHistoryCopyUniforms = { inverseProjectionMatrix: Readonly; }; type ClusteredVolumetricCompositeUniforms = { strength: number; debugMode: number; }; type ClusteredVolumetricTraceBindings = { depthTexture?: Texture; pointLights?: Buffer; clusterLightCounts?: Buffer; clusterLightIndices?: Buffer; }; type ClusteredVolumetricTemporalBindings = { depthTexture?: Texture; velocityTexture?: Texture; historyTexture?: Texture; previousDepthTexture?: Texture; }; /** Integrates real clustered point lights and occluded directional light through height fog. */ export declare const clusteredVolumetricTrace: { readonly name: "clusteredVolumetricTrace"; readonly source: "const CLUSTERED_VOLUMETRIC_PI: f32 = 3.141592653589793;\nconst CLUSTERED_VOLUMETRIC_MAX_STEPS: u32 = 20u;\nconst CLUSTERED_VOLUMETRIC_MAX_LIGHTS: u32 = 10u;\nconst CLUSTERED_VOLUMETRIC_MAX_GOD_RAY_STEPS: u32 = 32u;\n\nstruct ClusteredVolumetricTraceUniforms {\n projectionMatrix: mat4x4f,\n inverseProjectionMatrix: mat4x4f,\n inverseViewMatrix: mat4x4f,\n directionalLightDirectionView: vec3f,\n directionalLightColor: vec3f,\n fogColor: vec3f,\n godRayPosition: vec2f,\n density: f32,\n heightFalloff: f32,\n fogHeight: f32,\n anisotropy: f32,\n directionalIntensity: f32,\n pointLightIntensity: f32,\n godRayIntensity: f32,\n godRayDensity: f32,\n godRayDecay: f32,\n godRaySampleCount: f32,\n godRaysOnly: f32,\n maxDistance: f32,\n sampleCount: f32,\n shadowStrength: f32,\n clusterCountX: u32,\n clusterCountY: u32,\n clusterCountZ: u32,\n maxLightsPerCluster: u32,\n pointLightCount: u32,\n clusterNearPlane: f32,\n clusterFarPlane: f32,\n};\n\nstruct ClusteredVolumetricPointLight {\n positionRange: vec4f,\n colorIntensity: vec4f,\n};\n\n@group(0) @binding(auto) var clusteredVolumetricTrace:\n ClusteredVolumetricTraceUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var pointLights:\n array;\n@group(0) @binding(auto) var clusterLightCounts: array;\n@group(0) @binding(auto) var clusterLightIndices: array;\n\nfn clusteredVolumetricTrace_reconstructViewPosition(texCoord: vec2f, depth: f32) -> vec3f {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = clusteredVolumetricTrace.inverseProjectionMatrix * clip;\n return viewPosition.xyz / max(abs(viewPosition.w), 0.00001);\n}\n\nfn clusteredVolumetricTrace_projectViewPosition(viewPosition: vec3f) -> vec2f {\n let clip = clusteredVolumetricTrace.projectionMatrix * vec4f(viewPosition, 1.0);\n let normalizedDeviceCoordinate = clip.xy / max(clip.w, 0.00001);\n return normalizedDeviceCoordinate * vec2f(0.5, -0.5) + vec2f(0.5);\n}\n\nfn clusteredVolumetricTrace_phase(cosine: f32, anisotropy: f32) -> f32 {\n let squaredAnisotropy = anisotropy * anisotropy;\n let denominator = max(1.0 + squaredAnisotropy - 2.0 * anisotropy * cosine, 0.02);\n return (1.0 - squaredAnisotropy) /\n (4.0 * CLUSTERED_VOLUMETRIC_PI * pow(denominator, 1.5));\n}\n\nfn clusteredVolumetricTrace_clusterIndex(texCoord: vec2f, viewDepth: f32) -> u32 {\n let tileX = min(\n u32(clamp(texCoord.x, 0.0, 0.999999) * f32(clusteredVolumetricTrace.clusterCountX)),\n clusteredVolumetricTrace.clusterCountX - 1u\n );\n let tileY = min(\n u32(clamp(texCoord.y, 0.0, 0.999999) * f32(clusteredVolumetricTrace.clusterCountY)),\n clusteredVolumetricTrace.clusterCountY - 1u\n );\n let normalizedDepth = clamp(\n log(max(viewDepth, clusteredVolumetricTrace.clusterNearPlane) /\n clusteredVolumetricTrace.clusterNearPlane) /\n log(clusteredVolumetricTrace.clusterFarPlane /\n clusteredVolumetricTrace.clusterNearPlane),\n 0.0,\n 0.999999\n );\n let tileZ = min(\n u32(normalizedDepth * f32(clusteredVolumetricTrace.clusterCountZ)),\n clusteredVolumetricTrace.clusterCountZ - 1u\n );\n return tileX + clusteredVolumetricTrace.clusterCountX *\n (tileY + clusteredVolumetricTrace.clusterCountY * tileZ);\n}\n\nfn clusteredVolumetricTrace_directionalVisibility(viewPosition: vec3f) -> f32 {\n let lightDirection = normalize(clusteredVolumetricTrace.directionalLightDirectionView);\n for (var shadowStep: u32 = 1u; shadowStep <= 3u; shadowStep++) {\n let shadowPosition = viewPosition + lightDirection * (0.32 + f32(shadowStep) * 0.95);\n if (shadowPosition.z >= -0.04) {\n return 1.0;\n }\n let shadowCoord = clusteredVolumetricTrace_projectViewPosition(shadowPosition);\n if (any(shadowCoord <= vec2f(0.0)) || any(shadowCoord >= vec2f(1.0))) {\n return 1.0;\n }\n let occluderDepth = textureSampleLevel(depthTexture, depthTextureSampler, shadowCoord, 0);\n if (occluderDepth >= 0.99999) {\n continue;\n }\n let occluderPosition = clusteredVolumetricTrace_reconstructViewPosition(\n shadowCoord,\n occluderDepth\n );\n let depthBehindOccluder = -shadowPosition.z - (-occluderPosition.z);\n if (depthBehindOccluder > 0.06 && depthBehindOccluder < 1.9) {\n return 1.0 - clusteredVolumetricTrace.shadowStrength;\n }\n }\n return 1.0;\n}\n\nfn clusteredVolumetricTrace_godRayVisibility(texCoord: vec2f) -> f32 {\n if (clusteredVolumetricTrace.godRayIntensity <= 0.0001) {\n return 0.0;\n }\n\n let sampleCount = clamp(\n u32(clusteredVolumetricTrace.godRaySampleCount),\n 3u,\n CLUSTERED_VOLUMETRIC_MAX_GOD_RAY_STEPS\n );\n let sampleOffset = (texCoord - clusteredVolumetricTrace.godRayPosition) *\n clusteredVolumetricTrace.godRayDensity / f32(sampleCount);\n var sampleCoord = texCoord;\n var illumination = 0.0;\n var totalWeight = 0.0;\n var illuminationDecay = 1.0;\n\n for (var sampleIndex: u32 = 0u;\n sampleIndex < CLUSTERED_VOLUMETRIC_MAX_GOD_RAY_STEPS;\n sampleIndex++) {\n if (sampleIndex >= sampleCount) {\n break;\n }\n sampleCoord -= sampleOffset;\n if (any(sampleCoord < vec2f(0.0)) || any(sampleCoord > vec2f(1.0))) {\n break;\n }\n let occluderDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let visibility = smoothstep(0.9985, 0.99999, occluderDepth);\n illumination += visibility * illuminationDecay;\n totalWeight += illuminationDecay;\n illuminationDecay *= clusteredVolumetricTrace.godRayDecay;\n }\n\n let distanceFromSun = distance(texCoord, clusteredVolumetricTrace.godRayPosition);\n return illumination / max(totalWeight, 0.0001) * exp(-distanceFromSun * 1.6);\n}\n\nfn clusteredVolumetricTrace_pointRadiance(\n texCoord: vec2f,\n viewPosition: vec3f,\n viewDirection: vec3f\n) -> vec3f {\n let clusterIndex = clusteredVolumetricTrace_clusterIndex(texCoord, -viewPosition.z);\n let clusterCount = clusterLightCounts[clusterIndex];\n let firstCandidateIndex = clusterIndex * clusteredVolumetricTrace.maxLightsPerCluster;\n let clampedFirstCandidateIndex = min(firstCandidateIndex, arrayLength(&clusterLightIndices));\n let storedCandidateCapacity = min(\n clusteredVolumetricTrace.maxLightsPerCluster,\n arrayLength(&clusterLightIndices) - clampedFirstCandidateIndex\n );\n let candidateCount = min(clusterCount, storedCandidateCapacity);\n let activePointLightCount = min(\n clusteredVolumetricTrace.pointLightCount,\n arrayLength(&pointLights)\n );\n var selectedLightIndices: array;\n var selectedLightScores: array;\n for (var slotIndex: u32 = 0u; slotIndex < CLUSTERED_VOLUMETRIC_MAX_LIGHTS; slotIndex++) {\n selectedLightIndices[slotIndex] = 0xffffffffu;\n selectedLightScores[slotIndex] = 1.0e20;\n }\n var selectedLightCount = 0u;\n var worstSlotIndex = 0u;\n var worstScore = -1.0;\n\n // Score every candidate retained by the cluster builder, including its complete overflow-safe\n // storage capacity, while keeping integration work independent of the global light count.\n for (var candidateIndex: u32 = 0u; candidateIndex < candidateCount; candidateIndex++) {\n let lightIndex = clusterLightIndices[firstCandidateIndex + candidateIndex];\n if (lightIndex >= activePointLightCount) {\n continue;\n }\n let light = pointLights[lightIndex];\n let toLight = light.positionRange.xyz - viewPosition;\n let distanceSquared = dot(toLight, toLight);\n let rangeSquared = light.positionRange.w * light.positionRange.w;\n if (distanceSquared >= rangeSquared || distanceSquared <= 0.0004) {\n continue;\n }\n let lightScore = distanceSquared /\n max(rangeSquared * max(light.colorIntensity.a, 0.05), 0.0001);\n if (selectedLightCount < CLUSTERED_VOLUMETRIC_MAX_LIGHTS) {\n selectedLightIndices[selectedLightCount] = lightIndex;\n selectedLightScores[selectedLightCount] = lightScore;\n if (lightScore > worstScore) {\n worstSlotIndex = selectedLightCount;\n worstScore = lightScore;\n }\n selectedLightCount += 1u;\n continue;\n }\n if (lightScore < worstScore) {\n selectedLightIndices[worstSlotIndex] = lightIndex;\n selectedLightScores[worstSlotIndex] = lightScore;\n worstSlotIndex = 0u;\n worstScore = selectedLightScores[0];\n for (var slotIndex = 1u; slotIndex < CLUSTERED_VOLUMETRIC_MAX_LIGHTS; slotIndex++) {\n if (selectedLightScores[slotIndex] > worstScore) {\n worstSlotIndex = slotIndex;\n worstScore = selectedLightScores[slotIndex];\n }\n }\n }\n }\n\n var radiance = vec3f(0.0);\n for (var slotIndex: u32 = 0u; slotIndex < CLUSTERED_VOLUMETRIC_MAX_LIGHTS; slotIndex++) {\n let lightIndex = selectedLightIndices[slotIndex];\n if (lightIndex >= arrayLength(&pointLights)) {\n continue;\n }\n let light = pointLights[lightIndex];\n let toLight = light.positionRange.xyz - viewPosition;\n let distanceToLight = length(toLight);\n if (distanceToLight >= light.positionRange.w || distanceToLight <= 0.02) {\n continue;\n }\n let lightDirection = toLight / distanceToLight;\n let rangeFade = pow(1.0 - distanceToLight / light.positionRange.w, 2.0);\n let attenuation = rangeFade / (1.0 + distanceToLight * distanceToLight * 0.1);\n let phase = clusteredVolumetricTrace_phase(\n dot(viewDirection, lightDirection),\n clusteredVolumetricTrace.anisotropy * 0.65\n );\n radiance += light.colorIntensity.rgb * light.colorIntensity.a *\n attenuation * phase * clusteredVolumetricTrace.pointLightIntensity;\n }\n return radiance;\n}\n\nfn clusteredVolumetricTrace_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n if (clusteredVolumetricTrace.density <= 0.0001) {\n return vec4f(0.0, 0.0, 0.0, 1.0);\n }\n let sceneDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n let rayOrigin = clusteredVolumetricTrace_reconstructViewPosition(texCoord, 0.0);\n let farPosition = clusteredVolumetricTrace_reconstructViewPosition(texCoord, 0.9999);\n let viewDirection = normalize(farPosition - rayOrigin);\n let scenePosition = clusteredVolumetricTrace_reconstructViewPosition(texCoord, sceneDepth);\n let rayDistance = select(\n min(\n max(dot(scenePosition - rayOrigin, viewDirection), 0.0),\n clusteredVolumetricTrace.maxDistance\n ),\n clusteredVolumetricTrace.maxDistance,\n sceneDepth >= 0.99999\n );\n let stepCount = clamp(u32(clusteredVolumetricTrace.sampleCount), 3u,\n CLUSTERED_VOLUMETRIC_MAX_STEPS);\n let stepDistance = rayDistance / f32(stepCount);\n let pixelCoordinate = floor(texCoord * texSize);\n let rayJitter = fract(sin(dot(pixelCoordinate, vec2f(12.9898, 78.233))) * 43758.5453);\n let directionalPhase = clusteredVolumetricTrace_phase(\n dot(viewDirection, normalize(clusteredVolumetricTrace.directionalLightDirectionView)),\n clusteredVolumetricTrace.anisotropy\n );\n let godRayVisibility = clusteredVolumetricTrace_godRayVisibility(texCoord);\n\n var opticalDepth = 0.0;\n var scattering = vec3f(0.0);\n for (var stepIndex: u32 = 0u; stepIndex < CLUSTERED_VOLUMETRIC_MAX_STEPS; stepIndex++) {\n if (stepIndex >= stepCount) {\n break;\n }\n let travel = (f32(stepIndex) + 0.28 + rayJitter * 0.52) * stepDistance;\n let viewPosition = rayOrigin + viewDirection * travel;\n let worldPosition =\n (clusteredVolumetricTrace.inverseViewMatrix * vec4f(viewPosition, 1.0)).xyz;\n let localDensity = clusteredVolumetricTrace.density * exp(\n -max(worldPosition.y - clusteredVolumetricTrace.fogHeight, 0.0) *\n clusteredVolumetricTrace.heightFalloff\n );\n let extinction = localDensity * stepDistance;\n opticalDepth += extinction;\n let directionalVisibility = clusteredVolumetricTrace_directionalVisibility(viewPosition);\n let directionalRadiance = clusteredVolumetricTrace.directionalLightColor *\n clusteredVolumetricTrace.directionalIntensity * directionalPhase * directionalVisibility;\n let godRayRadiance = clusteredVolumetricTrace.directionalLightColor *\n clusteredVolumetricTrace.directionalIntensity * directionalPhase * godRayVisibility *\n clusteredVolumetricTrace.godRayIntensity * 2.4;\n let localRadiance = clusteredVolumetricTrace_pointRadiance(\n texCoord,\n viewPosition,\n viewDirection\n );\n let incomingRadiance = select(\n clusteredVolumetricTrace.fogColor * 0.11 + directionalRadiance + localRadiance +\n godRayRadiance,\n godRayRadiance,\n clusteredVolumetricTrace.godRaysOnly > 0.5\n );\n scattering += incomingRadiance * extinction * exp(-opticalDepth);\n }\n\n return vec4f(scattering, clamp(exp(-opticalDepth), 0.0, 1.0));\n}"; readonly bindingLayout: readonly [{ readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "pointLights"; readonly group: 0; }, { readonly name: "clusterLightCounts"; readonly group: 0; }, { readonly name: "clusterLightIndices"; readonly group: 0; }]; readonly props: Partial & ClusteredVolumetricTraceBindings; readonly uniforms: ClusteredVolumetricTraceUniforms; readonly bindings: ClusteredVolumetricTraceBindings; readonly uniformTypes: { readonly projectionMatrix: "mat4x4"; readonly inverseProjectionMatrix: "mat4x4"; readonly inverseViewMatrix: "mat4x4"; readonly directionalLightDirectionView: "vec3"; readonly directionalLightColor: "vec3"; readonly fogColor: "vec3"; readonly godRayPosition: "vec2"; readonly density: "f32"; readonly heightFalloff: "f32"; readonly fogHeight: "f32"; readonly anisotropy: "f32"; readonly directionalIntensity: "f32"; readonly pointLightIntensity: "f32"; readonly godRayIntensity: "f32"; readonly godRayDensity: "f32"; readonly godRayDecay: "f32"; readonly godRaySampleCount: "f32"; readonly godRaysOnly: "f32"; readonly maxDistance: "f32"; readonly sampleCount: "f32"; readonly shadowStrength: "f32"; readonly clusterCountX: "u32"; readonly clusterCountY: "u32"; readonly clusterCountZ: "u32"; readonly maxLightsPerCluster: "u32"; readonly pointLightCount: "u32"; readonly clusterNearPlane: "f32"; readonly clusterFarPlane: "f32"; }; readonly propTypes: { readonly projectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly inverseViewMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly directionalLightDirectionView: { readonly value: readonly [0.35, 0.82, 0.38]; readonly private: true; }; readonly directionalLightColor: { readonly value: readonly [1, 0.85, 0.66]; readonly private: true; }; readonly fogColor: { readonly value: readonly [0.18, 0.3, 0.48]; }; readonly godRayPosition: { readonly value: readonly [0.72, 0.16]; }; readonly density: { readonly value: 0.055; readonly min: 0; readonly softMax: 0.22; }; readonly heightFalloff: { readonly value: 0.23; readonly min: 0; readonly softMax: 2; }; readonly fogHeight: { readonly value: 0.2; readonly min: -5; readonly softMax: 5; }; readonly anisotropy: { readonly value: 0.45; readonly min: -0.8; readonly max: 0.85; }; readonly directionalIntensity: { readonly value: 2.2; readonly min: 0; readonly softMax: 8; }; readonly pointLightIntensity: { readonly value: 1.8; readonly min: 0; readonly softMax: 6; }; readonly godRayIntensity: { readonly value: 0; readonly min: 0; readonly softMax: 6; }; readonly godRayDensity: { readonly value: 0.94; readonly min: 0.1; readonly max: 1.2; }; readonly godRayDecay: { readonly value: 0.96; readonly min: 0.7; readonly max: 1; }; readonly godRaySampleCount: { readonly value: 18; readonly min: 3; readonly max: 32; }; readonly godRaysOnly: { readonly value: 0; readonly min: 0; readonly max: 1; readonly private: true; }; readonly maxDistance: { readonly value: 28; readonly min: 1; readonly softMax: 80; }; readonly sampleCount: { readonly value: 10; readonly min: 3; readonly max: 20; }; readonly shadowStrength: { readonly value: 0.74; readonly min: 0; readonly max: 1; }; readonly clusterCountX: { readonly value: 1; readonly private: true; }; readonly clusterCountY: { readonly value: 1; readonly private: true; }; readonly clusterCountZ: { readonly value: 1; readonly private: true; }; readonly maxLightsPerCluster: { readonly value: 1; readonly private: true; }; readonly pointLightCount: { readonly value: 0; readonly private: true; }; readonly clusterNearPlane: { readonly value: 0.1; readonly private: true; }; readonly clusterFarPlane: { readonly value: 100; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Reprojects participating-media radiance and rejects invalid linear-depth history. */ export declare const clusteredVolumetricTemporal: { readonly name: "clusteredVolumetricTemporal"; readonly source: "struct ClusteredVolumetricTemporalUniforms {\n inverseProjectionMatrix: mat4x4f,\n inverseViewProjectionMatrix: mat4x4f,\n previousViewProjectionMatrix: mat4x4f,\n historyWeight: f32,\n depthThreshold: f32,\n};\n\n@group(0) @binding(auto) var clusteredVolumetricTemporal:\n ClusteredVolumetricTemporalUniforms;\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\nfn clusteredVolumetricTemporal_viewDepth(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 = clusteredVolumetricTemporal.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn clusteredVolumetricTemporal_cameraPreviousCoord(texCoord: vec2f, depth: f32) -> vec3f {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let worldPosition = clusteredVolumetricTemporal.inverseViewProjectionMatrix * clip;\n let world = worldPosition.xyz / max(abs(worldPosition.w), 0.00001);\n let previousClip = clusteredVolumetricTemporal.previousViewProjectionMatrix * vec4f(world, 1.0);\n let previousNdc = previousClip.xy / max(abs(previousClip.w), 0.00001);\n let previousCoord = previousNdc * vec2f(0.5, -0.5) + vec2f(0.5);\n return vec3f(previousCoord, select(0.0, 1.0, previousClip.w > 0.00001));\n}\n\nfn clusteredVolumetricTemporal_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 let velocity = textureSampleLevel(velocityTexture, velocityTextureSampler, texCoord, 0).xy;\n let cameraReprojection = clusteredVolumetricTemporal_cameraPreviousCoord(texCoord, currentDepth);\n let velocityIsFinite = all(velocity == velocity) && all(abs(velocity) <= vec2f(1.0));\n let useObjectVelocity = currentDepth < 0.99999 && velocityIsFinite;\n let previousCoord = select(cameraReprojection.xy, texCoord - velocity, useObjectVelocity);\n let validCoordinate = all(previousCoord >= vec2f(0.0)) &&\n all(previousCoord <= vec2f(1.0)) &&\n (useObjectVelocity || cameraReprojection.z > 0.5);\n let clampedPreviousCoord = clamp(previousCoord, vec2f(0.0), vec2f(1.0));\n let previousDepthDimensions = textureDimensions(previousDepthTexture);\n let previousDepthCoordinate = min(\n vec2u(clampedPreviousCoord * vec2f(previousDepthDimensions)),\n previousDepthDimensions - vec2u(1u)\n );\n let currentViewDepth = clusteredVolumetricTemporal_viewDepth(texCoord, currentDepth);\n let previousViewDepth = textureLoad(\n previousDepthTexture,\n vec2i(previousDepthCoordinate),\n 0\n ).r;\n let relativeDepthDifference = abs(previousViewDepth - currentViewDepth) /\n max(currentViewDepth, 0.0001);\n let validDepth = previousViewDepth > 0.0 &&\n relativeDepthDifference < clusteredVolumetricTemporal.depthThreshold;\n\n let texel = 1.0 / vec2f(textureDimensions(sourceTexture));\n var minimumScattering = current;\n var maximumScattering = 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 sampleScattering = textureSampleLevel(\n sourceTexture,\n sourceTextureSampler,\n sampleCoord,\n 0\n );\n minimumScattering = min(minimumScattering, sampleScattering);\n maximumScattering = max(maximumScattering, sampleScattering);\n }\n }\n\n let history = clamp(\n textureSampleLevel(historyTexture, historyTextureSampler, clampedPreviousCoord, 0),\n minimumScattering,\n maximumScattering\n );\n let weight = select(\n 0.0,\n clusteredVolumetricTemporal.historyWeight,\n validCoordinate && validDepth\n );\n return mix(current, history, weight);\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 & ClusteredVolumetricTemporalBindings; readonly uniforms: ClusteredVolumetricTemporalUniforms; readonly bindings: ClusteredVolumetricTemporalBindings; readonly uniformTypes: { readonly inverseProjectionMatrix: "mat4x4"; readonly inverseViewProjectionMatrix: "mat4x4"; readonly previousViewProjectionMatrix: "mat4x4"; readonly historyWeight: "f32"; readonly depthThreshold: "f32"; }; readonly propTypes: { readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly inverseViewProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly previousViewProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly historyWeight: { readonly value: 0.88; readonly min: 0; readonly max: 0.97; }; readonly depthThreshold: { readonly value: 0.035; readonly min: 0.0001; readonly softMax: 0.2; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Captures current scene depth for atmospheric temporal disocclusion rejection. */ export declare const clusteredVolumetricDepthHistoryCopy: { readonly name: "clusteredVolumetricDepthHistoryCopy"; readonly source: "struct ClusteredVolumetricDepthHistoryCopyUniforms {\n inverseProjectionMatrix: mat4x4f,\n};\n\n@group(0) @binding(auto) var clusteredVolumetricDepthHistoryCopy:\n ClusteredVolumetricDepthHistoryCopyUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n\nfn clusteredVolumetricDepthHistoryCopy_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 let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = clusteredVolumetricDepthHistoryCopy.inverseProjectionMatrix * clip;\n let linearDepth = abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n return vec4f(linearDepth, 0.0, 0.0, 1.0);\n}"; readonly bindingLayout: readonly [{ readonly name: "depthTexture"; readonly group: 0; }]; readonly props: Partial; readonly uniforms: ClusteredVolumetricDepthHistoryCopyUniforms; readonly uniformTypes: { readonly inverseProjectionMatrix: "mat4x4"; }; readonly propTypes: { readonly inverseProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Applies atmospheric extinction and in-scattering, or exposes direct volume diagnostics. */ export declare const clusteredVolumetricComposite: { readonly name: "clusteredVolumetricComposite"; readonly source: "struct ClusteredVolumetricCompositeUniforms {\n strength: f32,\n debugMode: f32,\n};\n\n@group(0) @binding(auto) var clusteredVolumetricComposite:\n ClusteredVolumetricCompositeUniforms;\n@group(0) @binding(auto) var scatteringTexture: texture_2d;\n@group(0) @binding(auto) var scatteringTextureSampler: sampler;\n\nfn clusteredVolumetricComposite_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let source = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let scattering = textureSampleLevel(scatteringTexture, scatteringTextureSampler, texCoord, 0);\n if (clusteredVolumetricComposite.debugMode > 1.5) {\n return vec4f(vec3f(clamp(scattering.a, 0.0, 1.0)), 1.0);\n }\n if (clusteredVolumetricComposite.debugMode > 0.5) {\n return vec4f(scattering.rgb * 2.4, 1.0);\n }\n let strength = clamp(clusteredVolumetricComposite.strength, 0.0, 2.0);\n let transmittance = mix(1.0, clamp(scattering.a, 0.0, 1.0), min(strength, 1.0));\n return vec4f(source.rgb * transmittance + scattering.rgb * strength, source.a);\n}"; readonly bindingLayout: readonly [{ readonly name: "scatteringTexture"; readonly group: 0; }]; readonly props: Partial; readonly uniforms: ClusteredVolumetricCompositeUniforms; readonly uniformTypes: { readonly strength: "f32"; readonly debugMode: "f32"; }; readonly propTypes: { readonly strength: { readonly value: 0.9; readonly min: 0; readonly softMax: 2; }; readonly debugMode: { readonly value: 0; readonly min: 0; readonly max: 2; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Creates clustered participating-media integration, temporal stabilization, and composition. */ export declare function createClusteredVolumetricLightingShaderPassPipeline(options?: ClusteredVolumetricLightingShaderPassPipelineOptions): ShaderPassPipeline<'clusteredVolumeRaw' | 'clusteredVolumeHistory' | 'clusteredVolumeDepthHistory' | 'clusteredVolumeScratch' | 'clusteredVolumeScattering'>; export {}; //# sourceMappingURL=clustered-volumetric-lighting.d.ts.map