Inverse — project a direction to the pixel that would have produced it. Used in `pdf` to evaluate BRDF-sample directions against the environment distribution.
(&self, direction: Vec3)
| 1619 | /// produced it. Used in `pdf` to evaluate BRDF-sample directions |
| 1620 | /// against the environment distribution. |
| 1621 | fn direction_to_pixel(&self, direction: Vec3) -> (u32, u32, f32) { |
| 1622 | let d = direction.normalize_or_zero(); |
| 1623 | let theta = d.y.clamp(-1.0, 1.0).acos(); |
| 1624 | let phi = d.z.atan2(d.x); |
| 1625 | let u = (phi / (2.0 * std::f32::consts::PI)).rem_euclid(1.0); |
| 1626 | let v = (theta / std::f32::consts::PI).clamp(0.0, 1.0); |
| 1627 | let x = ((u * self.width as f32) as u32).min(self.width - 1); |
| 1628 | let y = ((v * self.height as f32) as u32).min(self.height - 1); |
| 1629 | let sin_theta = theta.sin(); |
| 1630 | (x, y, sin_theta) |
| 1631 | } |
| 1632 | |
| 1633 | /// Draw a direction from the env's luminance distribution along |
| 1634 | /// with the per-solid-angle PDF of that choice. The PDF is what |