diff options
Diffstat (limited to '')
| -rw-r--r-- | src/main/resources/shaders/modules/utils.glsl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/resources/shaders/modules/utils.glsl b/src/main/resources/shaders/modules/utils.glsl index 3520df1..10e3a48 100644 --- a/src/main/resources/shaders/modules/utils.glsl +++ b/src/main/resources/shaders/modules/utils.glsl @@ -7,9 +7,30 @@ float ssubtract(float a, float b, float k) { return -smin(-a, b, k); } +// Easing +float ease_in_out_quart(in float x) { + return x < 0.5 ? 8 * x * x * x * x : 1 - pow(-2 * x + 2, 4) / 2; +} +vec2 ease_in_out_quart(in vec2 v) { + return vec2(ease_in_out_quart(v.x), ease_in_out_quart(v.y)); +} + +// Color utils vec3 srgb(float r, float g, float b) { return vec3(pow(r, 2.2), pow(g, 2.2), pow(b, 2.2)); } vec3 srgb(vec3 c) { return srgb(c.r, c.g, c.b); } +vec3 srgb(float c) { + return srgb(c, c, c); +} + +vec3 saturation(vec3 color, float s) { + float y = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; + return vec3( + y + s * (color.r - y), + y + s * (color.g - y), + y + s * (color.b - y) + ); +} |
