Cell-center UV in `[-1, 1]^2` for grid coords `(i, j)` of an `N×N` atlas. Matches the runtime `floor(oct * GRID)` cell selection: the runtime samples the cell whose lower-left corner is `cell / N`, so the bake direction must be the *center* of that cell, i.e. `(cell + 0.5) / N` mapped from `[0, 1]` to `[-1, 1]`.
(i: u32, j: u32, n: u32)
| 26 | /// the bake direction must be the *center* of that cell, i.e. |
| 27 | /// `(cell + 0.5) / N` mapped from `[0, 1]` to `[-1, 1]`. |
| 28 | pub fn cell_center_uv(i: u32, j: u32, n: u32) -> [f32; 2] { |
| 29 | let nf = n as f32; |
| 30 | let u = ((i as f32 + 0.5) / nf) * 2.0 - 1.0; |
| 31 | let v = ((j as f32 + 0.5) / nf) * 2.0 - 1.0; |
| 32 | [u, v] |
| 33 | } |
| 34 | |
| 35 | /// Direction (model → camera) for cell `(i, j)`. |
| 36 | pub fn cell_direction(i: u32, j: u32, n: u32) -> [f32; 3] { |