Three Blocks

sdfFieldNodes

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 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.

SDF and raymarching

Import

import { sdfFieldNodes } from "three-blocks/sdf-raymarching";

Declaration

function sdfFieldNodes(source: SDFFieldNodesSource, options?: SDFFieldNodesOptions): SDFFieldNodes;

Parameters

  • source — Generated field to sample; must already hold a texture.
  • options — Sampling budgets and the out-of-volume distance.

Returns

World-space distance, normal, occlusion, and shadow samplers.

SDFFieldNodesSource · SDFFieldNodesOptions · SDFFieldNodes

Read as Markdown ↗