import * as THREE from 'three/webgpu'; import type { TSLVec4Node } from '../types/tsl.js'; export type VolumeSmokeUpsampling = 'bilateral' | 'bilinear'; export type VolumeSmokeOutputMode = 'safe-premultiplied' | 'unclamped-hdr'; interface VolumeSmokeRenderCompositorBaseOptions { scale?: number | undefined; upsampling?: VolumeSmokeUpsampling | undefined; outputMode?: VolumeSmokeOutputMode | undefined; historyWeight?: number | undefined; historyRejection?: number | undefined; depthSigma?: number | undefined; /** Borrowed full-resolution depth texture; the compositor never disposes it. */ depthTexture?: THREE.Texture | null | undefined; } export interface VolumeSmokeTemporalOptions extends VolumeSmokeRenderCompositorBaseOptions { temporal: true; /** Borrowed screen-space motion texture required for temporal reprojection. */ motionTexture: THREE.Texture; } export interface VolumeSmokeNonTemporalOptions extends VolumeSmokeRenderCompositorBaseOptions { temporal?: false | undefined; motionTexture?: THREE.Texture | null | undefined; } export type VolumeSmokeRenderCompositorOptions = VolumeSmokeTemporalOptions | VolumeSmokeNonTemporalOptions; /** Context passed while the compositor-owned scaled target is active. */ export interface VolumeSmokeScaledRenderContext { readonly renderer: THREE.Renderer; readonly target: THREE.RenderTarget; readonly width: number; readonly height: number; readonly scale: number; } export type VolumeSmokeScaledRenderCallback = (context: VolumeSmokeScaledRenderContext) => void; /** * Reconstructed smoke output for one frame. `target` and `texture` remain owned by the compositor; * callers may sample them until the compositor is resized, rendered again, or disposed. */ export interface VolumeSmokeRenderContext extends VolumeSmokeScaledRenderContext { readonly texture: THREE.Texture; readonly fullWidth: number; readonly fullHeight: number; readonly upsampling: VolumeSmokeUpsampling; readonly temporal: boolean; readonly outputMode: VolumeSmokeOutputMode; readonly premultipliedAlpha: true; } export type VolumeSmokeCompositeCallback = (context: VolumeSmokeRenderContext) => void; export interface VolumeSmokeRenderOptions { /** Borrowed per-frame full-resolution depth texture, or `null` to restore scaled depth. */ depthTexture?: THREE.Texture | null | undefined; /** Borrowed per-frame motion texture. A null value retains the runtime temporal error. */ motionTexture?: THREE.Texture | null | undefined; resetHistory?: boolean | undefined; /** Composite callback, `false` to leave the resolved color for a post graph, or omitted for the standalone quad. */ composite?: VolumeSmokeCompositeCallback | false | null | undefined; } /** * Scaled HDR rendering, depth-aware reconstruction, and guarded temporal accumulation for smoke volumes. * * Temporal accumulation is never enabled without an explicit screen-space motion texture. History is * reprojected, neighborhood-clamped, and rejected for out-of-bounds or strongly changed pixels. * * The renderer and option textures are borrowed. The scaled color/depth target, both history targets, * and both node materials are owned by this compositor and released by {@link dispose}. * * @class VolumeSmokeRenderCompositor * @short Scaled bilateral and temporal reconstruction for smoke volumes. * @category Materials */ export declare class VolumeSmokeRenderCompositor { /** Borrowed renderer; never disposed by the compositor. */ readonly renderer: THREE.Renderer; /** Compositor-owned scaled color/depth target. */ readonly target: THREE.RenderTarget; /** Fraction of full drawing-buffer resolution used by the smoke pass. */ scale: number; /** Reconstruction filter used when expanding the scaled smoke texture. */ readonly upsampling: VolumeSmokeUpsampling; /** Output range and alpha contract used by the resolved texture. */ readonly outputMode: VolumeSmokeOutputMode; /** Whether motion-reprojected temporal accumulation is enabled. */ readonly temporal: boolean; /** Maximum weight retained from valid reprojected history. */ readonly historyWeight: number; /** Difference threshold used to reject stale history. */ readonly historyRejection: number; /** Depth difference scale used by bilateral reconstruction. */ depthSigma: number; /** Width of the scaled smoke target in pixels. */ width: number; /** Height of the scaled smoke target in pixels. */ height: number; /** Full drawing-buffer width in pixels. */ fullWidth: number; /** Full drawing-buffer height in pixels. */ fullHeight: number; /** Full-resolution resolved premultiplied color for linear post-graph composition. */ readonly colorNode: TSLVec4Node; private readonly _scaledDepthTexture; private readonly _historyTargets; private _historyReadIndex; private _historyValid; private _disposed; private readonly _sourceNode; private readonly _scaledDepthNode; private readonly _fullDepthNode; private readonly _motionNode; private readonly _historyNode; private readonly _inverseScaledSize; private readonly _inverseFullSize; private readonly _depthSigma; private readonly _historyWeight; private readonly _historyRejection; private readonly _historyReset; private readonly _resolveMaterial; private readonly _resolveQuad; private readonly _compositeMaterial; private readonly _compositeOutputNode; private readonly _compositeQuad; /** Create a compositor that owns scaled, resolved, and optional history targets. */ constructor(renderer: THREE.Renderer, options?: VolumeSmokeRenderCompositorOptions); private _createReconstructionNode; private _createResolveNode; /** Resize owned targets from the renderer's current drawing-buffer dimensions. */ resize(): this; /** Set the scaled-rendering ratio and resize owned targets. */ setScale(scale: number): this; /** Bind a borrowed full-resolution depth texture, or restore scaled depth. */ setDepthTexture(depthTexture: THREE.Texture | null | undefined): this; /** Set the bilateral depth-rejection scale. */ setDepthSigma(depthSigma: number): this; /** Bind the borrowed motion texture required by temporal reconstruction. */ setMotionTexture(motionTexture: THREE.Texture | null | undefined): this; /** Invalidate temporal history before the next render. */ resetHistory(): this; /** * Returns the full-resolution resolved smoke color texture node. */ getTextureNode(): TSLVec4Node; /** * Render smoke and optional opaque depth into the scaled target, then reconstruct and composite it. * The renderer's previous target is restored if either scaled rendering or full-resolution resolve throws. */ render(renderScaled: VolumeSmokeScaledRenderCallback, { depthTexture, motionTexture, resetHistory, composite, }?: VolumeSmokeRenderOptions): VolumeSmokeRenderContext; /** Composite the latest resolved texture into the renderer's active target. */ composite(): void; /** Dispose all compositor-owned targets and node materials. */ dispose(): void; } export default VolumeSmokeRenderCompositor;