sdf nodes
16 node types in the sdf category.
- grid_blur
- grid_combine
- grid_dilate
- grid_erode
- grid_offset
- grid_resample
- grid_to_mesh
- grid_to_sdf
- sdf_combine
- sdf_expr
- sdf_from_mesh
- sdf_grid
- sdf_modify
- sdf_shape
- sdf_to_mesh
- voxel_remesh
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
| # | name | description |
|---|---|---|
| 0 | grid | sampled SDF grid(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
radius | int | 1 | 0..1024 | box-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
| # | name | description |
|---|---|---|
| 0 | a | grid A defines output layout |
| 1 | b | grid B (optional) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
operation | enum | "union" | CSG operation options: union intersect subtract smooth_union smooth_intersect smooth_subtractaliases: op | |
smooth | float | 0.1 | 0.. | 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
| # | name | description |
|---|---|---|
| 0 | grid | sampled SDF grid(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
distance | float | 0.05 | 0.. | 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
| # | name | description |
|---|---|---|
| 0 | grid | sampled SDF grid(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
distance | float | 0.05 | 0.. | 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
| # | name | description |
|---|---|---|
| 0 | grid | sampled SDF grid(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
distance | float | 0.05 | distance 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
| # | name | description |
|---|---|---|
| 0 | grid | sampled SDF grid(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
voxel_size | float | 0.05 | 0.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
| # | name | description |
|---|---|---|
| 0 | grid | sampled SDF grid(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
method | enum | "dual_contouring" | dual quads, conservative cell-local triangle fans, or smooth marching cubes options: dual_contouring dual_contouring_conservative marching_cubes | |
iso | float | 0 | iso distance (+ grows) | |
sharp | bool | true | QEF feature fitting (false uses Hermite intersection centroids) | |
adaptive | float | 0 | 0.. | adaptive error tolerance in voxels; currently retains the uniform surface because octree simplification is not implemented |
sharp_threshold | float | 0.5 | 0..1 | normal variation threshold for sharp-feature fitting (0..1) |
qef_tolerance | float | 0.000001 | 1e-12..1 | relative rank tolerance of the QEF solver |
clamp_to_cell | bool | true | constrain 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
| # | name | description |
|---|---|---|
| 0 | grid | sampled 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
| # | name | description |
|---|---|---|
| 0 | a | SDF A |
| 1 | b | SDF B (optional: combines all volumes of A) (optional) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
operation | enum | "smooth_union" | operation options: union subtract intersect smooth_union smooth_subtract smooth_intersectaliases: op mode | |
k | float | 0.2 | 0.. | 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
| # | name | description |
|---|---|---|
| 0 | a | optional SDF input, sampled as sdf(0, p) (optional) |
| 1 | b | optional SDF input, sampled as sdf(1, p) (optional) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
code | code | "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_min | vec3 | [-1.5,-1.5,-1.5] | meshing region min | |
bounds_max | vec3 | [1.5,1.5,1.5] | meshing region max | |
auto_bounds | bool | false | use the union of input volume bounds (padded) instead | |
name | string | "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
| # | name | description |
|---|---|---|
| 0 | mesh | closed polygon mesh |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
voxel_size | float | 0 | 0.. | voxel size (0 = auto from divisions) |
divisions | int | 64 | 8..256 | voxels across the largest dimension when voxel_size = 0 |
keep_mesh | bool | false | keep 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
| # | name | description |
|---|---|---|
| 0 | source | implicit SDF volume(s), or a polygon mesh |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
voxel_size | float | 0.05 | 0.000001.. | grid spacing in world units; smaller voxels need more memory |
band | float | 3 | 2.. | exact narrow-band half width in voxels (at least 2 for gradients) |
padding | float | 4 | 1.. | bounding-box padding in voxels; allow room for growth |
fill | bool | true | fill distances outside the exact band (fast sweeping for mesh inputs) | |
name | string | "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
| # | name | description |
|---|---|---|
| 0 | sdf | geometry with SDF volume(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
operation | enum | "offset" | modification options: offset shell noise twist bend repeataliases: op mode | |
amount | float | 0.05 | offset distance (+ grows) / shell thickness / noise amplitude / twist or bend radians per unit | |
frequency | float | 3 | noise frequency | |
octaves | int | 3 | 1..8 | noise octaves |
period | vec3 | [1,0,1] | repeat: spacing per axis (0 = no repetition on that axis) | |
count | ivec3 | [3,1,3] | 1..1000000 | repeat: number of copies per axis (limits the domain) |
seed | float | 0 | random 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
| name | type | default | range | description |
|---|---|---|---|---|
shape | enum | "sphere" | primitive options: sphere box round_box torus capsule cylinder cone ellipsoid octahedron | |
radius | float | 0.5 | sphere/capsule/cylinder/cone/octahedron radius; torus major radius | |
radius2 | float | 0.1 | torus minor radius; round_box corner radius | |
size | vec3 | [1,1,1] | box/round_box/ellipsoid full size | |
height | float | 1 | capsule/cylinder/cone height (along Y) | |
center | vec3 | [0,0,0] | center position aliases: t translate position pos origin | |
rotate | vec3 | [0,0,0] | rotation in degrees | |
name | string | "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
| # | name | description |
|---|---|---|
| 0 | sdf | geometry with SDF volume(s) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
edge_length | float | 0 | 0.. | target triangle edge length (0 = auto from divisions) aliases: voxel_size resolution |
divisions | int | 64 | 8..400 | cells across the largest dimension when edge_length = 0 |
iso | float | 0 | iso value (+ grows, − shrinks) aliases: level offset | |
normals | bool | true | write point N from the field gradient | |
keep_input | bool | false | also 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
| # | name | description |
|---|---|---|
| 0 | mesh | polygon mesh (open shells use generalized winding-number sign) |
Parameters
| name | type | default | range | description |
|---|---|---|---|---|
voxel_size | float | 0.05 | 0.000001.. | grid spacing in world units; smaller voxels need more memory |
method | enum | "dual_contouring" | dual quads, conservative cell-local triangle fans, or smooth marching cubes options: dual_contouring dual_contouring_conservative marching_cubes | |
adaptive | float | 0 | 0.. | adaptive error tolerance in voxels; currently retains the uniform surface because octree simplification is not implemented |
sharp_threshold | float | 0.5 | 0..1 | normal variation threshold for sharp-feature fitting (0..1) |
offset | float | 0 | distance in world units; positive grows the solid aliases: d amount | |
smooth_iterations | int | 0 | 0..32 | passes of radius-1 distance-grid blur before contouring |
transfer_attributes | bool | false | transfer source Cd and material using nearest source triangles |
Example
{
"type": "voxel_remesh",
"in": ["mesh"],
"params": { "voxel_size": 0.05, "transfer_attributes": true }
}