Remove duplicate definitions of linear2srgb functions in shaders

This commit is contained in:
Kovid Goyal
2023-06-13 14:54:20 +05:30
parent 444ec2484d
commit 288bb034b5
17 changed files with 41 additions and 61 deletions

15
kitty/linear2srgb.glsl Normal file
View File

@@ -0,0 +1,15 @@
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));
}