import { Color, Matrix4, NodeMaterial, Vector2, Vector3 } from 'three/webgpu'; import type { ColorRepresentation, Storage3DTexture } from 'three/webgpu'; import type { TSLNode, TSLUniformNode, TSLVec2Node } from '../types/tsl.cjs'; export interface RayMarchSDFNodeMaterialOptions { color?: ColorRepresentation | undefined; highlightColor?: ColorRepresentation | undefined; backgroundTop?: ColorRepresentation | undefined; backgroundBottom?: ColorRepresentation | undefined; backgroundAlpha?: number | undefined; roughness?: number | undefined; stepScale?: number | undefined; translucency?: number | undefined; absorptionColor?: ColorRepresentation | undefined; scatterColor?: ColorRepresentation | undefined; absorptionDensity?: number | undefined; envIntensity?: number | undefined; scatterSoftness?: number | undefined; ior?: number | undefined; dispersion?: number | undefined; cloudStrength?: number | undefined; veinStrength?: number | undefined; veinColor?: ColorRepresentation | undefined; finishIntensity?: number | undefined; surfaceDetail?: number | undefined; filmic?: number | undefined; exposure?: number | undefined; ditherStrength?: number | undefined; marchJitter?: number | undefined; quality?: number | undefined; } export interface RayMarchSDFUniforms { surface: TSLUniformNode<'float', number>; distanceScale: TSLUniformNode<'float', number>; normalStep: TSLUniformNode<'vec3', Vector3>; projectionInverse: TSLUniformNode<'mat4', Matrix4>; sdfTransformInverse: TSLUniformNode<'mat4', Matrix4>; sdfTransform: TSLUniformNode<'mat4', Matrix4>; stepScale: TSLUniformNode<'float', number>; roughness: TSLUniformNode<'float', number>; ambientOcclusion: TSLUniformNode<'float', number>; translucency: TSLUniformNode<'float', number>; absorptionDensity: TSLUniformNode<'float', number>; absorptionColor: TSLUniformNode<'color', Color>; scatterColor: TSLUniformNode<'color', Color>; envIntensity: TSLUniformNode<'float', number>; scatterSoftness: TSLUniformNode<'float', number>; ior: TSLUniformNode<'float', number>; dispersion: TSLUniformNode<'float', number>; cloudStrength: TSLUniformNode<'float', number>; veinStrength: TSLUniformNode<'float', number>; veinColor: TSLUniformNode<'color', Color>; finishIntensity: TSLUniformNode<'float', number>; surfaceDetail: TSLUniformNode<'float', number>; filmic: TSLUniformNode<'float', number>; exposure: TSLUniformNode<'float', number>; ditherStrength: TSLUniformNode<'float', number>; marchJitter: TSLUniformNode<'float', number>; quality: TSLUniformNode<'float', number>; surfaceColor: TSLUniformNode<'color', Color>; highlightColor: TSLUniformNode<'color', Color>; lightDirection: TSLUniformNode<'vec3', Vector3>; viewToWorld: TSLUniformNode<'mat4', Matrix4>; resolution: TSLUniformNode<'vec2', Vector2>; backgroundTop: TSLUniformNode<'color', Color>; backgroundBottom: TSLUniformNode<'color', Color>; backgroundAlpha: TSLUniformNode<'float', number>; uv: TSLVec2Node; sdf: TSLNode; } /** * Ray-marching material for SDF isosurface visualization. * * The material traces in normalized SDF space and converts stored distances back to * that space with `distanceScale`. Float storage textures are reconstructed manually * with trilinear `textureLoad` calls so the material works on adapters that do not * expose the optional `float32-filterable` WebGPU feature. * * @example * import { RayMarchSDFNodeMaterial } from 'three-blocks/sdf-raymarching'; * import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js'; * * const material = new RayMarchSDFNodeMaterial( sdfTexture ); * const quad = new FullScreenQuad( material ); * * // In the render loop: * const uniforms = material.raymarchUniforms; * uniforms.surface.value = 0; * uniforms.distanceScale.value = sdfGenerator.bounds.getSize( size ).x; * uniforms.sdfTransformInverse.value.copy( sdfToView ).invert(); * uniforms.sdfTransform.value.copy( sdfToView ); * quad.render( renderer ); * * @class RayMarchSDFNodeMaterial * @extends {NodeMaterial} */ export declare class RayMarchSDFNodeMaterial extends NodeMaterial { raymarchUniforms: RayMarchSDFUniforms; isRayMarchSDFNodeMaterial: boolean; /** * @param {THREE.Storage3DTexture} sdfTexture - 3D SDF texture to visualize. * @param {Object} [options] - Appearance and tracing options. * @param {THREE.ColorRepresentation} [options.color=0x72d6b3] - Surface base color. * @param {THREE.ColorRepresentation} [options.highlightColor=0xc8fff2] - Rim and specular tint. * @param {THREE.ColorRepresentation} [options.backgroundTop=0x10232b] - Top background color. * @param {THREE.ColorRepresentation} [options.backgroundBottom=0x020506] - Bottom background color. * @param {number} [options.backgroundAlpha=0] - Background opacity. Keep at zero for compositing. * @param {number} [options.roughness=0.28] - Perceptual surface roughness. * @param {number} [options.stepScale=0.75] - Conservative sphere-tracing step multiplier. * @param {number} [options.translucency=0] - Subsurface scattering blend. 0 keeps the opaque shading. * @param {THREE.ColorRepresentation} [options.absorptionColor=0x2fbf8f] - Per-unit-depth transmission color of the body. * @param {THREE.ColorRepresentation} [options.scatterColor=0xd9ffe9] - Tint of light transmitted through the body. * @param {number} [options.absorptionDensity=7] - Optical density. Higher darkens thick regions faster. * @param {number} [options.envIntensity=0] - Analytic studio environment blend. Zero preserves legacy shading. * @param {number} [options.scatterSoftness=0] - Terminator, phase-skirt, and cone-light softening blend. * @param {number} [options.ior=1] - Interior index of refraction. One preserves the unrefracted path. * @param {number} [options.dispersion=0] - Exit-only RGB refraction spread. * @param {number} [options.cloudStrength=0] - Low-frequency interior density variation. * @param {number} [options.veinStrength=0] - Ridged interior vein extinction. * @param {THREE.ColorRepresentation} [options.veinColor=0x273c2e] - Per-unit-depth transmission color inside veins. * @param {number} [options.finishIntensity=0] - Dual-lobe GGX polish blend. * @param {number} [options.surfaceDetail=0] - Surface-only micro-normal and roughness grain. * @param {number} [options.filmic=0] - AgX output transform blend. * @param {number} [options.exposure=0] - Output exposure in stops. * @param {number} [options.ditherStrength=0] - Final integer-pixel IGN dither strength. * @param {number} [options.marchJitter=0] - Primary-ray IGN offset strength. * @param {number} [options.quality=0] - Quality tier (0–4); higher tiers restore FBM, dispersion, then cone taps. */ constructor(sdfTexture: Storage3DTexture, options?: RayMarchSDFNodeMaterialOptions); }