aboutsummaryrefslogtreecommitdiffstats
path: root/src/color.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/color.cpp')
-rw-r--r--src/color.cpp12
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;
}