summaryrefslogtreecommitdiff
path: root/graphics.c
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.c')
-rwxr-xr-xgraphics.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/graphics.c b/graphics.c
index bb800ad..e46dca5 100755
--- a/graphics.c
+++ b/graphics.c
@@ -961,6 +961,18 @@ vec4_f32 vec4_f32_lerp(vec4_f32 a, vec4_f32 b, f32 t) {
// ================================================================
+static f64 gamma_(f64 x) {
+ if (x >= 0.0031308)
+ return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
+ return 12.92 * x;
+}
+
+static f64 gamma_re_(f64 x) {
+ if (x >= 0.04045)
+ return pow((x + 0.055) / 1.055, 2.4);
+ return x / 12.92;
+}
+
vec3_f32 rgb_gamma_add(vec3_f32 rgb) {
return (vec3_f32) {
.x = (f32) gamma_(rgb.x),