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)
| 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 |