library: render: pathtracer: simple progress

This commit is contained in:
Antoine Martin 2020-04-07 23:32:34 +02:00
parent 82dee9fde5
commit 9596bb3d00
2 changed files with 6 additions and 4 deletions

View file

@ -23,13 +23,16 @@ beevee = { path = "../beevee" }
derive_more = "0.99.3"
enum_dispatch = "0.2.1"
image = "0.23.0"
indicatif = "0.14.0"
rand = "0.7"
rayon = "1.3.0"
serde_yaml = "0.8"
structopt = "0.3"
tobj = "1.0"
[dependencies.indicatif]
version = "0.14"
features = ["with_rayon"]
[dependencies.nalgebra]
version = "0.20.0"
features = ["serde-serialize"]

View file

@ -1,3 +1,4 @@
use indicatif::ParallelProgressIterator;
use rayon::prelude::*;
use super::super::utils::{buffer_to_image, sample_hemisphere};
@ -43,6 +44,7 @@ impl Pathtracer {
// Ensure at least one round of shots
let img_buf = (0..self.scene.shot_rays.max(1))
.into_par_iter()
.progress_with(p)
.map(|_| {
let mut buffer: Vec<LinearColor> = Vec::new();
buffer.resize_with(total as usize, LinearColor::black);
@ -53,7 +55,6 @@ impl Pathtracer {
buffer[i as usize] += self.pixel_ray(x as f32, y as f32);
}
}
p.inc(1); // Increment the number of passes
buffer
})
@ -72,8 +73,6 @@ impl Pathtracer {
},
);
p.finish();
buffer_to_image(img_buf, self.scene.shot_rays, width, height)
}