Add color correction.
This commit is contained in:
parent
494b48c560
commit
a0de4cc8f1
7
color.h
7
color.h
@ -2,6 +2,7 @@
|
||||
#define COLOR_H
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
#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<int>(256 * clamp(r, 0.0, 0.999)) << " "
|
||||
<< static_cast<int>(256 * clamp(g, 0.0, 0.999)) << " "
|
||||
|
Loading…
Reference in New Issue
Block a user