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)) << " "