- Introduction
- Source Operators
- GenerateSamplePoints
- LoadSamplePoints
- LoadVolume
- Transform Operators
- ComputeNormals
- TransformCylindricalCoords
- TransformMirrorCoords
- TransformSphericalCoords
- TransformTwistCoords
- Sample Operators
- MapTexturePrimitive
- SampleBox
- SampleBeam
- SampleCustomShape
- SampleTriangleMesh
- SampleLattice
- SampleSpinodoid [Under Development]
- SampleSurfaceLattice
- SampleVolume
- Filter Operators
- CSG
- Shell
- LinearFilter
- Redistance
- Threshold
- Assets
Introduction
The Metafold geometry kernel uses a computational directed acyclic graph (DAG) of operators to define shape functions. The DAG can be created through factory functions available in the SDK. By composing these operators you can create expressive implicit representations of arbitrarily complex shapes.
Operators are categorized into three main groups:
- Sample: TODO
- Filter: TODO
- Transform: TODO
These operators are a symbolic representation of functions within the computational graph that are consumed by our backend via jobs like, evaluate_graph. In order to access the data locally you must download the resulting assets using the SDK and import it into your project. For example:
Source Operators
GenerateSamplePoints
GenerateSamplePoints is a fundamental operator within the Metafold SDK that creates a regular grid of sample points in 3D space. It serves as the starting point for many geometric operations and shape definitions in Metafold.
Users need to use GenerateSamplePoints for several important reasons:
- Defining the computational domain: It sets up the 3D space where subsequent operations will take place.
- Controlling resolution: Users can specify the density of sample points, which affects the accuracy and detail of the resulting shapes for rendering and exporting.
- Providing input for other operators: Many other Metafold operators, such as
SampleLatticeor various primitives, require a set of sample points as input.
By using GenerateSamplePoints, users create the foundation upon which they can build complex geometric structures, perform analyses, and generate 3D models within the Metafold environment.
Vec3f function
Parameter | Type | Description |
xform | Mat4f | Affine transformation matrix. Applied after offset. Defaults to identity matrix. |
offset | Vec3f | Translational offset of minimum grid corner. Defaults to zero vector. |
size | Vec3f | Grid extents. Ignored for any axis with a resolution of one. Defaults to zero vector. |
resolution | Vec3i | Number of samples along grid extents. Defaults to [1, 1, 1]. |
The following generates 128^3 grid points within a box of size 20 centered at the origin.
from metafold.func import GenerateSamplePoints
import numpy as np
source = GenerateSamplePoints(
{
"offset": np.full(3, -10.0)
"size": np.full(3, 20)
"resolution": np.full(3, 128)
}
)LoadSamplePoints
LoadSamplePoints is a flexible operator that allows users to manually define their own set of points for function evaluations. Users can use this to define irregular grids that sample certain regions in space more densely.
Vec3f function
Parameter | Type | Description |
points (Required) | Array[Vec3f] | Array of sample points. |
The following generates a random set 1000 of points within a box of size 20 centered at the origin.
from metafold.func import LoadSamplePoints
import numpy as np
source = LoadSamplePoints(
{
"points": np.random.uniform(-10, 20, (1000, 3))
}
)LoadVolume
LoadVolume is a handy operator for importing 2D and 3D arrays of data. The data is expected to be stored as 32-bit floats and can consist of 1-, 2-, 3-, or 4- dimensional vector. It is imperative that the resolution accurately matches the size of the data.
LoadVolume does not sample the volume, but allocates and fills memory with the given data to be used by subsequent operators in the graph. SampleVolume is such an operator.
It is recommended to cache an implicit representation of a mesh using SampleTriangleMesh on a grid. You can than use this operator to load in the mesh each time for faster evaluation.
Parameter | Type | Description |
volume_data (Required) | VolumeAsset | Structured reference to a .bin file containing volume data. |
ByteFunction
Float function
Vec2i or Vec2f function
Vec3i or Vec3f function
Vec4i or Vec4f function
Parameter | Type | Description | |
component_type (Required) | String | Volume asset component type. Defaults to “Float” .
Options include: "Byte", "Float", "Integer", "Vec2f", "Vec2i", "Vec3f", "Vec3i", "Vec4f", "Vec4i” | |
resolution (Required) | Vec3i | Number of values along each dimension. |
Loads in a scalar field cached onto a grid.
from metafold.func import LoadVolume
from metafold.func_types import Volume_Asset
import numpy as np
volume_path = "path/to/binary/volume.bin"
volume_asset = VolumeAsset()
volume_asset["path"] = volume_path
volume = LoadVolume(
volume_asset,
{
"component_type"
"resolution": [128, 128, 128]
}
)SampleVolume, MapTexturePrimitive, ComputeNormals
Transform Operators
ComputeNormals
Compute the gradient of a volume at the given sample points.
Metafold represents shapes as the 0-level set of implicit scalar-field defined on a grid. This means that the normal is defined throughout the domain for all shapes. This function allows you to quickly compute the normals at specific locations in space. The locations do not need to be the original grid created via GenerateSamplePoints. They can be from a secondary grid or another set of points generated via LoadSamplePoints .
Name | Type | Description |
points (Required) | Vec3f function | Metafold source operator representing the sample point locations. |
volume (Required) | Float function | Metafold operator representing the volume of interest. |
Vec3f function
Parameter | Type | Description |
volume_offset | Vec3f | Volume translational offset. Defaults to [0.0, 0.0, 0.0] . |
volume_size | Vec3f | Volume extents. Defaults to [0.0, 0.0, 0.0] . |
xform | Mat4f | Affine transformation to apply to volume box. Defaults to identity matrix. |
Compute the normals on a cylinder with a cap radius of 5 and height of 10.
TransformCylindricalCoords
Apply a cylindrical mapping to the input points. This operator transforms points into a cylindrical coordinate system. When used as input to a sample function for shape creation, it introduces controlled curvature to the shape. This technique is particularly powerful for manipulating lattice structures.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Vec3f function
Parameter | Type | Description |
xform | Mat4 | Affine transformation matrix applied to points before the mapping occurs. Defaults to identity matrix. |
radial_scale | Float | Used to control the amount of amount of repetition in the radial direction. Defaults to 1.0. |
Loads in a scalar field cached onto a grid.
from metafold.func import GenerateSamplePoints, TransformCylindricalCoords
import numpy as np
source = GenerateSamplePoints(
{
"offset": np.full(3, -10.0),
"size": np.full(3, 20),
"resolution": np.full(3, 128)
}
)
transformed_pts = TransformCylindricalCoords(source, {"radial_scale": 4})TransformMirrorCoords
Apply a mirror transformation to the input points. This operator mirrors points across a specified plane in 3D space. When used as input to a sample function for shape creation, it enables the creation of symmetrical shapes across a plane. This technique is useful for creating mirrored versions of existing structures.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Vec3f function
Parameter | Type | Description |
xform | Mat4f | Affine transformation matrix applied to points before the mapping occurs. Defaults to identity matrix. |
mirror_normal | Vec3f | Normal vector of mirror plane in world coordinates. Defaults to [0.0, 0.0, 1.0]. |
mirror_point | Vec3f | Position of the mirror plane in 3D space. Defaults to origin [0.0, 0.0, 0.0]. |
Loads in a scalar field cached onto a grid.
from metafold.func import GenerateSamplePoints, TransformMirrorCoords
import numpy as np
source = GenerateSamplePoints(
{
"offset": np.full(3, -10.0)
"size": np.full(3, 20)
"resolution": np.full(3, 128)
}
)
transformed_pts = TransformMirrorCoords(source, {"reflection": 0})TransformSphericalCoords
Apply a spherical mapping to the input points. This operator transforms points into a spherical coordinate system. When used as input to a sample function for shape creation, it introduces controlled curvature to the shape in all directions. This technique is particularly powerful for creating spherical or radially symmetric structures and manipulating objects in a spherical space.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Vec3f function
Parameter | Type | Description |
xform | Mat4 | Affine transformation matrix applied to points before the mapping occurs. Defaults to identity matrix. |
Loads in a scalar field cached onto a grid.
from metafold.func import GenerateSamplePoints, TransformSphericalCoords
import numpy as np
source = GenerateSamplePoints(
{
"offset": np.full(3, -10.0)
"size": np.full(3, 20)
"resolution": np.full(3, 128)
}
)
transformed_pts = TransformSphericalCoords(source)TransformTwistCoords
Apply a twisting transformation to the input points. This operator rotates points around a specified axis. When used as input to a sample function for shape creation, it introduces a controlled spiral or helical deformation to the shape. This technique is particularly powerful for creating twisted structures or adding rotational effects to existing geometries.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Vec3f function
Force the input points to twist about x = 0.
from metafold.func import GenerateSamplePoints, TransformTwistCoords
import numpy as np
source = GenerateSamplePoints(
{
"offset": np.full(3, -10.0)
"size": np.full(3, 20)
"resolution": np.full(3, 128)
}
)
transformed_pts = TransformTwistCoords(source, {"frequency": 3.0})Sample Operators
MapTexturePrimitive
Generates a perturbation to distort the 0-level sets of shapes. By remapping input points into u, v image space according to a primitive mapping type the new coordinates are used to sample a grayscale texture. The result is a scalar field defined at all points on the grid. When combined with LinearFilter, it creates a texture-mapped surface effect. The mapping allows for precise control over how the image is applied to the primitive shape, enabling complex surface details and patterns. For a comprehensive guide on implementing this technique, refer to our detailed tutorial on texture mapping.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
image (Required) | Float function | Instance of a LoadVolume operator whose VolumeAsset references they.bin file created bt convert_image_to_height_map() . |
Float function
Parameter | Type | Description |
box_width | Vec3f | Used only for "Box" mapping. Creates a rectangular mapping with the given dimensions. Defaults to [1.0, 1.0, 1.0]. |
scale | Vec2f | Scale of the mapping u, v mapping. Defaults to [1.0, 1.0]. |
shape_type | String | String Enum representing the mapping. Defaults to "Box". |
shape_xform | Mat4f | Affine transformation applied to the underlying primitive. Defaults to identity matrix. |
xform | Mat4f | Affine transformation applied to the input points before mapping. Defaults to identity matrix. |
See tutorial on mapping textures.
LinearFilter
SampleBox
Sample a primitive shape at the given sample points.
This operator allows users to create common 3D shapes (what we call primitives) for their design needs. Each call allows users to create a single shape that is defined by it’s 0-level of it’s implicit scalar function definition. The primitives here serve as the bedrock for more complicated projects within the Metafold environment.
When combined with CSG operations users can define complex geometries for their needs through combining primitives with other sample operators.
A list of all the current available primitives can be found here.
[0, 0, 0], unlike the other operators that specify a box using minimum corner and size/extents. Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Float function
Parameter | Type | Description |
xform | Mat4 | Affine transformation matrix. Defaults to identity matrix. |
size | Vec3 | Primitive box size. Defaults to [0, 0, 0]. |
shape_type | String | The type of shape. Defaults to Box.
All options: "Box", "BoxFrame", "CappedCone", "Capsule" "Cylinder", "Ellipsoid", "Link", "Plane", "Torus" |
Create a 10x10x10 box rotated 30 degrees about its x-axis
SampleBeam
Sample a complete description of a line network. A line network consists of nodes and edges that define a graph, which can be connected or disconnected. This operator enables sampling and manipulation of line networks, offering customization options similar to those in the SampleLattice operator. Users can adjust various parameters to modify the network's properties and appearance.
This powerful tool allows input of complete beam structures built externally, rather than relying on a unit cell-based definition as in SampleLattice. To optimize line network evaluation, we use a BVH structure. This structure must be created before using this operator by running a create_bvh_from_network_file() job.
The .json file containing the line network must have two fields: "nodes" and "edges". The following example demonstrates how to define a BCC lattice using this format.
{
"nodes": [
[0., 0., 0.],
[1., 0., 0.],
[0., 1., 0.],
[1., 1., 0.],
[1., 0., 1.],
[0., 1., 1.],
[1., 1., 1.],
[.5, .5, .5]
],
"edges": [
[0, 8],
[1, 8],
[2, 8],
[3, 8],
[4, 8],
[5, 8],
[6, 8],
[7, 9]
]
}Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Name | Type | Description |
bvh_data (Required) | LineNetworkBvhAsset | Structured reference to a .bvh file created by the job create_bvh_from_network_file() . |
network_data (Required) | LineNetworkAsset | Structured reference to a .json file detailing the list of nodes and edges in the line network. The json file must be populated by two fields.
- nodes : a list of 3D points.
- edges : a list of 2D arrays describing the connections between points. |
Float function
Parameter | Type | Description |
node_type | String | String enum referencing the spape of lattice nodes. Defaults to "None". |
node_radius | Float | Radius of lattice nodes relative to unit cell. Defaults to 0.1. |
section_radius | Float | Radius of lattice beam cross sections relative to unit cell. Defaults to 0.05. |
section_type | SampleLattice_Enum_section_type | Shape of lattice beam cross sections. Defaults to "Circle". |
smoothing | Float | Width to smooth joints between nodes and beams by. Defaults to 0. |
xform | Mat4f | Affine transformation matrix for the lattice. Defaults to identity matrix. |
Import and sample a custom line network. See Handling Assets using the SDK for a detailed guide on how to handle and create LineNetworkAsset and LineNetworkBvhAsset assets.
SampleCustomShape
SampleCustomShape allows power users to create novel shapes using GLSL shader code. By attaching a SPIRV compiled binary describing a 3D shape, this operator samples it and adds it to your project. This functionality is particularly useful for advanced users who want to:
- Create complex, mathematically-defined shapes that are not easily achievable with standard primitives.
- Optimize performance for specific shape calculations.
- Experiment with procedural shape generation within the Metafold ecosystem.
In order to make use of this tool a user only needs to write GLSL shader code. The job compile_custom_shape() takes this code and converts it to a SPIRV compiled binary digestible by our backend.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Name | Type | Description |
shader_data (Required) | CustomShapeAsset | Structured reference to a .spv file created by the job compile_custom_shape() . |
Float function
Parameter | Type | Description |
xform | Mat4f | Affine transformation matrix for the custom shape. Defaults to identity matrix. |
Sample a custom 3D object. See Handling Assets using the SDK for a detailed guide on how to handle and create assets like CustomShapeAsset .
SampleTriangleMesh
Triangle meshes are a widely used representation for 3D geometry. This powerful tool enables you to seamlessly convert triangle mesh geometry into a Metafold implicit representation. By doing so, you can leverage Metafold's advanced capabilities for manipulating and analyzing complex 3D shapes within the implicit framework.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Name | Type | Description |
mesh_data (Required) | TriangleMeshAsset | Structured reference to a triangle mesh. Accepts most common triangle mesh formats. |
Float function.
Name | Type | Description |
cw_winding | Int | Winding order of mesh triangles. Defaults to counter clockwise.
0: Counter Clockwise
1: Clockwise |
xform | Mat4f | Affine transformation matrix applied to triangle mesh. |
Convert a triangle mesh to a metafold implicit.
SampleLattice
Lattices are formed by infinitely repeating unit cells in all directions. This operator samples beam lattices on a grid specified by GenerateSamplePoints, creating a lattice block that matches the size of the aforementioned operator.
Unit cells are defined via the UnitCell class. They consist of an array of nodes and edges. See below for an example of a BCC unit cell.
Two powerful sets of parameters for lattices are scale_grading_* and section_grading_*. Scale and Section Grading are techniques used to vary the properties of a lattice structure across its volume:
- Scale Grading varies the unit cell scale of the lattice across the structure.
- Section Grading varies the cross-sectional properties of lattice beams.
These grading techniques enable the creation of lattice structures with varying properties, which can optimize performance, weight distribution, or other design objectives.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Float function.
Parameter | Type | Description |
lattice_data (Required) | UnitCell | Dictionary with the following keys:
nodes: Positions of lattice nodes.
edges: Connectivity of lattice nodes.
No default. |
node_type | String | Shape of lattice nodes. Defaults to "None".
All types:
"None", "Sphere" |
node_radius | Float | Radius of lattice nodes relative to unit cell. Defaults to 0.1. |
scale | Vec3f | Unit cell scale. Defaults to [1.0, 1.0, 1.0]. |
scale_grading_range | Vec2f | Distances of ScaleGrading scalar field to grade between. Defaults to zero vector. |
scale_grading_scale | Vec2f | Scaling to apply to upper/lower grading limits. Defaults to zero vector. |
section_radius | Float | Radius of lattice beam cross sections relative to unit cell. Defaults to 0.05. |
section_type | String | Shape of lattice beam cross sections. Defaults to "Circle".
All types:
"Box", "Circle", "Cross” |
section_radius_grading_range | Vec2f | Distances of SectionRadiusGrading scalar field to grade between. Defaults to zero vector. |
section_radius_grading_scale | Vec2f | Scaling to apply to upper/lower grading limits. Defaults to zero vector. |
smoothing | Float | Width to smooth joints between nodes and beams by. Defaults to 0. |
xform | Mat4f | Affine transformation matrix for the lattice. Defaults to identity matrix. |
Create a 5x5x5 BCC unit cell to populate a 20x20x20 volume.
SampleSpinodoid [Under Development]
Spinodoid structures enhance additive manufacturing by offering customizable, non-periodic designs with tunable anisotropic properties, improving material resilience and functional grading. This operator samples a spinodoid using the given parameters on a grid specified by GenerateSamplePoints, creating a spinodoid block.
Spinodoids are created via computing a Gaussian random field. The parameters of this operator adjust the sampling using to build the field. For deterministic results set seedto a specific value.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Float function.
Parameter | Type | Description |
angles | Vec3f | Solid angles around the conical axes (e.g. x-, y-, and z-axis). These angles define the spread of wave vectors that shape the underlying Gaussian random field (GRF), which represents the spinodoid topology. All angles must be in {x : 0 or [0.25, pi / 4]}. With at least one angle being non-zero.. |
density | Float | The relative amount of solid material versus void in the structure. The limit are as follows, for:
- anisotropic (angles are different)[0.3, 1,0]
- isotropic (angles are the same) [0.16, 1.0] |
wave_count | Int | Positive integer that defines the terms in the Fourier series for computing the gaussian random field. Defaults to: 100 |
seed | Int | Random seed. Set to a specific value for deterministic (repeatable) results. Random by default. |
xform | Mat4f | Affine transformation matrix for the lattice. Defaults to identity matrix. |
Create a lamellar style spinodoid block in a 20x20x20 volume. Here we scale the spinodoid uniformly in x, y, z by 0.5 units.
SampleSurfaceLattice
Lattices are formed by infinitely repeating unit cells in all directions. This operator samples surface lattices on a grid specified by GenerateSamplePoints, creating a lattice block that matches the size of the aforementioned operator. See a list of predefined surface lattices here.
Two powerful sets of parameters for lattices are scale_grading_* and section_grading_*. Scale and Section Grading are techniques used to vary the properties of a lattice structure across its volume:
- Scale Grading varies the unit cell scale of the lattice across the structure.
- Section Grading varies the cross-sectional properties of lattice beams.
These grading techniques enable the creation of lattice structures with varying properties, which can optimize performance, weight distribution, or other design objectives.
Name | Type | Description |
points (Required) | Vec3f function | Source or transform operator representing point coordinates. |
Float function
Parameter | Type | Description |
lattice_type | String | Type of surface lattice. Defaults to "Gyroid" . Other options are listed here. |
scale | Vec3f | Unit cell scale. Defaults to [1.0, 1.0, 1.0]. |
scale_grading_range | Vec2f | Distances of ScaleGrading scalar field to grade between. Defaults to zero vector. |
scale_grading_scale | Vec2f | Scaling to apply to upper/lower grading limits. Defaults to zero vector. |
threshold | Float | Value of the zero level set. Defaults to 0. |
threshold_grading_range | Vec2f | Distances of ThresholdGrading scalar field to grade between. Defaults to zero vector. |
threshold_grading_scale | Vec2f | Offset to apply to upper/lower grading limits. Defaults to zero vector. |
xform | Mat4f | Affine transformation matrix. Defaults to identity matrix. |
Create a 5x5x5 Schwarz unit cell in a 20x20x20 volume.
from metafold.func import GenerateSamplePoints, SampleSurfaceLattice
source = GenerateSamplePoints(
{
"offset": [10.0, 10.0, 10.0],
"size": [20.0, 20.0, 20.0],
"resolution": [128, 128, 128],
}
)
schwarz_volume = SampleSurfaceLattice(
source,
{
"lattice_type": "Schwarz",
"scale": [5, 5, 5]
}
)SampleVolume
Given a volume of whether this operator samples that volume at specific points. This is very useful when combined with the LoadVolume operator. LoadVolume connects a volume asset to the backend but does not make it usable as is. To bring the volume into the Metafold computation space it must be sampled on the grid of points you are using for your project (see GenerateSamplePoints).
This operator can be used to sample 1D, 2D, and 3D dimensional arrays from LoadVolume .
Name | Type | Description |
points (Required) | Vec3f function | Metafold source operator representing the sample point locations. |
volume (Required) | Float function, Vec2f function, Vec3f function, Vec4f function | A Metafold operator representing the volume of interest. |
Float function
Name | Type | Description |
volume_size (Required) | Vec3f | Extents of the volume. Defaults to [0.0, 0.0, 0.0]. |
volume_offset | Vec3f | New position of grid origin. Defaults to [0.0, 0.0, 0.0]. |
xform | Mat4f | Affine transformation matrix applied to points before sampling. Defaults to identity matrix. |
Reamples a stored volume that is contained in a 25^3 cube.
SampleVolume, MapTexturePrimitive, ComputeNormals
Filter Operators
CSG
Constructive Solid Geometry (CSG) operations are powerful tools in 3D modeling and computer-aided design. They allow for complex shapes to be created by combining simpler primitive shapes using boolean operations. The three main types of CSG operations are:
"Union": Combines two shapes into a single object"Intersect": Creates a new shape from the overlapping portions of two objects"Subtract": Removes one shape from another
The power and usefulness of CSG operations lie in their ability to:
- Create complex geometries quickly and efficiently
- Simplify the design process for intricate parts
Name | Type | Description |
Aa (Required) | Float function | An operator representing the volume of interest. |
Bb (Required) | Float function | An operator representing the volume of interest. |
Float function
Name | Type | Description |
operation | String | Type of CSG operation to apply. Defaults to "Union".
Other operations: "Intersect", "Subtract" , "Union"
When using "Subtract", input A is subtracted from input B. |
smoothing | Float | Width of smooth CSG function by. Defaults to 0.0. |
Union a box and a sphere.
Shell
This operator creates a shell of a given thickness around the center of a level set given. The location of the level set is controlled by the offset parameter.
There are many creative and powerful ways to employ the Shell operator within the Metafold environment. The most common use is to make volumes hollow.
Name | Type | Description |
samples (Required) | Float function | An operator representing the volume of interest. |
Float function
Create a cube that is hollow inside and has a wall thickness of 2.0.
from metafold.func import GenerateSamplePoints, BoxPrimitive, Shell
import numpy as np
source = GenerateSamplePoints(
{
"offset": np.full(3, -100.0)
"size": np.full(3, 200)
"resolution": np.full(3, 512)
}
)
shelled_box = Shell(
BoxPrimitive(source, {"size": [50, 50, 50]}),
{"thickness": 2.0}
)LinearFilter
Metafold shapes are implicitly defined on a grid of points, such that their surface is the 0-level set of the implicit function. The LinearFilter allows you to combine two fields from different shapes to distort their 0-level set in a controlled manner by addition and scalar multiplication.
The common use case is for mapping a texture to a surface. See Mapping Textures to Shapes here for a step by step guide.
Name | Type | Description |
a (Required) | Float function | An operator representing the volume of interest. |
b (Required) | Float function | An operator representing the volume of interest. |
Float function
Parameter | Type | Description |
scale_a | Float | Factor to multiply the values of a . |
scale_b | Float | Factor to multiply the values of b . |
See tutorial on mapping textures.
Redistance
This operator computes an exact signed distance field from a given pseudo distance field. We recommend applying this filter to shapes prior to CSG operations to ensure accurate booleans. It is also typically appended to the end of shape functions so that we can be sure the shape function is generating an exact SDF. For more details, see Redistancing: What is it and why is it important?
Within the Metafold backend shapes live as implicit-fields, that are pseudo signed distance fields. Their surfaces are defined via their 0-level set. Some operators like SampleBox and SampleTriangleMesh provide the true signed distances to the object at the time of evaluation. But once they are combined with other operators this guarantee no longer holds. In order to ensure we are working with true signed distance fields only, this operator should be appended to the end of all graphs that are evaluated. See <> for more details.
Name | Type | Description |
samples (Required) | Float function | An operator representing the volume of interest. |
Float function
Parameter | Type | Description |
pre_offset | Float | Offset to apply before redistancing. Positive values result in an erosion and negative values result in a dilation. Defaults to: 0. |
post_offset | Float | Offset to apply after redistancing. Positive values result in an erosion and negative values result in a dilation. Defaults to 0. |
Apply apply a distance transform to a gyroid filled volume.
Threshold
To export a graph, this operator must be appended to the end. It compresses the graph's final output by remapping all sample values from the underlying implicit scalar field to the range [-1, 1]. Sample values with an absolute value exceeding the specified width are clamped to -1 or 1, depending on whether they are inside or outside the volume. The remapped values are then packed, with each float being represented as a single byte. Export functions, such as export_triangle_mesh(), require binary files in this format."
Name | Type | Description |
samples (Required) | Float function | A Metafold operator representing the volume of interest. |
Bytes function
Parameter | Type | Description |
width | Float | Width of the range on either size of zero. |
Apply apply a threshold to a gyroid filled volume to later be exported as a triangle mesh.
Assets
Assets are handled using a Python dictionary or Javascript object. Each asset class has a field path where a user references the file containing the asset.
# ...
triangle_mesh_path = "path/to/mesh"
line_network_asset = TriangleMeshAsset()
line_network_asset["path"] = triangle_mesh_path
f = SampleTriangleMesh(source, mesh_data=line_network_asset)
# ...