Draw a direction from the env's luminance distribution along with the per-solid-angle PDF of that choice. The PDF is what MIS needs when weighting this sample against a BRDF sample.
(&self, rng: &mut Rng)
| 1634 | /// with the per-solid-angle PDF of that choice. The PDF is what |
| 1635 | /// MIS needs when weighting this sample against a BRDF sample. |
| 1636 | fn sample_importance(&self, rng: &mut Rng) -> (Vec3, Vec3, f32) { |
| 1637 | let (x, y, pixel_p) = self |
| 1638 | .distribution |
| 1639 | .sample_pixel(rng.next_f32(), rng.next_f32()); |
| 1640 | let (direction, sin_theta) = self.pixel_to_direction(x, y); |
| 1641 | let radiance = self.sample(direction); |
| 1642 | // Convert pixel probability → solid-angle PDF. |
| 1643 | // pdf_omega = pixel_p / (omega_per_pixel) |
| 1644 | // omega_per_pixel = (2π/W)(π/H)·sin(θ) |
| 1645 | let omega_per_pixel = (2.0 * std::f32::consts::PI / self.width as f32) |
| 1646 | * (std::f32::consts::PI / self.height as f32) |
| 1647 | * sin_theta.max(1e-6); |
| 1648 | let pdf = pixel_p / omega_per_pixel; |
| 1649 | (direction, radiance, pdf) |
| 1650 | } |
| 1651 | |
| 1652 | /// PDF (per solid angle) of the env distribution for a given |
| 1653 | /// direction. Evaluates the pixel the direction maps to and |
no test coverage detected