library: render: split bidirectional pathtracer

This commit is contained in:
Bruno BELANYI 2020-04-01 23:58:27 +02:00
parent 96995e7ef1
commit fc2de38b1a
6 changed files with 56 additions and 17 deletions

View file

@ -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()
}
}

View file

@ -0,0 +1,4 @@
mod path;
mod bidirectional_pathtracer;
pub use bidirectional_pathtracer::*;

View file

@ -9,6 +9,9 @@ pub trait Renderer {
fn render(&self) -> RgbImage;
}
mod bidirectional;
pub use bidirectional::*;
mod pathtrace;
pub use pathtrace::*;

View file

@ -1,4 +1,2 @@
mod path;
mod pathtracer;
pub use self::pathtracer::*;

View file

@ -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<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 {