fuckingtech/public/assets/glsl/lygia/math/gain.msl
Elias Rhouzlane bf76c6b086 fix: code
2025-04-06 17:23:52 +02:00

16 lines
No EOL
589 B
Text

/*
contributors: Inigo Quiles
description: |
Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function. From https://iquilezles.org/articles/functions/
use: <float> gain(<float> x, <float> k)
examples:
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/math_functions.frag
*/
#ifndef FNC_GAIN
#define FNC_GAIN
float gain(float x, float k) {
float a = 0.5 * pow(2.0*((x<0.5)? x : 1.0-x), k);
return (x < 0.5) ? a : 1.0-a;
}
#endif