gain
Maps an input value (typically in the 0-1 range) to an S-shaped curve based on a gain parameter `k`, providing an intuitive way to adjust contrast.
Core Advantages
It encapsulates a complex, piecewise S-curve function into a single call, offering an intuitive `k` parameter to control contrast while preserving the black, white, and mid-gray points of the input, making it ideal for artistic adjustments.
Common Uses
Enhancing the contrast of procedural textures (like noise) to create sharper edges.
Adjusting terrain heightmaps to create more dramatic or gentler topography.
Adding easing (slow-fast-slow) to animated transitions, such as wipes.
Artistically controlling light falloff curves.
How to adjust
Controlled primarily by the `k` parameter. `k=1` is linear (no effect). `k > 1` increases contrast, steepening the S-curve and pushing mid-tones to the extremes. `k < 1` decreases contrast, flattening the curve and making the image appear 'grayer'. Connecting `k` to a `timer` node can create a dynamic, 'breathing' contrast effect.
Code Examples
1// Sharpen the contrast of a noise texture to create crisper edges
2const sharpNoise = gain( perlinNoise( uv() ), 2.5 );