Add initial MIS implementation

This commit is contained in:
hal8174 2025-01-05 23:52:41 +01:00
parent ba2d853319
commit d43d60bb85
10 changed files with 161 additions and 3 deletions

View file

@ -10,6 +10,11 @@ pub trait Material<R: Rng>: Send + Sync + Debug {
SampleResult::new(w_out, self.eval(w_in, w_out, rng) * FloatConsts::PI)
}
fn pdf(&self, w_in: Dir3, w_out: Dir3) -> Float {
let _ = w_out;
FloatConsts::FRAC_1_PI * Float::max(w_in.y(), 0.0)
}
}
#[derive(Debug)]

View file

@ -18,6 +18,7 @@ pub struct Intersection<'sc, R: Rng> {
normal: Dir3,
material: Option<&'sc dyn Material<R>>,
light: Option<&'sc dyn Light<R>>,
light_pdf: Float,
}
impl<'sc, R: Rng> Intersection<'sc, R> {
@ -26,12 +27,14 @@ impl<'sc, R: Rng> Intersection<'sc, R> {
normal: Dir3,
material: Option<&'sc dyn Material<R>>,
light: Option<&'sc dyn Light<R>>,
light_pdf: Float,
) -> Self {
Self {
t,
normal,
material,
light,
light_pdf,
}
}
@ -51,6 +54,10 @@ impl<'sc, R: Rng> Intersection<'sc, R> {
self.light
}
pub fn light_pdf(&self) -> Float {
self.light_pdf
}
pub fn tangent_frame(&self) -> Frame {
Frame::from_normal(self.normal)
}