library: render: split bidirectional pathtracer
This commit is contained in:
parent
96995e7ef1
commit
fc2de38b1a
|
@ -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<Vector>) -> 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()
|
||||||
|
}
|
||||||
|
}
|
4
pathtracer/src/render/bidirectional/mod.rs
Normal file
4
pathtracer/src/render/bidirectional/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
mod path;
|
||||||
|
|
||||||
|
mod bidirectional_pathtracer;
|
||||||
|
pub use bidirectional_pathtracer::*;
|
|
@ -9,6 +9,9 @@ pub trait Renderer {
|
||||||
fn render(&self) -> RgbImage;
|
fn render(&self) -> RgbImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod bidirectional;
|
||||||
|
pub use bidirectional::*;
|
||||||
|
|
||||||
mod pathtrace;
|
mod pathtrace;
|
||||||
pub use pathtrace::*;
|
pub use pathtrace::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,2 @@
|
||||||
mod path;
|
|
||||||
|
|
||||||
mod pathtracer;
|
mod pathtracer;
|
||||||
pub use self::pathtracer::*;
|
pub use self::pathtracer::*;
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use super::super::Renderer;
|
use super::super::Renderer;
|
||||||
use super::path::*;
|
|
||||||
use crate::scene::Scene;
|
use crate::scene::Scene;
|
||||||
use crate::{Point, Vector};
|
|
||||||
use image::RgbImage;
|
use image::RgbImage;
|
||||||
use nalgebra::Unit;
|
|
||||||
|
|
||||||
/// Render the [`Scene`] using Bidirectional-Pathtracing
|
/// Render the [`Scene`] using Bidirectional-Pathtracing
|
||||||
///
|
///
|
||||||
|
@ -28,18 +25,6 @@ impl Pathtracer {
|
||||||
pub fn render(&self) -> RgbImage {
|
pub fn render(&self) -> RgbImage {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn construct_path(&self, point: Point, direction: Unit<Vector>) -> 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 {
|
impl Renderer for Pathtracer {
|
||||||
|
|
Loading…
Reference in a new issue