haze
This commit is contained in:
13
src/view.rs
13
src/view.rs
@@ -20,6 +20,7 @@ const FAR: f32 = 3072.0;
|
||||
|
||||
gfx_constant_struct! {
|
||||
Trans {
|
||||
viewmodel: [[f32; 4]; 4] = "u_viewmodel",
|
||||
matrix: [[f32; 4]; 4] = "u_matrix",
|
||||
}
|
||||
}
|
||||
@@ -81,13 +82,13 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
|
||||
(vr::Eye::Right, &self.right)].into_iter() {
|
||||
let target = &buffers.as_ref().expect("vr color buffer").target;
|
||||
let depth = &buffers.as_ref().expect("vr depth buffer").depth;
|
||||
window.encoder.clear(target, [0.005, 0.005, 0.01, 1.0]);
|
||||
window.encoder.clear_depth(depth, 1.0);
|
||||
|
||||
let proj_mat = vr.projection_matrix(eye, NEAR, FAR);
|
||||
let eye_mat = vr.head_to_eye_transform(eye);
|
||||
let scene_mat = scene.origin();
|
||||
let trans = Trans { matrix: *(proj_mat * eye_mat * hmd_mat * scene_mat).as_ref() };
|
||||
let viewmodel_mat = eye_mat * hmd_mat * scene_mat;
|
||||
let trans = Trans { viewmodel: *viewmodel_mat.as_ref(),
|
||||
matrix: *(proj_mat * viewmodel_mat).as_ref() };
|
||||
window.encoder.update_constant_buffer(&self.trans, &trans);
|
||||
|
||||
scene.render(&mut window.factory,
|
||||
@@ -103,12 +104,12 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
|
||||
1.0).to_homogeneous();
|
||||
let proj_mat = na::PerspectiveMatrix3::new(1.0, 90.0, NEAR, FAR).to_matrix();
|
||||
let scene_mat = scene.origin();
|
||||
let trans = Trans { matrix: *(proj_mat * head_mat * scene_mat).as_ref() };
|
||||
let viewmodel_mat = head_mat * scene_mat;
|
||||
let trans = Trans { viewmodel: *viewmodel_mat.as_ref(),
|
||||
matrix: *(proj_mat * viewmodel_mat).as_ref() };
|
||||
window.encoder.update_constant_buffer(&self.trans, &trans);
|
||||
}
|
||||
// draw monitor window
|
||||
window.encoder.clear(&window.output_color, [0.005, 0.005, 0.01, 1.0]);
|
||||
window.encoder.clear_depth(&window.output_stencil, 1.0);
|
||||
scene.render(&mut window.factory,
|
||||
&mut window.encoder,
|
||||
&self.trans,
|
||||
|
||||
Reference in New Issue
Block a user