Add initial MIS implementation
This commit is contained in:
parent
ba2d853319
commit
d43d60bb85
10 changed files with 161 additions and 3 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue