library: scene: rename aliasing_limit to shot_rays

This commit is contained in:
Bruno BELANYI 2020-03-31 12:08:15 +02:00
parent e68ceb484d
commit d4345e6ea4
2 changed files with 9 additions and 9 deletions

View file

@ -46,7 +46,7 @@ impl Raytracer {
"{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", "{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 Self::anti_alias_pixel
} else { } else {
Self::pixel Self::pixel
@ -90,7 +90,7 @@ impl Raytracer {
/// Get pixel color with anti-aliasing /// Get pixel color with anti-aliasing
fn anti_alias_pixel(&self, x: f32, y: f32) -> LinearColor { 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 mut rng = thread_rng();
let acc: LinearColor = range let acc: LinearColor = range
.map(|_| { .map(|_| {
@ -100,7 +100,7 @@ impl Raytracer {
}) })
.map(LinearColor::clamp) .map(LinearColor::clamp)
.sum(); .sum();
acc / self.scene.aliasing_limit as f32 acc / self.scene.shot_rays as f32
} }
fn cast_ray(&self, ray: Ray) -> Option<(f32, &Object)> { fn cast_ray(&self, ray: Ray) -> Option<(f32, &Object)> {

View file

@ -14,7 +14,7 @@ pub struct Scene {
pub(crate) objects: Vec<Object>, pub(crate) objects: Vec<Object>,
pub(crate) bvh: BVH, pub(crate) bvh: BVH,
pub(crate) background: LinearColor, pub(crate) background: LinearColor,
pub(crate) aliasing_limit: u32, pub(crate) shot_rays: u32,
pub(crate) reflection_limit: u32, pub(crate) reflection_limit: u32,
pub(crate) diffraction_index: f32, pub(crate) diffraction_index: f32,
} }
@ -49,7 +49,7 @@ impl Scene {
/// ), /// ),
/// ], /// ],
/// LinearColor::black(), // Background color /// LinearColor::black(), // Background color
/// 5, // aliasing limit /// 5, // amount of rays shot per pixel
/// 3, // reflection recursion limit /// 3, // reflection recursion limit
/// 0.0, // diffraction index /// 0.0, // diffraction index
/// ); /// );
@ -59,7 +59,7 @@ impl Scene {
lights: LightAggregate, lights: LightAggregate,
mut objects: Vec<Object>, mut objects: Vec<Object>,
background: LinearColor, background: LinearColor,
aliasing_limit: u32, shot_rays: u32,
reflection_limit: u32, reflection_limit: u32,
diffraction_index: f32, diffraction_index: f32,
) -> Self { ) -> Self {
@ -70,7 +70,7 @@ impl Scene {
objects, objects,
bvh, bvh,
background, background,
aliasing_limit, shot_rays,
reflection_limit, reflection_limit,
diffraction_index, diffraction_index,
} }
@ -90,7 +90,7 @@ struct SerializedScene {
#[serde(default)] #[serde(default)]
background: LinearColor, background: LinearColor,
#[serde(default)] #[serde(default)]
aliasing_limit: u32, shot_rays: u32,
#[serde(default)] #[serde(default)]
reflection_limit: u32, reflection_limit: u32,
#[serde(default = "crate::serialize::default_identity")] #[serde(default = "crate::serialize::default_identity")]
@ -112,7 +112,7 @@ impl From<SerializedScene> for Scene {
scene.lights, scene.lights,
scene.objects, scene.objects,
scene.background, scene.background,
scene.aliasing_limit, scene.shot_rays,
scene.reflection_limit, scene.reflection_limit,
scene.starting_diffraction, scene.starting_diffraction,
) )