diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2020-12-20 22:42:37 +0100 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2020-12-20 22:42:37 +0100 |
| commit | 643708a9922cabe9b37329ee41a8668087dc92d7 (patch) | |
| tree | e4052ae5b08569d97af39afc8456852d836d6c9f /src/color.cpp | |
| parent | 44c1eec63fc51d1a4eb888cde5e8f4b874876bab (diff) | |
Add a camera class
Diffstat (limited to 'src/color.cpp')
| -rw-r--r-- | src/color.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/color.cpp b/src/color.cpp index 53a79f9..b0e60e1 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -1,7 +1,11 @@ #include "color.hpp" -void write_color(std::ostream& out, const color& pixel_color) { - out << static_cast<uint32_t>(255.0 * pixel_color.x) << ' ' - << static_cast<uint32_t>(255.0 * pixel_color.y) << ' ' - << static_cast<uint32_t>(255.0 * pixel_color.z) << std::endl; +void write_color(std::ostream& out, const color& pixel_color, uint32_t samples_per_pixel) { + + auto scale = 1.0 / samples_per_pixel; + auto scaled_color = pixel_color * scale; + + out << static_cast<uint32_t>(255.0 * scaled_color.x) << ' ' + << static_cast<uint32_t>(255.0 * scaled_color.y) << ' ' + << static_cast<uint32_t>(255.0 * scaled_color.z) << std::endl; } |
