mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-02-01 11:34:59 +01:00
16 lines
398 B
GLSL
16 lines
398 B
GLSL
float srgb2linear(float x) {
|
|
// sRGB to linear conversion
|
|
float lower = x / 12.92;
|
|
float upper = pow((x + 0.055f) / 1.055f, 2.4f);
|
|
|
|
return mix(lower, upper, step(0.04045f, x));
|
|
}
|
|
|
|
float linear2srgb(float x) {
|
|
// Linear to sRGB conversion.
|
|
float lower = 12.92 * x;
|
|
float upper = 1.055 * pow(x, 1.0f / 2.4f) - 0.055f;
|
|
|
|
return mix(lower, upper, step(0.0031308f, x));
|
|
}
|