MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / sample_importance

Method sample_importance

tools/bloom-reference/src/main.rs:1636–1650  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

trace_pathFunction · 0.80

Calls 4

sample_pixelMethod · 0.80
next_f32Method · 0.80
pixel_to_directionMethod · 0.80
sampleMethod · 0.80

Tested by

no test coverage detected