(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32)
| 31 | } |
| 32 | |
| 33 | pub fn mat4_ortho(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32) -> [[f32; 4]; 4] { |
| 34 | // wgpu NDC z range is [0, 1] (not OpenGL's [-1, 1]). Matching |
| 35 | // this so shadow-map fragments at near half-depth don't get |
| 36 | // clipped and sample_shadow's in-frustum test (z in [0, 1]) |
| 37 | // actually works. |
| 38 | let lr = 1.0 / (left - right); |
| 39 | let bt = 1.0 / (bottom - top); |
| 40 | let nf = 1.0 / (near - far); |
| 41 | [ |
| 42 | [-2.0 * lr, 0.0, 0.0, 0.0], |
| 43 | [0.0, -2.0 * bt, 0.0, 0.0], |
| 44 | [0.0, 0.0, nf, 0.0], |
| 45 | [(left + right) * lr, (top + bottom) * bt, near * nf, 1.0], |
| 46 | ] |
| 47 | } |
| 48 | |
| 49 | pub fn mat4_look_at(eye: [f32; 3], center: [f32; 3], up: [f32; 3]) -> [[f32; 4]; 4] { |
| 50 | let fx = center[0] - eye[0]; |
no outgoing calls
no test coverage detected