flip: Gradual Polarity Inversion Function
Controlled Transition Between Value and Its Complement
The flip
function performs gradual polarity inversion by interpolating between a value and its complement (1-v). This enables controlled negative effects and bidirectional value transformations.
Mathematical Definition
For input value and transition parameter :
Transition States
Parameter | Mathematical Expression | Visual Result | Application |
---|---|---|---|
Original value | No inversion | ||
Neutral gray | 50% inversion | ||
Complete complement | Full inversion |
Bidirectional Property
The function exhibits symmetric behavior around the midpoint:
- Forward: as
- Reverse: as applied to
ライブエディター
const fragment = () => { const wave = uv.y.mul(20).add(iTime).sin().mul(0.5).add(0.5) const grad = uv.x.mul(wave) const color = vec3(uv.x, wave, grad) const amount = iTime.sin().abs() const flipped = flip(color, amount) return vec4(flipped, 1) }