diff --git a/pathtracer/src/render/mod.rs b/pathtracer/src/render/mod.rs index 1e2b4b2..d502605 100644 --- a/pathtracer/src/render/mod.rs +++ b/pathtracer/src/render/mod.rs @@ -18,4 +18,5 @@ pub use pathtrace::*; mod raytrace; pub use raytrace::*; +pub(crate) mod progress; pub(crate) mod utils; diff --git a/pathtracer/src/render/progress.rs b/pathtracer/src/render/progress.rs new file mode 100644 index 0000000..30698ee --- /dev/null +++ b/pathtracer/src/render/progress.rs @@ -0,0 +1,10 @@ +use indicatif::ProgressBar; + +pub fn get_progressbar(total: u64) -> ProgressBar { + let pb = ProgressBar::new(total); + pb.set_draw_delta(total / 10000); + pb.set_style(indicatif::ProgressStyle::default_bar().template( + "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", + )); + pb +} diff --git a/pathtracer/src/render/raytrace/raytracer.rs b/pathtracer/src/render/raytrace/raytracer.rs index 19b50dc..8aceb29 100644 --- a/pathtracer/src/render/raytrace/raytracer.rs +++ b/pathtracer/src/render/raytrace/raytracer.rs @@ -40,11 +40,7 @@ impl Raytracer { ); let total = (image.width() * image.height()) as u64; - let pb = indicatif::ProgressBar::new(total); - pb.set_draw_delta(total / 10000); - pb.set_style(indicatif::ProgressStyle::default_bar().template( - "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", - )); + let pb = super::super::progress::get_progressbar(total); let pixel_func = if self.scene.shot_rays > 0 { Self::anti_alias_pixel