sdf nodes

16 node types in the sdf category.

grid_blur#

Separable box blur of sampled distances.

Creates new value arrays and preserves other input geometry. Offset/morphology/blur preserve bounds: use sufficient padding. Narrow-band infinities are distance sentinels; fill the source for large edits.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

nametypedefaultrangedescription
radiusint10..1024box-filter radius in voxels

Example

{ "type": "grid_blur", "in": ["grid"], "params": { "radius": 1 } }

grid_combine#

Boolean or smooth CSG on sampled SDF grids; B is resampled onto A.

The result keeps A's layout and clips to its bounds. Pad A before sampling if a union must include distant B. The first grid from each input is used; without B all A grids are combined.

Inputs

#namedescription
0agrid A defines output layout
1bgrid B (optional)

Parameters

nametypedefaultrangedescription
operationenum"union"CSG operation
options: union intersect subtract smooth_union smooth_intersect smooth_subtract
aliases: op
smoothfloat0.10..smooth CSG blend distance in world units
aliases: k

Example

{
  "type": "grid_combine",
  "in": ["a", "b"],
  "params": { "operation": "smooth_union", "smooth": 0.1 }
}

grid_dilate#

Dilate the solid by subtracting a distance.

Creates new value arrays and preserves other input geometry. Offset/morphology/blur preserve bounds: use sufficient padding. Narrow-band infinities are distance sentinels; fill the source for large edits.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

nametypedefaultrangedescription
distancefloat0.050..nonnegative morphology distance in world units
aliases: d amount

Example

{ "type": "grid_dilate", "in": ["grid"], "params": { "distance": 0.05 } }

grid_erode#

Erode the solid by adding a distance.

Creates new value arrays and preserves other input geometry. Offset/morphology/blur preserve bounds: use sufficient padding. Narrow-band infinities are distance sentinels; fill the source for large edits.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

nametypedefaultrangedescription
distancefloat0.050..nonnegative morphology distance in world units
aliases: d amount

Example

{ "type": "grid_erode", "in": ["grid"], "params": { "distance": 0.05 } }

grid_offset#

Offset sampled distances (positive grows the solid).

Creates new value arrays and preserves other input geometry. Offset/morphology/blur preserve bounds: use sufficient padding. Narrow-band infinities are distance sentinels; fill the source for large edits.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

nametypedefaultrangedescription
distancefloat0.05distance in world units; positive grows the solid
aliases: d amount

Example

{ "type": "grid_offset", "in": ["grid"], "params": { "distance": 0.05 } }

grid_resample#

Resample distance grids at a new voxel spacing.

Creates new value arrays and preserves other input geometry. Offset/morphology/blur preserve bounds: use sufficient padding. Narrow-band infinities are distance sentinels; fill the source for large edits.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

nametypedefaultrangedescription
voxel_sizefloat0.050.000001..grid spacing in world units; smaller voxels need more memory

Example

{ "type": "grid_resample", "in": ["grid"], "params": { "voxel_size": 0.08 } }

grid_to_mesh#

Extract sharp dual-contour quads or smooth marching-cubes triangles from sampled grids.

No source attributes are transferred. Dual contouring records the lower-corner sample index as point grid_cell, with fallback_cells and adaptive_collapses detail counts. Planar dual faces remain quads; nonplanar faces are triangulated consistently. Conservative extraction uses cell-local triangle fans. Closed surfaces must fit inside the grid; increase source padding for offsets. Subvoxel features cannot be recovered.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

nametypedefaultrangedescription
methodenum"dual_contouring"dual quads, conservative cell-local triangle fans, or smooth marching cubes
options: dual_contouring dual_contouring_conservative marching_cubes
isofloat0iso distance (+ grows)
sharpbooltrueQEF feature fitting (false uses Hermite intersection centroids)
adaptivefloat00..adaptive error tolerance in voxels; currently retains the uniform surface because octree simplification is not implemented
sharp_thresholdfloat0.50..1normal variation threshold for sharp-feature fitting (0..1)
qef_tolerancefloat0.0000011e-12..1relative rank tolerance of the QEF solver
clamp_to_cellbooltrueconstrain fitted points to their source cells

Example

{
  "type": "grid_to_mesh",
  "in": ["grid"],
  "params": { "method": "dual_contouring", "sharp": true }
}

grid_to_sdf#

Expose each sampled grid as a lazy trilinear implicit SDF.

Inputs

#namedescription
0gridsampled SDF grid(s)

Parameters

None.

Example

{ "type": "grid_to_sdf", "in": ["grid"] }

sdf_combine#

aliases: sdf_boolean sdf_blend vdb_combine

Combine SDF volumes: union / subtract / intersect, hard or smooth (blend radius k).

Inputs

#namedescription
0aSDF A
1bSDF B (optional: combines all volumes of A) (optional)

Parameters

nametypedefaultrangedescription
operationenum"smooth_union"operation
options: union subtract intersect smooth_union smooth_subtract smooth_intersect
aliases: op mode
kfloat0.20..blend radius for smooth operations
aliases: smoothness blend radius

Example

{
  "nodes": {
    "body": {
      "type": "sdf_shape",
      "params": { "shape": "capsule", "radius": 0.3, "height": 1 }
    },
    "head": {
      "type": "sdf_shape",
      "params": { "shape": "sphere", "radius": 0.35, "center": [0, 0.8, 0] }
    },
    "blob": {
      "type": "sdf_combine",
      "in": ["body", "head"],
      "params": { "operation": "smooth_union", "k": 0.2 }
    },
    "mesh": { "type": "sdf_to_mesh", "in": ["blob"] }
  },
  "output": "mesh"
}

sdf_expr#

aliases: sdf_code sdf_wrangle implicit

SDF from JS code: return a signed distance for point p ([x,y,z]). IQ helpers built in (sdSphere, sdBox, smin, opTwist…). sdf(i, p) samples input i.

The code runs sandboxed like a wrangle, under the script timeout (TOPOTOPO_SCRIPT_TIMEOUT_MS, default 30 s), and reads graph vars by their bare name (sdSphere(p, radius)). This node only probes the field at the origin; the nodes that sample it later (sdf_to_mesh, sdf_grid, also after transform, sdf_modify or sdf_combine) run all of their sampling under that limit, so the whole mesh or grid must be computed within it: a field that loops anywhere, or is too slow for the resolution, fails the sampling node with "SDF code (sdf_expr) exceeded N ms".

Inputs

#namedescription
0aoptional SDF input, sampled as sdf(0, p) (optional)
1boptional SDF input, sampled as sdf(1, p) (optional)

Parameters

nametypedefaultrangedescription
codecode"smin(sdSphere(p, 0.6), sdBox(sub(p, [0.6, 0, 0]), [0.3, 0.3, 0.3]), 0.25)"expression or body with return; p = [x,y,z]; negative inside
bounds_minvec3[-1.5,-1.5,-1.5]meshing region min
bounds_maxvec3[1.5,1.5,1.5]meshing region max
auto_boundsboolfalseuse the union of input volume bounds (padded) instead
namestring"sdf"volume name

Example

{
  "type": "sdf_expr",
  "params": {
    "code": "const q = opTwist(p, 2.0);\nreturn sdTorus(q, 0.8, 0.2);"
  }
}

Used in the example blob_creature.

sdf_from_mesh#

aliases: vdb_from_polygons mesh_to_sdf

Convert a closed mesh to an SDF volume (narrow band + sweeping), for blending meshes, offsets and remeshing.

Inputs

#namedescription
0meshclosed polygon mesh

Parameters

nametypedefaultrangedescription
voxel_sizefloat00..voxel size (0 = auto from divisions)
divisionsint648..256voxels across the largest dimension when voxel_size = 0
keep_meshboolfalsekeep the input polygons alongside the volume

Example

{
  "nodes": {
    "box": { "type": "box" },
    "field": {
      "type": "sdf_from_mesh",
      "in": ["box"],
      "params": { "divisions": 48 }
    },
    "grown": {
      "type": "sdf_to_mesh",
      "in": ["field"],
      "params": { "iso": 0.1 }
    }
  },
  "output": "grown"
}

sdf_grid#

Sample implicit SDF volumes or a polygon mesh into a regular 3D distance grid.

SDF volumes are unioned before sampling; if none exist, polygons are sampled using a triangle BVH and generalized winding-number sign. Values outside the narrow band are signed infinity unless fill is enabled. Grid bounds include padding in voxels. Mesh attributes are dropped. A field that runs user code (an sdf_expr upstream, also through transform, sdf_modify or sdf_combine) is sampled under the script timeout (TOPOTOPO_SCRIPT_TIMEOUT_MS, default 30 s): the whole grid must be sampled within it, else this node fails with "SDF code (sdf_expr) exceeded N ms" (raise voxel_size or the timeout). Implicit analytic volumes and meshes have no limit.

Inputs

#namedescription
0sourceimplicit SDF volume(s), or a polygon mesh

Parameters

nametypedefaultrangedescription
voxel_sizefloat0.050.000001..grid spacing in world units; smaller voxels need more memory
bandfloat32..exact narrow-band half width in voxels (at least 2 for gradients)
paddingfloat41..bounding-box padding in voxels; allow room for growth
fillbooltruefill distances outside the exact band (fast sweeping for mesh inputs)
namestring"grid"volume name

Example

{
  "type": "sdf_grid",
  "in": ["shape"],
  "params": { "voxel_size": 0.05, "band": 3, "fill": true }
}

sdf_modify#

aliases: sdf_offset sdf_noise sdf_twist vdb_reshape

Modify SDF volumes: offset (grow/shrink), shell, noise displacement, twist, bend, repeat (domain repetition).

Inputs

#namedescription
0sdfgeometry with SDF volume(s)

Parameters

nametypedefaultrangedescription
operationenum"offset"modification
options: offset shell noise twist bend repeat
aliases: op mode
amountfloat0.05offset distance (+ grows) / shell thickness / noise amplitude / twist or bend radians per unit
frequencyfloat3noise frequency
octavesint31..8noise octaves
periodvec3[1,0,1]repeat: spacing per axis (0 = no repetition on that axis)
countivec3[3,1,3]1..1000000repeat: number of copies per axis (limits the domain)
seedfloat0random seed

Example

{
  "nodes": {
    "ball": {
      "type": "sdf_shape",
      "params": { "shape": "sphere", "radius": 0.8 }
    },
    "rough": {
      "type": "sdf_modify",
      "in": ["ball"],
      "params": { "operation": "noise", "amount": 0.08, "frequency": 4 }
    },
    "mesh": { "type": "sdf_to_mesh", "in": ["rough"] }
  },
  "output": "mesh"
}

sdf_shape#

aliases: sdf_primitive sdf

SDF primitive volume (sphere, box, round_box, torus, capsule, cylinder, cone, ellipsoid, octahedron). Mesh it with sdf_to_mesh.

Inputs

None (generator).

Parameters

nametypedefaultrangedescription
shapeenum"sphere"primitive
options: sphere box round_box torus capsule cylinder cone ellipsoid octahedron
radiusfloat0.5sphere/capsule/cylinder/cone/octahedron radius; torus major radius
radius2float0.1torus minor radius; round_box corner radius
sizevec3[1,1,1]box/round_box/ellipsoid full size
heightfloat1capsule/cylinder/cone height (along Y)
centervec3[0,0,0]center position
aliases: t translate position pos origin
rotatevec3[0,0,0]rotation in degrees
namestring"sdf"volume name

Example

{
  "type": "sdf_shape",
  "params": { "shape": "round_box", "size": [1, 0.5, 1], "radius2": 0.1 }
}

sdf_to_mesh#

aliases: convert_sdf convert_vdb mesh_sdf polygonize isosurface

Polygonise SDF volumes into a watertight triangle mesh (all volumes are unioned). Smooth normals from the field gradient.

Meshes with the level-set mesher of manifold-3d. A field that runs user code (an sdf_expr upstream, also through transform, sdf_modify or sdf_combine) is meshed under the script timeout (TOPOTOPO_SCRIPT_TIMEOUT_MS, default 30 s): the whole meshing, normals included, must finish within it, else this node fails with "SDF code (sdf_expr) exceeded N ms" (raise edge_length or the timeout for a slow field). Analytic volumes (sdf_shape, sdf_from_mesh, grid_to_sdf, heightfield_to_sdf) have no limit.

Inputs

#namedescription
0sdfgeometry with SDF volume(s)

Parameters

nametypedefaultrangedescription
edge_lengthfloat00..target triangle edge length (0 = auto from divisions)
aliases: voxel_size resolution
divisionsint648..400cells across the largest dimension when edge_length = 0
isofloat0iso value (+ grows, − shrinks)
aliases: level offset
normalsbooltruewrite point N from the field gradient
keep_inputboolfalsealso keep the input polygons

Example

{
  "nodes": {
    "ring": {
      "type": "sdf_shape",
      "params": { "shape": "torus", "radius": 0.8, "radius2": 0.25 }
    },
    "mesh": {
      "type": "sdf_to_mesh",
      "in": ["ring"],
      "params": { "divisions": 80 }
    }
  },
  "output": "mesh"
}

Used in the example blob_creature.

voxel_remesh#

Mesh to sampled grid to sharp dual contouring in one operation.

Unions overlapping consistently oriented polygon shells by winding number. Dual QEF contouring preserves resolved features and reports local conservative fallback counts. The conservative and marching-cubes methods are also available. With transfer_attributes, Cd is interpolated on the nearest source triangle and material is chosen at each output face centre. Other attributes are dropped; UVs and exact seams are not retained.

Inputs

#namedescription
0meshpolygon mesh (open shells use generalized winding-number sign)

Parameters

nametypedefaultrangedescription
voxel_sizefloat0.050.000001..grid spacing in world units; smaller voxels need more memory
methodenum"dual_contouring"dual quads, conservative cell-local triangle fans, or smooth marching cubes
options: dual_contouring dual_contouring_conservative marching_cubes
adaptivefloat00..adaptive error tolerance in voxels; currently retains the uniform surface because octree simplification is not implemented
sharp_thresholdfloat0.50..1normal variation threshold for sharp-feature fitting (0..1)
offsetfloat0distance in world units; positive grows the solid
aliases: d amount
smooth_iterationsint00..32passes of radius-1 distance-grid blur before contouring
transfer_attributesboolfalsetransfer source Cd and material using nearest source triangles

Example

{
  "type": "voxel_remesh",
  "in": ["mesh"],
  "params": { "voxel_size": 0.05, "transfer_attributes": true }
}