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); 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