summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-03-28 14:45:19 -0700
committeryum <yum.food.vr@gmail.com>2026-03-28 14:47:24 -0700
commitb7c4d1bf622f057cf8e88754a089157300818ae3 (patch)
treee950f46b370e750f0c271ada4fe1b726d6378963 /math.cginc
parent5b732ae3d8bf19d4fbade236f318df0f7221cdd2 (diff)
Finish implementing burley per-channel histogram preserving blending operator
Diffstat (limited to 'math.cginc')
-rwxr-xr-xmath.cginc12
1 files changed, 12 insertions, 0 deletions
diff --git a/math.cginc b/math.cginc
index 0f5f8f5..6bca086 100755
--- a/math.cginc
+++ b/math.cginc
@@ -251,4 +251,16 @@ float median(float3 x) {
return (x.r + x.g + x.b) - (x_min + x_max);
}
+float3 linear_to_srgb(float3 linear_color) {
+ float3 lo = 12.92f * linear_color;
+ float3 hi = 1.055f * pow(linear_color, 1.0f / 2.4f) - 0.055f;
+ return lerp(lo, hi, step(0.0031308f, linear_color));
+}
+
+float3 srgb_to_linear(float3 srgb_color) {
+ float3 lo = srgb_color / 12.92f;
+ float3 hi = pow((srgb_color + 0.055f) / 1.055f, 2.4f);
+ return lerp(lo, hi, step(0.04045f, srgb_color));
+}
+
#endif // __MATH_INC