mx_safepower
A power function that safely handles negative base values, commonly used to symmetrically reshape signals in the [-1, 1] range, such as noise or lighting, with a non-linear curve.
Core Advantages
Its core advantage is avoiding the rendering errors of the standard `pow` function with negative inputs, while symmetrically processing both the positive and negative parts of a signal, fully preserving and adjusting its dynamic range.
Common Uses
Custom procedural falloffs and masks
Controlling Non-Photorealistic Rendering (NPR) lighting
Shaping procedural displacement maps
How to adjust
It's mainly adjusted by the exponent `in2`. An exponent greater than 1 makes the curve steeper at the ends and flatter in the middle, increasing contrast for a "sharper" effect. An exponent less than 1 does the opposite, making the curve steeper in the middle and flatter at the ends for a "rounder," softer effect.
Code Examples
1// Apply a safe power operation to a [-1, 1] signal to adjust its curve
2const result = mx_safepower( mySignal, exponent );