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

Function mat4_ortho

native/shared/src/renderer/util.rs:33–47  ·  view source on GitHub ↗
(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32)

Source from the content-addressed store, hash-verified

31}
32
33pub 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
49pub fn mat4_look_at(eye: [f32; 3], center: [f32; 3], up: [f32; 3]) -> [[f32; 4]; 4] {
50 let fx = center[0] - eye[0];

Callers 2

compute_cascade_vpsMethod · 0.85
begin_mode_3dMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected