library: render: pathtracer: simple progress
This commit is contained in:
parent
82dee9fde5
commit
9596bb3d00
|
@ -23,13 +23,16 @@ beevee = { path = "../beevee" }
|
||||||
derive_more = "0.99.3"
|
derive_more = "0.99.3"
|
||||||
enum_dispatch = "0.2.1"
|
enum_dispatch = "0.2.1"
|
||||||
image = "0.23.0"
|
image = "0.23.0"
|
||||||
indicatif = "0.14.0"
|
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
rayon = "1.3.0"
|
rayon = "1.3.0"
|
||||||
serde_yaml = "0.8"
|
serde_yaml = "0.8"
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
tobj = "1.0"
|
tobj = "1.0"
|
||||||
|
|
||||||
|
[dependencies.indicatif]
|
||||||
|
version = "0.14"
|
||||||
|
features = ["with_rayon"]
|
||||||
|
|
||||||
[dependencies.nalgebra]
|
[dependencies.nalgebra]
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
features = ["serde-serialize"]
|
features = ["serde-serialize"]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use indicatif::ParallelProgressIterator;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use super::super::utils::{buffer_to_image, sample_hemisphere};
|
use super::super::utils::{buffer_to_image, sample_hemisphere};
|
||||||
|
@ -43,6 +44,7 @@ impl Pathtracer {
|
||||||
// Ensure at least one round of shots
|
// Ensure at least one round of shots
|
||||||
let img_buf = (0..self.scene.shot_rays.max(1))
|
let img_buf = (0..self.scene.shot_rays.max(1))
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
|
.progress_with(p)
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
let mut buffer: Vec<LinearColor> = Vec::new();
|
let mut buffer: Vec<LinearColor> = Vec::new();
|
||||||
buffer.resize_with(total as usize, LinearColor::black);
|
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);
|
buffer[i as usize] += self.pixel_ray(x as f32, y as f32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.inc(1); // Increment the number of passes
|
|
||||||
|
|
||||||
buffer
|
buffer
|
||||||
})
|
})
|
||||||
|
@ -72,8 +73,6 @@ impl Pathtracer {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
p.finish();
|
|
||||||
|
|
||||||
buffer_to_image(img_buf, self.scene.shot_rays, width, height)
|
buffer_to_image(img_buf, self.scene.shot_rays, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue