From a0de4cc8f19494f1eb7340be966c86f2c2527a4a Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sat, 6 Jun 2020 14:57:55 +0200 Subject: [PATCH] Add color correction. --- color.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/color.h b/color.h index 4e0b86d..6434d90 100644 --- a/color.h +++ b/color.h @@ -2,6 +2,7 @@ #define COLOR_H #include +#include #include "vec3.h" #include "util.h" @@ -12,9 +13,9 @@ void write_color(std::ostream &out, Color pixel_color, int sample_per_pixel) { auto b = pixel_color.z(); auto scale = 1.0 / sample_per_pixel; - r *= scale; - g *= scale; - b *= scale; + r = std::sqrt(scale * r); + g = std::sqrt(scale * g); + b = std::sqrt(scale * b); out << static_cast(256 * clamp(r, 0.0, 0.999)) << " " << static_cast(256 * clamp(g, 0.0, 0.999)) << " "