From 1b72dceae8427a7e43bef44c7dbb47f53c0cb865 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Mon, 7 Apr 2025 01:33:07 +0200 Subject: Rewrite antialiasing downscale code --- graphics.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'graphics.c') 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), -- cgit v1.2.3