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

Method pixel_to_direction

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

Convert a pixel (column, row) to a world-space direction. The sample lands at the pixel center. Returns the direction together with sin(theta) — callers need that for the PDF conversion between pixel and solid angle.

(&self, x: u32, y: u32)

Source from the content-addressed store, hash-verified

1606 /// together with sin(theta) — callers need that for the PDF
1607 /// conversion between pixel and solid angle.
1608 fn pixel_to_direction(&self, x: u32, y: u32) -> (Vec3, f32) {
1609 let u = (x as f32 + 0.5) / self.width as f32;
1610 let v = (y as f32 + 0.5) / self.height as f32;
1611 let theta = v * std::f32::consts::PI;
1612 let phi = (u - 0.5) * 2.0 * std::f32::consts::PI;
1613 let sin_theta = theta.sin();
1614 let dir = Vec3::new(sin_theta * phi.cos(), theta.cos(), sin_theta * phi.sin());
1615 (dir.normalize(), sin_theta)
1616 }
1617
1618 /// Inverse — project a direction to the pixel that would have
1619 /// produced it. Used in `pdf` to evaluate BRDF-sample directions

Callers 1

sample_importanceMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected