sin(x+t)/(0.4+0.4*abs(sin(x+t)))
Explaining \( f(x) = \dfrac{\cos(x)}{0.4 + 0.4\,|\cos(x)|} \)
This page explains the wave-shaping idea behind dividing cos(x)
by a term that depends on its own magnitude.
Target function:
\\[ f(x) = \frac{\cos(x)}{0.4 + 0.4\,\lvert \cos(x)\rvert} \\]
Value ranges: \( \cos(x)\in[-1,1] \) and \( 0.4 + 0.4\,|\cos(x)| \in [0.4,\,0.8] \).
1) Numerator: \( \cos(x) \)
The base signal is a standard cosine: period \(2\pi\) and amplitude within \([-1,1]\).
2) Denominator: \( 0.4 + 0.4\,|\cos(x)| \)
Because \( |\cos(x)| \in [0,1] \), the denominator varies smoothly between 0.4 (when \( \cos(x)=0 \)) and 0.8 (when \( |\cos(x)|=1 \)).
3) Net Effect (Wave Rounding)
Where \( |\cos(x)| \) is large (near peaks/valleys), the denominator is larger, so the output is pushed smaller.
Where \( |\cos(x)| \) is small (near zero crossings), the denominator is smaller, so the output is slightly larger.
This redistributes amplitude and visually “rounds” the sharp crests and troughs of a cosine—handy for shader aesthetics.
4) Intuition
Think of it as a gentle, signal-dependent normalization: the wave compresses more at extremes and less around zero, yielding a smoother, more rounded profile.
5) Notes for Shaders
- Use directly as a fragment-space curve or to modulate color/normal intensity.
- To adjust the rounding strength, replace
0.4
by a parameter \(a\in(0,1]\): \( \cos(x)/(a+a|\cos x|) \). - Clamp \(a\) away from zero to avoid division blow-ups.
Comments
Post a Comment