From d4345e6ea4acea4bee9dadc187dabcc9435ab238 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 31 Mar 2020 12:08:15 +0200 Subject: [PATCH] library: scene: rename aliasing_limit to shot_rays --- pathtracer/src/render/raytracer.rs | 6 +++--- pathtracer/src/scene/scene.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pathtracer/src/render/raytracer.rs b/pathtracer/src/render/raytracer.rs index b6c564d..6757772 100644 --- a/pathtracer/src/render/raytracer.rs +++ b/pathtracer/src/render/raytracer.rs @@ -46,7 +46,7 @@ impl Raytracer { "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", )); - let pixel_func = if self.scene.aliasing_limit > 0 { + let pixel_func = if self.scene.shot_rays > 0 { Self::anti_alias_pixel } else { Self::pixel @@ -90,7 +90,7 @@ impl Raytracer { /// Get pixel color with anti-aliasing fn anti_alias_pixel(&self, x: f32, y: f32) -> LinearColor { - let range = 0..self.scene.aliasing_limit; + let range = 0..self.scene.shot_rays; let mut rng = thread_rng(); let acc: LinearColor = range .map(|_| { @@ -100,7 +100,7 @@ impl Raytracer { }) .map(LinearColor::clamp) .sum(); - acc / self.scene.aliasing_limit as f32 + acc / self.scene.shot_rays as f32 } fn cast_ray(&self, ray: Ray) -> Option<(f32, &Object)> { diff --git a/pathtracer/src/scene/scene.rs b/pathtracer/src/scene/scene.rs index db4ca83..6bf9386 100644 --- a/pathtracer/src/scene/scene.rs +++ b/pathtracer/src/scene/scene.rs @@ -14,7 +14,7 @@ pub struct Scene { pub(crate) objects: Vec, pub(crate) bvh: BVH, pub(crate) background: LinearColor, - pub(crate) aliasing_limit: u32, + pub(crate) shot_rays: u32, pub(crate) reflection_limit: u32, pub(crate) diffraction_index: f32, } @@ -49,7 +49,7 @@ impl Scene { /// ), /// ], /// LinearColor::black(), // Background color - /// 5, // aliasing limit + /// 5, // amount of rays shot per pixel /// 3, // reflection recursion limit /// 0.0, // diffraction index /// ); @@ -59,7 +59,7 @@ impl Scene { lights: LightAggregate, mut objects: Vec, background: LinearColor, - aliasing_limit: u32, + shot_rays: u32, reflection_limit: u32, diffraction_index: f32, ) -> Self { @@ -70,7 +70,7 @@ impl Scene { objects, bvh, background, - aliasing_limit, + shot_rays, reflection_limit, diffraction_index, } @@ -90,7 +90,7 @@ struct SerializedScene { #[serde(default)] background: LinearColor, #[serde(default)] - aliasing_limit: u32, + shot_rays: u32, #[serde(default)] reflection_limit: u32, #[serde(default = "crate::serialize::default_identity")] @@ -112,7 +112,7 @@ impl From for Scene { scene.lights, scene.objects, scene.background, - scene.aliasing_limit, + scene.shot_rays, scene.reflection_limit, scene.starting_diffraction, )