From 1e83ea211055eb234b89c69b5d03602e3fcb98fb Mon Sep 17 00:00:00 2001 From: Julian T Date: Fri, 5 Feb 2021 20:17:20 +0100 Subject: Achieve anti aliasing with multi pixel sampling --- src/camera/film.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/camera/film.rs') diff --git a/src/camera/film.rs b/src/camera/film.rs index 3586374..7193e1d 100644 --- a/src/camera/film.rs +++ b/src/camera/film.rs @@ -45,7 +45,7 @@ impl Pixel { } fn finalize_rgb(&self) -> [u8; 3] { - let (r, g, b) = self.rgb.to_rgb(255.0); + let (r, g, b) = (&self.rgb / (self.samples as Float)).to_rgb(255.0); [ r as u8, g as u8, @@ -128,8 +128,8 @@ impl FilmTile { } /// Add a single sample sampled from the scene - pub fn add_sample(&mut self, point: &Vector2f, c: Spectrum) { - let point = Vector2i::from(point.floor()); + pub fn add_sample(&mut self, inp: &Vector2f, c: Spectrum) { + let point = Vector2i::from(inp.floor()); // Subtract the offset let point = point - self.bounds.min; -- cgit v1.2.3