Documentation
¶
Index ¶
- type Builder
- func (bld *Builder) Annulus(s glbuild.Shader2D, sub float32) glbuild.Shader2D
- func (bld *Builder) Array(s glbuild.Shader3D, spacingX, spacingY, spacingZ float32, nx, ny, nz int) glbuild.Shader3D
- func (bld *Builder) Array2D(s glbuild.Shader2D, spacingX, spacingY float32, nx, ny int) glbuild.Shader2D
- func (bld *Builder) Bend(s glbuild.Shader3D, R float32) glbuild.Shader3D
- func (bld *Builder) CircularArray(s glbuild.Shader3D, numInstances, circleDiv int) glbuild.Shader3D
- func (bld *Builder) CircularArray2D(s glbuild.Shader2D, numInstances, circleDiv int) glbuild.Shader2D
- func (bld *Builder) ClearErrors()
- func (bld *Builder) Difference(a, b glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) Difference2D(a, b glbuild.Shader2D) glbuild.Shader2D
- func (bld *Builder) Elongate(s glbuild.Shader3D, dirX, dirY, dirZ float32) glbuild.Shader3D
- func (bld *Builder) Elongate2D(s glbuild.Shader2D, dirX, dirY float32) glbuild.Shader2D
- func (bld *Builder) Err() error
- func (bld *Builder) Extrude(s glbuild.Shader2D, h float32) glbuild.Shader3D
- func (bld *Builder) Flags() Flags
- func (bld *Builder) Intersection(a, b glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) Intersection2D(a, b glbuild.Shader2D) glbuild.Shader2D
- func (bld *Builder) NewArc(radius, arcAngle, thick float32) glbuild.Shader2D
- func (bld *Builder) NewBoundsBoxFrame(bb ms3.Box) glbuild.Shader3D
- func (bld *Builder) NewBox(x, y, z, round float32) glbuild.Shader3D
- func (bld *Builder) NewBoxFrame(dimX, dimY, dimZ, e float32) glbuild.Shader3D
- func (bld *Builder) NewCircle(radius float32) glbuild.Shader2D
- func (bld *Builder) NewCubicBezier2D(points []ms2.Vec, segments int, thick float32) glbuild.Shader2D
- func (bld *Builder) NewCylinder(r, h, rounding float32) glbuild.Shader3D
- func (bld *Builder) NewDiamond2D(x_width, y_height float32) glbuild.Shader2D
- func (bld *Builder) NewEllipse(a, b float32) glbuild.Shader2D
- func (bld *Builder) NewEquilateralTriangle(triangleHeight float32) glbuild.Shader2D
- func (bld *Builder) NewHexagon(side float32) glbuild.Shader2D
- func (bld *Builder) NewHexagonalPrism(face2Face, h float32) glbuild.Shader3D
- func (bld *Builder) NewLine2D(x0, y0, x1, y1, width float32) glbuild.Shader2D
- func (bld *Builder) NewLines2D(segments [][2]ms2.Vec, width float32) glbuild.Shader2D
- func (bld *Builder) NewOctagon(constrain float32) glbuild.Shader2D
- func (bld *Builder) NewPolygon(vertices []ms2.Vec) glbuild.Shader2D
- func (bld *Builder) NewQuadraticBezier2D(a, b, c ms2.Vec, thick float32) glbuild.Shader2D
- func (bld *Builder) NewRectangle(x, y, r float32) glbuild.Shader2D
- func (bld *Builder) NewRoundedX(width, thick float32) glbuild.Shader2D
- func (bld *Builder) NewSphere(r float32) glbuild.Shader3D
- func (bld *Builder) NewTorus(greaterRadius, lesserRadius float32) glbuild.Shader3D
- func (bld *Builder) NewTriangularPrism(triHeight, extrudeLength float32) glbuild.Shader3D
- func (bld *Builder) Offset(s glbuild.Shader3D, sdfAdd float32) glbuild.Shader3D
- func (bld *Builder) Offset2D(s glbuild.Shader2D, sdfAdd float32) glbuild.Shader2D
- func (bld *Builder) Revolve(s glbuild.Shader2D, axisOffset float32) glbuild.Shader3D
- func (bld *Builder) Rotate(s glbuild.Shader3D, radians float32, axis ms3.Vec) glbuild.Shader3D
- func (bld *Builder) Rotate2D(s glbuild.Shader2D, theta float32) glbuild.Shader2D
- func (bld *Builder) Scale(s glbuild.Shader3D, scaleFactor float32) glbuild.Shader3D
- func (bld *Builder) Scale2D(s glbuild.Shader2D, scale float32) glbuild.Shader2D
- func (bld *Builder) SetFlags(flags Flags) error
- func (bld *Builder) Shell(s glbuild.Shader3D, thickness float32) glbuild.Shader3D
- func (bld *Builder) SmoothDifference(k float32, s1, s2 glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothDifferenceIn(k float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothDifferenceRamp(k0, k1 float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothIntersect(k float32, s1, s2 glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothIntersectIn(k float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothIntersectRamp(k0, k1 float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothUnion(k float32, s1, s2 glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothUnionIn(k float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) SmoothUnionRamp(k0, k1 float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) Symmetry(s glbuild.Shader3D, mirrorX, mirrorY, mirrorZ bool) glbuild.Shader3D
- func (bld *Builder) Symmetry2D(s glbuild.Shader2D, mirrorX, mirrorY bool) glbuild.Shader2D
- func (bld *Builder) Taper(s glbuild.Shader3D, k0, k1 float32) glbuild.Shader3D
- func (bld *Builder) Transform(s glbuild.Shader3D, m ms3.Mat4) glbuild.Shader3D
- func (bld *Builder) Translate(s glbuild.Shader3D, dirX, dirY, dirZ float32) glbuild.Shader3D
- func (bld *Builder) Translate2D(s glbuild.Shader2D, dirX, dirY float32) glbuild.Shader2D
- func (bld *Builder) TranslateMulti2D(s glbuild.Shader2D, displacements []ms2.Vec) glbuild.Shader2D
- func (bld *Builder) Twist(s glbuild.Shader3D, k float32) glbuild.Shader3D
- func (bld *Builder) Union(shaders ...glbuild.Shader3D) glbuild.Shader3D
- func (*Builder) Union2D(shaders ...glbuild.Shader2D) glbuild.Shader2D
- func (bld *Builder) Xor(s1, s2 glbuild.Shader3D) glbuild.Shader3D
- func (bld *Builder) Xor2D(s1, s2 glbuild.Shader2D) glbuild.Shader2D
- type Flags
- type GridSDF
- func (g *GridSDF) AppendShaderBody(b []byte) []byte
- func (g *GridSDF) AppendShaderName(b []byte) []byte
- func (g *GridSDF) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject
- func (g *GridSDF) Bounds() ms3.Box
- func (g *GridSDF) Evaluate(pos []ms3.Vec, dist []float32, _ any) error
- func (g *GridSDF) ForEachChild(_ any, _ func(any, *glbuild.Shader3D) error) error
- type OpUnion
- func (u *OpUnion) AppendShaderBody(b []byte) []byte
- func (u *OpUnion) AppendShaderName(b []byte) []byte
- func (u *OpUnion) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject
- func (u *OpUnion) Bounds() ms3.Box
- func (u *OpUnion) CullGapSafe() bool
- func (u *OpUnion) Evaluate(pos []ms3.Vec, dist []float32, userData any) error
- func (u *OpUnion) ForEachChild(userData any, fn func(userData any, s *glbuild.Shader3D) error) error
- type OpUnion2D
- func (u *OpUnion2D) AppendShaderBody(b []byte) []byte
- func (u *OpUnion2D) AppendShaderName(b []byte) []byte
- func (u *OpUnion2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject
- func (u *OpUnion2D) Bounds() ms2.Box
- func (u *OpUnion2D) Evaluate(pos []ms2.Vec, dist []float32, userData any) error
- func (u *OpUnion2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.Shader2D) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder wraps all SDF primitive and operation logic generation. Provides error handling strategies with panics or error accumulation during shape generation.
func (*Builder) Annulus ¶
Annulus makes a 2D shape annular by emptying it's center. It is the equivalent of the 3D Shell operation but in 2D.
func (*Builder) Array ¶
func (bld *Builder) Array(s glbuild.Shader3D, spacingX, spacingY, spacingZ float32, nx, ny, nz int) glbuild.Shader3D
Array is the domain repetition operation. It repeats domain centered around the origin (x,y,z)=(0,0,0).
func (*Builder) Array2D ¶
func (bld *Builder) Array2D(s glbuild.Shader2D, spacingX, spacingY float32, nx, ny int) glbuild.Shader2D
Array is the domain repetition operation. It repeats domain centered around (x,y)=(0,0).
func (*Builder) Bend ¶
Bend applies a constant-curvature bend: the child's +x axis curls toward +y for positive R (toward -y for negative R) onto a circle of radius |R| centered on the line (0, R, z). Distance to the center line and the z coordinate are preserved; the child's own x extent bends entirely (partial bends are boolean compositions).
The warp is the INVERSE of that image map — itself a polar transform about the same center (radius r = |p - center|, angle φ = atan2): the probe maps to child (|R|·φ, |R| - r), with rigid (isometric) tails beyond the child's x extent — the elongate clamp pattern — so the domain never folds or wraps. The inverse's Jacobian has singular values exactly (|R|/ρ, 1, 1), so evaluated distances are divided by lip = max(1, |R|/ρ_min). The bend axis must not cross the child's y extent (|R| smaller than the toward-center half-extent would fold the domain through the center line).
func (*Builder) CircularArray ¶
CircularArray is the circular domain repetition operation around the origin (x,y,z)=(0,0,0). It repeats the shape numInstances times and the spacing angle is defined by circleDiv such that angle = 2*pi/circleDiv. The operation is defined this way so that the argument shape is evaluated only twice per circular array evaluation, regardless of instances.
func (*Builder) CircularArray2D ¶
func (bld *Builder) CircularArray2D(s glbuild.Shader2D, numInstances, circleDiv int) glbuild.Shader2D
CircularArray2D is the circular domain repetition operation around the origin (x,y)=(0,0). It repeats the shape numInstances times and the spacing angle is defined by circleDiv such that angle = 2*pi/circleDiv. The operation is defined this way so that the argument shape is evaluated only twice per circular array evaluation, regardless of instances.
func (*Builder) ClearErrors ¶
func (bld *Builder) ClearErrors()
ClearErrors clears accumulated errors such that Builder.Err returns nil on next call.
func (*Builder) Difference ¶
Difference is the SDF difference of a-b. Does not produce a true SDF.
func (*Builder) Difference2D ¶
Difference2D is the SDF difference of a-b. Does not produce a true SDF.
func (*Builder) Elongate ¶
Elongate "stretches" the SDF in a direction by splitting it on the origin in the plane perpendicular to the argument direction. The part of the shape in the negative plane is discarded and replaced with the elongated positive part.
Arguments are distances, so zero-valued arguments are no-op.
func (*Builder) Elongate2D ¶
Elongate2D "stretches" the SDF in a direction by splitting it on the origin in the plane perpendicular to the argument direction. The part of the shape in the negative plane is discarded and replaced with the elongated positive part.
Arguments are distances, so zero-valued arguments are no-op.
func (*Builder) Err ¶
Err returns errors accumulated during SDF primitive creation and operations. The returned error implements `Unwrap() []error`.
func (*Builder) Extrude ¶
Extrude converts a 2D SDF into a 3D extrusion. Extrudes in both positive and negative Z direction, half of h both ways.
func (*Builder) Intersection ¶
Intersection is the SDF intersection of a ^ b. Does not produce an exact SDF.
func (*Builder) Intersection2D ¶
Intersection2D is the SDF intersection of a ^ b. Does not produce an exact SDF.
func (*Builder) NewArc ¶
NewArc returns a 2D arc centered at the origin (x,y)=(0,0) for a given radius and arc angle and thickness of the arc. The arc begins opening at (x,y)=(0,r) in both positive and negative x direction.
func (*Builder) NewBoundsBoxFrame ¶
NewBoundsBoxFrame creates a BoxFrame from a bb (ms3.Box) such that the BoxFrame envelops the bb. Useful for debugging bounding boxes of glbuild.Shader3D primitives and operations.
func (*Builder) NewBox ¶
NewBox creates a box centered at the origin with x,y,z dimensions and a rounding parameter to round edges.
func (*Builder) NewBoxFrame ¶
NewBoxFrame creates a framed box with the frame being composed of square beams of thickness e.
func (*Builder) NewCircle ¶
NewCircle creates a circle of a radius centered at the origin (x,y)=(0,0).
func (*Builder) NewCubicBezier2D ¶
func (bld *Builder) NewCubicBezier2D(points []ms2.Vec, segments int, thick float32) glbuild.Shader2D
NewCubicBezier2D creates a 2D SDF for a chain of cubic Bezier spans stroked with the given thickness (the tube of half-width thick around the curve). points holds 3n+1 control points: spans share endpoints, so (p0,p1,p2,p3), (p3,p4,p5,p6), ... Each span is evaluated exactly like NewQuadraticBezier2D does per segment, after splitting it into `segments` quadratic sub-spans — the authored facet dial of the section (deviation from the analytic cubic is O(1/segments²); no adaptive subdivision).
func (*Builder) NewCylinder ¶
NewCylinder creates a cylinder centered at the origin with given radius and height. The cylinder's axis points in z direction.
func (*Builder) NewDiamond2D ¶
NewDiamond2D creates a diamond (rhombus) centered at (x,y)=(0,0) with given x and y width and height dimensions, respectively.
func (*Builder) NewEllipse ¶
NewEllipse creates a 2D ellipse SDF with a and b ellipse parameters.
func (*Builder) NewEquilateralTriangle ¶
NewEquilateralTriangle creates an equilater triangle with a given height with it's centroid located at the origin.
func (*Builder) NewHexagon ¶
NewHexagon creates a regular hexagon centered at (x,y)=(0,0) with sides of length `side`.
func (*Builder) NewHexagonalPrism ¶
NewHexagonalPrism creates a hexagonal prism given a face-to-face dimension and height. The hexagon's length is in the z axis.
func (*Builder) NewLine2D ¶
NewLine2D creates a straight line between (x0,y0) and (x1,y1) with a given thickness.
func (*Builder) NewLines2D ¶
NewLines2D creates sequential straight lines between the argument points.
func (*Builder) NewOctagon ¶
NewOctagon returns a regular octagon 2D SDF with form that extend up to -constrain and constrain in both x and y axes.
func (*Builder) NewPolygon ¶
NewPolygon creates a polygon from a set of vertices. The polygon can be self-intersecting.
func (*Builder) NewQuadraticBezier2D ¶
NewQuadraticBezier2D creats an exact quadratic bezier SDF with three control points a, b, c. a and c lie on the bezier, b is a slope control point. Thick is the thickness of the curve.
func (*Builder) NewRectangle ¶
NewRectangle creates a rectangle centered at (x,y)=(0,0) with given x and y dimensions and r radius rounding.
func (*Builder) NewRoundedX ¶
NewRoundedX creates a two-dimensional X centered at (x,y)=(0,0) with given width and thickness/radius of lines.
func (*Builder) NewTorus ¶
NewTorus creates a 3D torus given 2 radii to define the radius across (greaterRadius) and the "solid" radius (lesserRadius). If the radius were cut and stretched straight to form a cylinder the lesser radius would be the radius of the cylinder. The torus' axis is in the z axis.
func (*Builder) NewTriangularPrism ¶
NewTriangularPrism creates a 3D triangular prism with a given triangle cross-sectional height (2D) and a extrude length. The prism's extrude axis is in the z axis direction.
func (*Builder) Offset ¶
Offset adds sdfAdd to the entire argument SDF. If sdfAdd is negative this will round edges and increase the dimension of flat surfaces of the SDF by the absolute magnitude. See Inigo's youtube video on the subject.
func (*Builder) Offset2D ¶
Offset2D adds sdfAdd to the entire argument SDF. If sdfAdd is negative this will round edges and increase the dimension of flat surfaces of the SDF by the absolute magnitude. See Inigo's youtube video on the subject.
func (*Builder) Revolve ¶
Revolve revolves a 2D SDF around the y axis, offsetting the axis of revolution by axisOffset.
func (*Builder) Rotate2D ¶
Rotate2D returns the argument shape rotated around the origin by theta (radians).
func (*Builder) Shell ¶
Shell carves the interior of the SDF leaving only the exterior shell of the part: the outer surface is preserved and an inner cavity is hollowed at the given wall thickness. The result fits inside the child's bounds.
func (*Builder) SmoothDifference ¶
SmoothDifference performs the difference of two SDFs with a smoothing parameter.
func (*Builder) SmoothDifferenceIn ¶
SmoothDifferenceIn subtracts sub from s with a region-scaled smoothing blend (see SmoothUnionIn for the region semantics).
func (*Builder) SmoothDifferenceRamp ¶
func (bld *Builder) SmoothDifferenceRamp(k0, k1 float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
SmoothDifferenceRamp subtracts sub from s with a ramped smoothing blend (see SmoothUnionRamp for the region and ramp semantics).
func (*Builder) SmoothIntersect ¶
SmoothIntersect performs the intesection of two SDFs with a smoothing parameter.
func (*Builder) SmoothIntersectIn ¶
SmoothIntersectIn intersects two shapes with a region-scaled smoothing blend (see SmoothUnionIn for the region semantics).
func (*Builder) SmoothIntersectRamp ¶
func (bld *Builder) SmoothIntersectRamp(k0, k1 float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
SmoothIntersectRamp intersects two shapes with a ramped smoothing blend (see SmoothUnionRamp for the region and ramp semantics).
func (*Builder) SmoothUnion ¶
SmoothUnion joins the shapes of two shaders into one with a smoothing blend.
func (*Builder) SmoothUnionIn ¶
SmoothUnionIn joins two shapes with a smoothing blend that is scaled by a region field: the blend is the full smooth-union kernel where region is negative (inside the region), tapers to the plain union where region exceeds k/2, and interpolates between over a transition width of k — one knob for both blend radius and falloff. This is the selective-fillet primitive: SmoothUnionIn(k, a, b, capsuleAroundTheEdge) rounds only that seam.
func (*Builder) SmoothUnionRamp ¶
func (bld *Builder) SmoothUnionRamp(k0, k1 float32, s1, s2, region glbuild.Shader3D) glbuild.Shader3D
SmoothUnionRamp joins two shapes with a smooth-union blend whose radius ramps linearly from k0 to k1 across a region field — the styling fillet that grows along a seam (2 mm meeting a shell, 6 mm at the handle root). The mask is the same SDF-region mechanism SmoothUnionIn uses, but its value both gates and positions: k_eff = S·lerp(k0, k1, S), S = smoothstep(clamp(0.5 − r/w)), w = max(k0, k1) — the blend tapers to the plain union over the transition (zero radius outside the region, no residual k0 blend beyond the mask) and reaches the full k1 kernel deep inside it. k0 == k1 degenerates exactly to SmoothUnionIn. k_eff is monotone in S for k1 ≥ k0; a strongly shrinking ramp (k0 > 2·k1) overshoots k1 by at most k0²/(4(k0−k1)) − k1 before settling — a non-monotone radius profile wants a composition of ramps over stacked regions, not this op. Shape the region so its iso-surfaces cross the seam on the stretch that ramps: a tilted slab sweeps k0→k1 along its slope.
func (*Builder) Symmetry2D ¶
Symmetry reflects the SDF around x or y (or both) axis.
func (*Builder) Taper ¶
Taper applies a scale field varying linearly along the child's own z extent: x and y are scaled by k0 at the child's z-min and k1 at its z-max (clamped outside), z untouched. This is the drafting warp — model in the natural axis, draft at export; rotate into place for other axes, as with Twist.
Lipschitz convention: the pullback's Jacobian is triangular [[1/s, 0, -x s'/s²], [0, 1/s, -y s'/s²], [0, 0, 1]] with s the local scale and s' its gradient, so distances can over-report by its spectral norm and are divided by a bound on it (the twist rule): σ² ≤ max row sum of JᵀJ over the child's extent = max(a²+aβ, β²+√2·aβ+1) with a = 1/min(k0,k1) and β = r_max·|k1-k0|/h / min(k0,k1)². The zero level set is lip-independent (division by a positive constant moves no surface), so the bound only affects culling aggressiveness, never geometry.
func (*Builder) Transform ¶
Transform applies a 4x4 matrix transformation to the argument shader by inverting the argument matrix.
func (*Builder) Translate ¶
Translate moves the SDF s in the given direction (dirX, dirY, dirZ) and returns the result.
func (*Builder) Translate2D ¶
Translate2D moves the SDF s in the given direction.
func (*Builder) TranslateMulti2D ¶
TranslateMulti2D displaces N instances of s SDF to positions given by displacements of length N.
func (*Builder) Twist ¶
Twist applies a twist deformation around the Z axis. The XY plane is rotated by k*z radians at height z.
Lipschitz convention: every operation is either 1-Lipschitz by construction (booleans min/max; offset ±d; shell max(d,-d-t); elongate clamp; symmetry mirror; array modulo; transforms via the inverse's spectral-norm renormalization) or carries a lip bound on its distance scaling and divides evaluated distances by it (transform, twist). Any future warp (bend, taper, ...) must follow one of the two and say which in a one-line comment.
func (*Builder) Union ¶
Union joins the shapes of several 3D SDFs into one. Is exact. Union aggregates nested Union results into its own. To prevent this behaviour use OpUnion directly.
func (*Builder) Union2D ¶
Union joins the shapes of several 2D SDFs into one. Is exact. Union aggregates nested Union results into its own.
type Flags ¶
type Flags uint64
Flags is a bitmask of values to control the functioning of the Builder type.
const ( // FlagNoDimensionPanic controls panicking behavior on invalid shape dimension errors. // If set then these errors do not panic, instead storing the error for later inspection with [Builder.Err]. FlagNoDimensionPanic Flags = 1 << iota // FlagUseShaderBuffers enforces the use of shader object for all newly built // SDFs which require a dynamic array(s) to be rendered correctly. FlagUseShaderBuffers // FlagNoShaderBuffers if set will cause the Builder to avoid all shader buffer usage, instead depending on // the shader program entirely for shape definition. FlagNoShaderBuffers )
type GridSDF ¶
type GridSDF struct {
// contains filtered or unexported fields
}
GridSDF is a signed distance field sampled on a dense axis-aligned lattice: (nx+1)*(ny+1)*(nz+1) corner values at `cell` spacing from `origin`, evaluated by trilinear interpolation. It is the substitution target for re-normalized fields (eikonal sweeps, baked grids): build the lattice, sweep, hand the grid to the mesher.
Outside the lattice box the field is conservative: the clamped interpolated edge value plus the distance to the box (axis-summed, an upper bound of Euclidean) on the outside — never under-reporting, so meshers keep every surface cube.
GridSDF is CPU-eval only: AppendShaderBody emits a clearly-marked placeholder (1e9) so accidental GLSL export of a grid model fails visibly at the surface, not silently at mesh time. AppendShaderName hashes the lattice geometry (origin/cell/dims) — values are not hashed, which is safe because the grid never evaluates on the GPU.
func NewGridSDF ¶
NewGridSDF builds a GridSDF from a corner-value lattice: vals holds (nx+1)*(ny+1)*(nz+1) samples at origin + cell*(i, j, k), indexed i + j*(nx+1) + k*(nx+1)*(ny+1) (x fastest). The slice is retained, not copied — callers own immutability while the grid is in use.
func (*GridSDF) AppendShaderBody ¶
AppendShaderBody emits the CPU-eval-only placeholder: a grid in a GLSL export is a modeling error, and a huge distance fails visibly (empty render) instead of silently.
func (*GridSDF) AppendShaderName ¶
AppendShaderName hashes the lattice geometry (origin, cell, dims); values are not hashed — the grid never evaluates on the GPU.
func (*GridSDF) AppendShaderObjects ¶
func (g *GridSDF) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject
AppendShaderObjects: no GPU objects.
type OpUnion ¶
type OpUnion struct {
// contains filtered or unexported fields
}
OpUnion is the result of the [Union] operation. Prefer using [Union] to using this type directly.
Normally primitives and results of operations in this package are not exported since their concrete type provides relatively little value. The result of Union is the exception to the rule since it is the most common operation to perform on SDFs and can provide several benefits to users seeking to optimize their SDFs creatively such as creating sectioned SDFs where conditional evaluation may be performed depending on the bounding boxes of the SDFs being evaluated.
By exporting OpUnion users can traverse a glbuild.Shader3D tree looking for OpUnion elements and checking how heavy their computation cost is and evaluating if sectioning their bounding box is effective.
func (*OpUnion) AppendShaderBody ¶
AppendShaderBody implements glbuild.Shader.
func (*OpUnion) AppendShaderName ¶
AppendShaderName implements glbuild.Shader.
func (*OpUnion) AppendShaderObjects ¶
func (u *OpUnion) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject
AppendShaderObjects implements glbuild.Shader. This method returns the argument buffer with no modifications. See glbuild.Shader for more information.
func (*OpUnion) Bounds ¶
Bounds returns the union of all joined SDFs. Implements glbuild.Shader3D and gleval.SDF3.
func (*OpUnion) CullGapSafe ¶
func (*OpUnion) Evaluate ¶
Evaluate implements gleval.SDF3. Children are culled per point: when the running distance at a point is already <= the gap to a child's bounding box (a lower bound on that child's distance), evaluating the child cannot lower the minimum, so the point is skipped for that child. Skipped points keep their value, so the result is bit-identical to evaluating every child.
func (*OpUnion) ForEachChild ¶
func (u *OpUnion) ForEachChild(userData any, fn func(userData any, s *glbuild.Shader3D) error) error
ForEachChild implements glbuild.Shader3D.
type OpUnion2D ¶
type OpUnion2D struct {
// contains filtered or unexported fields
}
OpUnion2D is the result of [Union2D]. This type is exported for special reasons, see OpUnion documentation.
func (*OpUnion2D) AppendShaderBody ¶
AppendShaderBody implements glbuild.Shader.
func (*OpUnion2D) AppendShaderName ¶
AppendShaderName implements glbuild.Shader.
func (*OpUnion2D) AppendShaderObjects ¶
func (u *OpUnion2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject
AppendShaderObjects implements glbuild.Shader. This method returns the argument buffer with no modifications. See glbuild.Shader for more information.
func (*OpUnion2D) Bounds ¶
Bounds returns the union of all joined SDFs. Implements glbuild.Shader2D and gleval.SDF2.
func (*OpUnion2D) Evaluate ¶
Evaluate implements gleval.SDF2. Same per-point child culling as OpUnion.Evaluate, gated on the same cull-safety property.
func (*OpUnion2D) ForEach2DChild ¶
func (u *OpUnion2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.Shader2D) error) error
ForEachChild implements glbuild.Shader2D.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
bolt
command
|
|
|
fibonacci-showerhead
command
|
|
|
gasket
command
|
|
|
image
command
|
|
|
image-text
command
|
|
|
knurled-cylinder
command
|
|
|
metric-spacers
command
|
|
|
mop-joint
command
|
|
|
npt-flange
command
|
|
|
plantpot
command
|
|
|
polarfire-icicle-kit-support
command
|
|
|
simple-knurled-cylinder
command
|
|
|
template-makers
command
|
|
|
test
command
|
|
|
ui-bolt
command
|
|
|
ui-geb
command
|
|
|
ui-mandala
command
|
|
|
ui-text
command
|
|
|
forge
|
|
|
wgsl/wgsllib
Package wgsllib is the WGSL twin of glbuild/glsllib: one hand-ported WGSL function per GLSL library function, same names, same parameters, same arithmetic (f32 throughout).
|
Package wgsllib is the WGSL twin of glbuild/glsllib: one hand-ported WGSL function per GLSL library function, same names, same parameters, same arithmetic (f32 throughout). |