import type { Texture } from '@luma.gl/core'; import type { ShaderPassPipeline } from '@luma.gl/shadertools'; import type { NumberArray16 } from '@math.gl/core'; /** Uniforms needed to reproject a static-world pixel into the previous camera frame. */ export type CameraReprojectionTAAUniforms = { /** * Inverse of the current unjittered view-projection matrix. * Jitter is supplied separately in UV units. */ inverseViewProjectionMatrix: Readonly; /** Previous unjittered view-projection matrix. */ previousViewProjectionMatrix: Readonly; /** Fraction of validated history blended into the current frame. */ historyWeight: number; /** Maximum normalized-device-depth disagreement before history is rejected. */ depthThreshold: number; /** Current projection jitter in UV units. */ currentJitter: [number, number]; /** Previous projection jitter in UV units. */ previousJitter: [number, number]; }; type CameraReprojectionTAABindings = { depthTexture?: Texture; historyTexture?: Texture; previousDepthTexture?: Texture; }; /** * Reprojects current depth into a previous camera frame, rejecting disoccluded history. * * This is intentionally camera-only. Moving objects need a velocity-aware pass or their * history must be reset by the caller. */ export declare const cameraReprojectionTaaResolve: { readonly name: "cameraReprojectionTaaResolve"; readonly source: "const CAMERA_REPROJECTION_TAA_EPSILON: f32 = 0.00001;\n\nstruct CameraReprojectionTaaResolveUniforms {\n inverseViewProjectionMatrix: mat4x4f,\n previousViewProjectionMatrix: mat4x4f,\n historyWeight: f32,\n depthThreshold: f32,\n currentJitter: vec2f,\n previousJitter: vec2f,\n};\n\n@group(0) @binding(auto) var cameraReprojectionTaaResolve:\n CameraReprojectionTaaResolveUniforms;\n@group(0) @binding(auto) var historyTexture: texture_2d;\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 cameraReprojectionTaaResolve_previousFrameCoordinate(\n texCoord: vec2f,\n depth: f32\n) -> vec4f {\n let unjitteredCoordinate = texCoord - cameraReprojectionTaaResolve.currentJitter;\n if (any(unjitteredCoordinate < vec2f(0.0)) ||\n any(unjitteredCoordinate > vec2f(1.0))) {\n return vec4f(0.0);\n }\n\n let currentClip = vec4f(\n unjitteredCoordinate.x * 2.0 - 1.0,\n 1.0 - unjitteredCoordinate.y * 2.0,\n depth,\n 1.0\n );\n let worldPositionHomogeneous =\n cameraReprojectionTaaResolve.inverseViewProjectionMatrix * currentClip;\n if (abs(worldPositionHomogeneous.w) <= CAMERA_REPROJECTION_TAA_EPSILON) {\n return vec4f(0.0);\n }\n\n let worldPosition = worldPositionHomogeneous.xyz / worldPositionHomogeneous.w;\n let previousClip =\n cameraReprojectionTaaResolve.previousViewProjectionMatrix * vec4f(worldPosition, 1.0);\n if (previousClip.w <= CAMERA_REPROJECTION_TAA_EPSILON) {\n return vec4f(0.0);\n }\n\n let previousNormalizedDeviceCoordinate = previousClip.xyz / previousClip.w;\n let previousCoordinate =\n previousNormalizedDeviceCoordinate.xy * vec2f(0.5, -0.5) +\n vec2f(0.5) +\n cameraReprojectionTaaResolve.previousJitter;\n let expectedPreviousDepth = previousNormalizedDeviceCoordinate.z;\n let validCoordinate = all(previousCoordinate >= vec2f(0.0)) &&\n all(previousCoordinate <= vec2f(1.0));\n let validDepthRange = expectedPreviousDepth >= 0.0 && expectedPreviousDepth <= 1.0;\n return vec4f(\n previousCoordinate,\n expectedPreviousDepth,\n select(0.0, 1.0, validCoordinate && validDepthRange)\n );\n}\n\nfn cameraReprojectionTaaResolve_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let currentColor = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let currentDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (currentDepth >= 0.99999) {\n return currentColor;\n }\n\n let previousFrame = cameraReprojectionTaaResolve_previousFrameCoordinate(\n texCoord,\n currentDepth\n );\n if (previousFrame.w < 0.5) {\n return currentColor;\n }\n\n let sourceTexel = 1.0 / vec2f(textureDimensions(sourceTexture));\n var minimumColor = currentColor.rgb;\n var maximumColor = currentColor.rgb;\n for (var sampleY: i32 = -1; sampleY <= 1; sampleY++) {\n for (var sampleX: i32 = -1; sampleX <= 1; sampleX++) {\n let sampleCoordinate = clamp(\n texCoord + vec2f(f32(sampleX), f32(sampleY)) * sourceTexel,\n vec2f(0.0),\n vec2f(1.0)\n );\n let sampleColor = textureSampleLevel(\n sourceTexture,\n sourceTextureSampler,\n sampleCoordinate,\n 0\n ).rgb;\n minimumColor = min(minimumColor, sampleColor);\n maximumColor = max(maximumColor, sampleColor);\n }\n }\n\n let historyDimensions = textureDimensions(historyTexture);\n let historyPosition = previousFrame.xy * vec2f(historyDimensions) - vec2f(0.5);\n let baseHistoryCoordinate = vec2i(floor(historyPosition));\n let historyFraction = fract(historyPosition);\n var accumulatedHistoryColor = vec3f(0.0);\n var accumulatedHistoryWeight = 0.0;\n for (var tapY: i32 = 0; tapY <= 1; tapY++) {\n for (var tapX: i32 = 0; tapX <= 1; tapX++) {\n let historyCoordinate = clamp(\n baseHistoryCoordinate + vec2i(tapX, tapY),\n vec2i(0),\n vec2i(historyDimensions) - vec2i(1)\n );\n let tapDepth = textureLoad(previousDepthTexture, historyCoordinate, 0).r;\n let validTapDepth =\n abs(tapDepth - previousFrame.z) <= cameraReprojectionTaaResolve.depthThreshold;\n let horizontalWeight = select(1.0 - historyFraction.x, historyFraction.x, tapX == 1);\n let verticalWeight = select(1.0 - historyFraction.y, historyFraction.y, tapY == 1);\n let tapWeight = select(0.0, horizontalWeight * verticalWeight, validTapDepth);\n accumulatedHistoryColor += textureLoad(historyTexture, historyCoordinate, 0).rgb *\n tapWeight;\n accumulatedHistoryWeight += tapWeight;\n }\n }\n\n if (accumulatedHistoryWeight <= CAMERA_REPROJECTION_TAA_EPSILON) {\n return currentColor;\n }\n\n let historyColor = accumulatedHistoryColor / accumulatedHistoryWeight;\n let clampedHistoryColor = clamp(historyColor, minimumColor, maximumColor);\n let resolvedColor = mix(\n currentColor.rgb,\n clampedHistoryColor,\n cameraReprojectionTaaResolve.historyWeight\n );\n return vec4f(resolvedColor, currentColor.a);\n}"; readonly bindingLayout: readonly [{ readonly name: "historyTexture"; readonly group: 0; }, { readonly name: "depthTexture"; readonly group: 0; }, { readonly name: "previousDepthTexture"; readonly group: 0; }]; readonly props: Partial & CameraReprojectionTAABindings; readonly uniforms: CameraReprojectionTAAUniforms; readonly bindings: CameraReprojectionTAABindings; readonly uniformTypes: { readonly inverseViewProjectionMatrix: "mat4x4"; readonly previousViewProjectionMatrix: "mat4x4"; readonly historyWeight: "f32"; readonly depthThreshold: "f32"; readonly currentJitter: "vec2"; readonly previousJitter: "vec2"; }; readonly propTypes: { readonly inverseViewProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly previousViewProjectionMatrix: { readonly value: NumberArray16; readonly private: true; }; readonly historyWeight: { readonly value: 0.9; readonly min: 0; readonly max: 0.98; }; readonly depthThreshold: { readonly value: 0.0025; readonly min: 0.00001; readonly softMax: 0.05; }; readonly currentJitter: { readonly value: readonly [0, 0]; readonly private: true; }; readonly previousJitter: { readonly value: readonly [0, 0]; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; }]; }; /** Copies current device depth into a filterable history texture for the next frame. */ export declare const cameraReprojectionTaaDepthHistoryCopy: { readonly name: "cameraReprojectionTaaDepthHistoryCopy"; readonly source: "@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n\nfn cameraReprojectionTaaDepthHistoryCopy_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; }]; }; /** * Creates a full-resolution HDR camera-reprojection TAA pipeline. * * The caller must bind current depth and update both matrices/jitter every frame. Reset the * renderer history after resize, camera cuts, or moving-object topology changes. */ export declare function createCameraReprojectionTAAShaderPassPipeline(): ShaderPassPipeline<'cameraReprojectionTaaHistoryColor' | 'cameraReprojectionTaaHistoryDepth'>; export {}; //# sourceMappingURL=camera-reprojection-temporal-antialiasing.d.ts.map