pbrt_r3/core/medium/
phase_function.rs

1use crate::core::base::*;
2
3pub trait PhaseFunction: std::fmt::Display {
4    fn p(&self, wo: &Vector3f, wi: &Vector3f) -> Float;
5    fn sample_p(&self, wo: &Vector3f, u: &Point2f) -> (Float, Vector3f);
6}
7
8// Media Inline Functions
9#[inline]
10pub fn phase_hg(cos_theta: Float, g: Float) -> Float {
11    let denom = 1.0 + g * g + 2.0 * g * cos_theta;
12    return INV_4_PI * (1.0 - g * g) / (denom * Float::sqrt(denom));
13}