import * as THREE from 'three/webgpu'; import type { TSLFloatInput, TSLFloatNode, TSLVec3Node } from '../types/tsl.cjs'; /** Generated field consumed by {@link sdfFieldNodes}; both SDF generators satisfy it. */ export interface SDFFieldNodesSource { /** Generator-owned r32float volume holding world-unit signed distances. */ readonly sdfTexture: THREE.Storage3DTexture | null; /** Cubic voxel dimension of the volume. */ readonly resolution: number; /** World to normalized-volume transform. */ readonly inverseBoundsMatrix: THREE.Matrix4; /** Normalized-volume to world transform. */ readonly boundsMatrix: THREE.Matrix4; } /** Construction configuration for {@link sdfFieldNodes}. */ export interface SDFFieldNodesOptions { /** Signed distance reported outside the volume; keeps marches terminating instead of smearing the clamped edge. */ far?: number | undefined; /** Sphere-tracing iterations spent by {@link SDFFieldNodes.shadow}. */ shadowSteps?: number | undefined; /** Cone taps spent by {@link SDFFieldNodes.occlusion}. */ occlusionSamples?: number | undefined; /** * How many voxels below the isosurface a shading point may read before the samplers stop * trusting it and report no occlusion. Must exceed the generator's shell radius in voxels. */ trustVoxels?: number | undefined; /** * How many voxels clear of the surface every sample is taken. It must exceed the error in * the caller's surface points - for a Gaussian capture, a voxel or two - or the readings are * noise. Raise it for a fuzzier source; the field loses detail it cannot resolve anyway. */ smoothVoxels?: number | undefined; } /** Per-call configuration for {@link SDFFieldNodes.occlusion}. */ export interface SDFFieldOcclusionOptions { /** World-space cone length searched along the normal; keep it well above the sample clearance. */ radius?: TSLFloatInput | undefined; /** Darkening applied to the measured occlusion; zero returns one. */ intensity?: TSLFloatInput | undefined; /** World-space clearance the sample is lifted to off the isosurface; defaults to `smoothVoxels`. */ lift?: TSLFloatInput | undefined; } /** Per-call configuration for {@link SDFFieldNodes.shadow}. */ export interface SDFFieldShadowOptions { /** Largest world-space distance marched toward the light. */ maxDistance?: TSLFloatInput | undefined; /** World-space clearance the sample is lifted to off the isosurface; defaults to `smoothVoxels`. */ lift?: TSLFloatInput | undefined; /** Penumbra tightness; higher values harden the shadow edge. */ softness?: TSLFloatInput | undefined; } /** World-space TSL samplers bound to one generated signed-distance volume. */ export interface SDFFieldNodes { /** Signed distance from a world position to the field surface, in world units. */ distance(worldPosition: TSLVec3Node): TSLFloatNode; /** Outward field normal at a world position, from a tetrahedral gradient. */ normal(worldPosition: TSLVec3Node): TSLVec3Node; /** Cone-traced ambient occlusion above a world-space surface point. */ occlusion(worldPosition: TSLVec3Node, surfaceNormal: TSLVec3Node, options?: SDFFieldOcclusionOptions): TSLFloatNode; /** Sphere-traced soft shadow from a world position toward a normalized light direction. */ shadow(worldPosition: TSLVec3Node, lightDirection: TSLVec3Node, options?: SDFFieldShadowOptions): TSLFloatNode; /** Refresh the bound texture and transforms after the source regenerates. */ update(): void; } /** * Bind world-space TSL samplers to a generated signed-distance volume. * * The volume is borrowed: the returned samplers read the generator's current * texture and transforms, and {@link SDFFieldNodes.update} re-reads both after a * regeneration. The field is static in world space, so a source whose geometry * was captured in object space must be regenerated when that object moves. * * Distances are stored in world units, so every option below is world-space too. * Reconstruction is a manual trilinear `textureLoad` because r32float volumes are * not filterable on adapters without `float32-filterable`. * * @param source Generated field to sample; must already hold a texture. * @param options Sampling budgets and the out-of-volume distance. * @returns World-space distance, normal, occlusion, and shadow samplers. */ export declare function sdfFieldNodes(source: SDFFieldNodesSource, options?: SDFFieldNodesOptions): SDFFieldNodes;