diff --git a/pathtracer/src/render/bidirectional/bidirectional_pathtracer.rs b/pathtracer/src/render/bidirectional/bidirectional_pathtracer.rs new file mode 100644 index 0000000..880b97c --- /dev/null +++ b/pathtracer/src/render/bidirectional/bidirectional_pathtracer.rs @@ -0,0 +1,49 @@ +use super::super::Renderer; +use super::path::*; +use crate::scene::Scene; +use crate::{Point, Vector}; +use image::RgbImage; +use nalgebra::Unit; + +/// Render the [`Scene`] using Bidirectional-Pathtracing +/// +/// [`Scene`]: ../scene/scene/struct.Scene.html +pub struct BidirectionalPathtracer { + #[allow(unused)] + scene: Scene, +} + +impl BidirectionalPathtracer { + /// Create a [`BidirectionalPathtracer`] renderer with the given [`Scene`] + /// + /// [`BidirectionalPathtracer`]: struct.BidirectionalPathtracer.html + /// [`Scene`]: ../scene/scene/struct.Scene.html + pub fn new(scene: Scene) -> Self { + BidirectionalPathtracer { scene } + } + + /// Render the [`Scene`] using Bidirectional-Pathtracing. + /// + /// [`Scene`]: ../scene/scene/struct.Scene.html + pub fn render(&self) -> RgbImage { + todo!() + } + + fn construct_path(&self, point: Point, direction: Unit) -> Path { + let mut res = Path::new(point); + for _ in 0..self.scene.reflection_limit { + // FIXME: + // * cast_ray: if no intersection, return the empty path + // * look-up information at intersection + // * append to path + // * start again with new origin + } + res + } +} + +impl Renderer for BidirectionalPathtracer { + fn render(&self) -> RgbImage { + self.render() + } +} diff --git a/pathtracer/src/render/bidirectional/mod.rs b/pathtracer/src/render/bidirectional/mod.rs new file mode 100644 index 0000000..656d62b --- /dev/null +++ b/pathtracer/src/render/bidirectional/mod.rs @@ -0,0 +1,4 @@ +mod path; + +mod bidirectional_pathtracer; +pub use bidirectional_pathtracer::*; diff --git a/pathtracer/src/render/pathtrace/path.rs b/pathtracer/src/render/bidirectional/path.rs similarity index 100% rename from pathtracer/src/render/pathtrace/path.rs rename to pathtracer/src/render/bidirectional/path.rs diff --git a/pathtracer/src/render/mod.rs b/pathtracer/src/render/mod.rs index 2da13a2..2e62f69 100644 --- a/pathtracer/src/render/mod.rs +++ b/pathtracer/src/render/mod.rs @@ -9,6 +9,9 @@ pub trait Renderer { fn render(&self) -> RgbImage; } +mod bidirectional; +pub use bidirectional::*; + mod pathtrace; pub use pathtrace::*; diff --git a/pathtracer/src/render/pathtrace/mod.rs b/pathtracer/src/render/pathtrace/mod.rs index 5f3e759..dd2cbdd 100644 --- a/pathtracer/src/render/pathtrace/mod.rs +++ b/pathtracer/src/render/pathtrace/mod.rs @@ -1,4 +1,2 @@ -mod path; - mod pathtracer; pub use self::pathtracer::*; diff --git a/pathtracer/src/render/pathtrace/pathtracer.rs b/pathtracer/src/render/pathtrace/pathtracer.rs index 6d113ab..bba0c76 100644 --- a/pathtracer/src/render/pathtrace/pathtracer.rs +++ b/pathtracer/src/render/pathtrace/pathtracer.rs @@ -1,9 +1,6 @@ use super::super::Renderer; -use super::path::*; use crate::scene::Scene; -use crate::{Point, Vector}; use image::RgbImage; -use nalgebra::Unit; /// Render the [`Scene`] using Bidirectional-Pathtracing /// @@ -28,18 +25,6 @@ impl Pathtracer { pub fn render(&self) -> RgbImage { todo!() } - - fn construct_path(&self, point: Point, direction: Unit) -> Path { - let mut res = Path::new(point); - for _ in 0..self.scene.reflection_limit { - // FIXME: - // * cast_ray: if no intersection, return the empty path - // * look-up information at intersection - // * append to path - // * start again with new origin - } - res - } } impl Renderer for Pathtracer {