Builtin Library
README.md
sdf.from_grid (procNode)
A channel of a Grid read as a signed distance field: trilinear between cell centres, and growing with the distance outside the outermost centres. How a distance computed on a grid (by a kernel, a simulation or attribute nodes) becomes a shape sdf.mesh can contour.
Inputs
grid(Grid): The grid whose channel is read, such as one grid.box makes.channel(String, default "distance"): The point attribute of the grid read as the distance, one Float per cell, negative inside the shape. A grid that does not carry it is refused.
Outputs
sdf(Sdf): the shape, bounded by the grid's box.
Outside the outermost cell centres the field is the nearest edge value plus the distance to it, so the shape stays closed at the grid's walls when the channel is positive there.
Example
local grid = g.grid.box({ size = vector.create(2, 2, 2), cells = vector.create(16, 16, 16) })
grid.point.distance = g.math.length(grid.point.P) - 0.6
local mesh = g.sdf.mesh({ sdf = g.sdf.from_grid({ grid = grid }), resolution = 16 }).geometry