depth testing
This commit is contained in:
@@ -17,7 +17,7 @@ use num_traits::identities::One;
|
||||
use piston_window::{PistonWindow, Window, WindowSettings};
|
||||
|
||||
pub type ColorFormat = gfx::format::Srgba8;
|
||||
//pub type DepthFormat = gfx::format::DepthStencil;
|
||||
pub type DepthFormat = gfx::format::DepthStencil;
|
||||
|
||||
const NEAR: f32 = 0.01;
|
||||
const FAR: f32 = 1000.0;
|
||||
@@ -36,6 +36,7 @@ gfx_defines!{
|
||||
vbuf: gfx::VertexBuffer<Vertex> = (),
|
||||
trans: gfx::ConstantBuffer<Trans> = "b_trans",
|
||||
pixcolor: gfx::RenderTarget<ColorFormat> = "pixcolor",
|
||||
depth: gfx::DepthTarget<DepthFormat> = gfx::preset::depth::LESS_EQUAL_WRITE,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +64,9 @@ fn main() {
|
||||
pipe::new())
|
||||
.expect("create pipeline");
|
||||
|
||||
let (tex_left, tgt_left) = vr::create_eyebuffer(&mut window.factory, render_size)
|
||||
let (tex_left, tgt_left, depth_left) = vr::create_eyebuffer(&mut window.factory, render_size)
|
||||
.expect("create left renderbuffer");
|
||||
let (tex_right, tgt_right) = vr::create_eyebuffer(&mut window.factory, render_size)
|
||||
let (tex_right, tgt_right, depth_right) = vr::create_eyebuffer(&mut window.factory, render_size)
|
||||
.expect("create right renderbuffer");
|
||||
let (vertex_buffer, slice) = window.factory.create_vertex_buffer_with_slice(&POLYGON, POLYGON_IDX);
|
||||
|
||||
@@ -73,16 +74,19 @@ fn main() {
|
||||
vbuf: vertex_buffer.clone(),
|
||||
trans: window.factory.create_constant_buffer(1),
|
||||
pixcolor: window.output_color.clone(),
|
||||
depth: window.output_stencil.clone(),
|
||||
};
|
||||
let pipe_left = pipe::Data {
|
||||
vbuf: vertex_buffer.clone(),
|
||||
trans: window.factory.create_constant_buffer(1),
|
||||
pixcolor: tgt_left,
|
||||
depth: depth_left,
|
||||
};
|
||||
let pipe_right = pipe::Data {
|
||||
vbuf: vertex_buffer.clone(),
|
||||
trans: window.factory.create_constant_buffer(1),
|
||||
pixcolor: tgt_right,
|
||||
depth: depth_right,
|
||||
};
|
||||
window.encoder.update_constant_buffer(
|
||||
&pipe_monitor.trans,
|
||||
@@ -128,6 +132,7 @@ fn main() {
|
||||
.into_iter() {
|
||||
info!("\tpass for eye: {:?}", pass.0);
|
||||
window.encoder.clear(&pass.1.pixcolor, [0.1, 0.2, 0.3, 1.0]);
|
||||
window.encoder.clear_depth(&pass.1.depth, 1.0);
|
||||
|
||||
// Submit eye textures
|
||||
if let Some((eye, tex)) = pass.0 {
|
||||
|
||||
Reference in New Issue
Block a user