From 546256639661912065408270308f9341693dac85 Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Wed, 18 Sep 2019 20:21:59 -0700 Subject: [PATCH] in a stroke of genius (total luck) I have gotten a stencil buffer which culls pixels --- src/canvas.rs | 2 +- src/canvas_shader.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/canvas.rs b/src/canvas.rs index 51c17752..8649c229 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -486,7 +486,7 @@ impl CanvasState { // Specify the color to clear the framebuffer with i.e. blue let clear_values = vec!( ClearValue::Float([0.0, 0.0, 1.0, 1.0]), - ClearValue::DepthStencil((1.0, 1)), + ClearValue::DepthStencil((1.0, 0)), ); let mut command_buffer = command_buffer.begin_render_pass( diff --git a/src/canvas_shader.rs b/src/canvas_shader.rs index 1d9d8c75..8e218a94 100644 --- a/src/canvas_shader.rs +++ b/src/canvas_shader.rs @@ -118,13 +118,13 @@ impl CanvasShader { depth_write: true, depth_bounds_test: DepthBounds::Disabled, stencil_front: Stencil { - compare: Compare::Always, + compare: Compare::Equal, pass_op: StencilOp::Invert, fail_op: StencilOp::Invert, - depth_fail_op: StencilOp::Invert, - compare_mask: Some(u32::max_value()), - write_mask: Some(u32::max_value()), - reference: Some(u32::max_value()), + depth_fail_op: StencilOp::Keep, + compare_mask: Some(0x01), + write_mask: Some(0xFF), + reference: Some(0x01), }, stencil_back: Default::default() };