From 239885401c41df266e6f92b18c8401cae23cec92 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 24 Oct 2019 12:26:58 -0400 Subject: [PATCH 1/2] Refactor log crate usage --- examples/framework.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/framework.rs b/examples/framework.rs index 9e818c69e5..bb5cc4b97c 100644 --- a/examples/framework.rs +++ b/examples/framework.rs @@ -1,4 +1,3 @@ -use log::info; use winit::event::WindowEvent; #[cfg_attr(rustfmt, rustfmt_skip)] @@ -50,7 +49,7 @@ pub fn run(title: &str) { env_logger::init(); let event_loop = EventLoop::new(); - info!("Initializing the window..."); + log::info!("Initializing the window..."); #[cfg(not(feature = "gl"))] let (_window, hidpi_factor, size, surface) = { @@ -105,13 +104,13 @@ pub fn run(title: &str) { }; let mut swap_chain = device.create_swap_chain(&surface, &sc_desc); - info!("Initializing the example..."); + log::info!("Initializing the example..."); let (mut example, init_command_buf) = E::init(&sc_desc, &device); if let Some(command_buf) = init_command_buf { queue.submit(&[command_buf]); } - info!("Entering render loop..."); + log::info!("Entering render loop..."); event_loop.run(move |event, _, control_flow| { *control_flow = if cfg!(feature = "metal-auto-capture") { ControlFlow::Exit @@ -124,7 +123,7 @@ pub fn run(title: &str) { .. } => { let physical = size.to_physical(hidpi_factor); - info!("Resizing to {:?}", physical); + log::info!("Resizing to {:?}", physical); sc_desc.width = physical.width.round() as u32; sc_desc.height = physical.height.round() as u32; swap_chain = device.create_swap_chain(&surface, &sc_desc); From 5123a5b800d7d949f6033d9e36f468c73b454602 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 24 Oct 2019 12:27:10 -0400 Subject: [PATCH 2/2] Fix shadow sampling outside of the positive hemisphere --- examples/shadow/forward.frag | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/shadow/forward.frag b/examples/shadow/forward.frag index 7af5dbdc7f..fdd587ae6d 100644 --- a/examples/shadow/forward.frag +++ b/examples/shadow/forward.frag @@ -28,6 +28,19 @@ layout(set = 1, binding = 0) uniform Entity { vec4 u_Color; }; +float fetch_shadow(int light_id, vec4 homogeneous_coords) { + if (homogeneous_coords.w <= 0.0) { + return 1.0; + } + // compute texture coordinates for shadow lookup + vec4 light_local = vec4( + (homogeneous_coords.xy/homogeneous_coords.w + 1.0) / 2.0, + light_id, + homogeneous_coords.z / homogeneous_coords.w + ); + // do the lookup, using HW PCF and comparison + return texture(sampler2DArrayShadow(t_Shadow, s_Shadow), light_local); +} void main() { vec3 normal = normalize(v_Normal); @@ -37,13 +50,7 @@ void main() { for (int i=0; i