Fix MIS bugs

This commit is contained in:
hal8174 2025-01-08 22:31:57 +01:00
parent 27ea5c5d93
commit 908efa79c2
5 changed files with 33 additions and 15 deletions

View file

@ -8,7 +8,7 @@ pub trait Material<R: Rng>: Send + Sync + Debug {
fn sample(&self, w_in: Dir3, rng: &mut R) -> SampleResult {
let w_out = Dir3::sample_cosine_hemisphere(rng);
SampleResult::new(w_out, self.eval(w_in, w_out, rng) * FloatConsts::PI)
SampleResult::new(w_out, self.eval(w_in, w_out, rng) * FloatConsts::PI, false)
}
fn pdf(&self, w_in: Dir3, w_out: Dir3) -> Float {
@ -21,11 +21,16 @@ pub trait Material<R: Rng>: Send + Sync + Debug {
pub struct SampleResult {
w_out: Dir3,
color: Color,
delta: bool,
}
impl SampleResult {
pub fn new(w_out: Dir3, color: Color) -> Self {
Self { w_out, color }
pub fn new(w_out: Dir3, color: Color, delta: bool) -> Self {
Self {
w_out,
color,
delta,
}
}
pub fn w_out(&self) -> Dir3 {
@ -35,4 +40,8 @@ impl SampleResult {
pub fn color(&self) -> Color {
self.color
}
pub fn is_delta(&self) -> bool {
self.delta
}
}