Add color correction.

This commit is contained in:
Faerbit 2020-06-06 14:57:55 +02:00
parent 494b48c560
commit a0de4cc8f1

View File

@ -2,6 +2,7 @@
#define COLOR_H #define COLOR_H
#include <iostream> #include <iostream>
#include <cmath>
#include "vec3.h" #include "vec3.h"
#include "util.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 b = pixel_color.z();
auto scale = 1.0 / sample_per_pixel; auto scale = 1.0 / sample_per_pixel;
r *= scale; r = std::sqrt(scale * r);
g *= scale; g = std::sqrt(scale * g);
b *= scale; b = std::sqrt(scale * b);
out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << " " out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << " "
<< static_cast<int>(256 * clamp(g, 0.0, 0.999)) << " " << static_cast<int>(256 * clamp(g, 0.0, 0.999)) << " "