メインコンテンツまでスキップ

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:

drhombus(p)=max(dtri(p),dtri(p))d_{rhombus}(p) = \max(d_{tri}(p), d_{tri}(p'))

where pp' represents the vertically flipped coordinate (px,1py)(p_x, 1 - p_y) 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

ParameterTypeDescription
stvec22D coordinate position

Implementation Demonstrations

ライブエディター
const fragment = () => {
      const dist = rhombSDF(uv)
      return vec4(vec3(dist), 1)
}