From 643708a9922cabe9b37329ee41a8668087dc92d7 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sun, 20 Dec 2020 22:42:37 +0100 Subject: Add a camera class --- src/color.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/color.cpp') 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(255.0 * pixel_color.x) << ' ' - << static_cast(255.0 * pixel_color.y) << ' ' - << static_cast(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(255.0 * scaled_color.x) << ' ' + << static_cast(255.0 * scaled_color.y) << ' ' + << static_cast(255.0 * scaled_color.z) << std::endl; } -- cgit v1.3