rhombSDF: Diamond Shape Distance Field
Composite Geometry from Triangle Intersection
The rhombSDF
function creates a rhombus (diamond) shape by combining two triangular distance fields. This approach demonstrates geometric composition through the maximum operation of transformed triangle primitives.
Mathematical Foundation
The rhombus is constructed by taking the maximum distance of two triangles:
where represents the vertically flipped coordinate for the second triangle.
The maximum operation creates the intersection of the two triangular half-spaces, forming the characteristic diamond shape with four equal sides meeting at right angles.
Function Signature
Parameter | Type | Description |
---|---|---|
st | vec2 | 2D coordinate position |
Implementation Demonstrations
Live Editor
const fragment = () => { const dist = rhombSDF(uv) return vec4(vec3(dist), 1) }