spiralSDF: Logarithmic Spiral Pattern Generator
Mathematical Spiral Construction in 2D Space
The spiralSDF
function creates intricate spiral patterns by combining logarithmic radius transformation with angular positioning. This function generates distance fields that follow logarithmic spiral mathematics, producing visually appealing rotational patterns.
Mathematical Foundation
The spiral function operates through polar coordinate transformation:
where:
- represents the squared distance from center
- provides angular position
- controls spiral tightness and frequency
- normalizes angular scaling
The logarithmic transformation creates exponentially expanding spiral arms, while the fractional component generates periodic repetition.
Function Signature
Parameter | Type | Description |
---|---|---|
st | vec2 | 2D coordinate position |
t | float | Spiral frequency and tightness control |
Implementation Demonstrations
ライブエディター
const fragment = () => { const coord = uv.mul(2).sub(1) const time = iTime.mul(0.1) const spiral1 = spiralSDF(coord.mul(0.5).add(0.5), time.add(2)) const spiral2 = spiralSDF(coord.mul(0.7).add(0.5), time.mul(1.3).add(4)) const pattern = spiral1.mul(spiral2) const color = pattern.pow(0.5).mul(vec3(1, 0.7, 0.4)) return vec4(color, 1) }