From c123c01c5da7371f0d60c044b8e3e24248abb76d Mon Sep 17 00:00:00 2001 From: TheRawMeatball Date: Tue, 31 Oct 2023 06:09:14 +0300 Subject: [PATCH 1/3] fix shadows --- src/render/mod.rs | 6 +++--- src/render/shadow.rs | 25 +++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/render/mod.rs b/src/render/mod.rs index dfb888d..d1eb7c7 100755 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -267,11 +267,11 @@ fn extract_infinite_grids( fn extract_grid_shadows( mut commands: Commands, - grids: Extract>, + grids: Extract>, ) { let extracted: Vec<_> = grids .iter() - .filter(|(_, extracted, _)| extracted.grid.shadow_color.is_some()) + .filter(|(_, grid, _)| grid.shadow_color.is_some()) .map(|(entity, _, intersect)| (entity, (*intersect,))) .collect(); commands.insert_or_spawn_batch(extracted); @@ -607,7 +607,7 @@ pub fn render_app_builder(app: &mut App) { .set_untracked(SHADER_HANDLE, Shader::from_wgsl(PLANE_RENDER, file!())); let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { - return + return; }; render_app .init_resource::() diff --git a/src/render/shadow.rs b/src/render/shadow.rs index d95f721..a9b5c0e 100644 --- a/src/render/shadow.rs +++ b/src/render/shadow.rs @@ -35,8 +35,8 @@ use bevy::{ renderer::RenderDevice, texture::TextureCache, view::{ - ExtractedView, ExtractedWindows, ViewUniform, ViewUniformOffset, ViewUniforms, - VisibleEntities, + prepare_view_uniforms, ExtractedView, ExtractedWindows, ViewUniform, ViewUniformOffset, + ViewUniforms, VisibleEntities, }, Render, RenderApp, RenderSet, }, @@ -442,7 +442,11 @@ impl RenderCommand

for SetGridShadowBindGroup, grid_entity_query: QueryState>, - grid_element_query: QueryState<(Read, Read>)>, + grid_element_query: QueryState<( + Read, + Read>, + Read, + )>, } impl GridShadowPassNode { @@ -471,7 +475,7 @@ impl Node for GridShadowPassNode { world: &World, ) -> Result<(), bevy::render::render_graph::NodeRunError> { for &entity in &self.grids { - let (shadow_view, render_phase) = + let (shadow_view, render_phase, _) = self.grid_element_query.get_manual(world, entity).unwrap(); let pass_descriptor = RenderPassDescriptor { label: Some("grid_shadow_pass"), @@ -486,13 +490,8 @@ impl Node for GridShadowPassNode { depth_stencil_attachment: None, }; - let draw_functions = world.resource::>(); let mut tracked_render_pass = render_context.begin_tracked_render_pass(pass_descriptor); - let mut draw_functions = draw_functions.write(); - for item in &render_phase.items { - let draw_function = draw_functions.get_mut(item.draw_function).unwrap(); - draw_function.draw(world, &mut tracked_render_pass, entity, item); - } + render_phase.render(&mut tracked_render_pass, world, entity); } Ok(()) @@ -534,8 +533,10 @@ pub fn register_shadow(app: &mut App) { .add_render_command::() .add_systems( Render, - // Register as exclusive system because ordering against `bevy_render::view::prepare_view_uniforms` isn't possible otherwise. - prepare_grid_shadow_views.in_set(RenderSet::Prepare), + (prepare_grid_shadow_views, apply_deferred) + .chain() + .before(prepare_view_uniforms) + .in_set(RenderSet::Prepare), ) .add_systems( Render, From e888b438d387cf563bd32e24990ffc1986b51d1d Mon Sep 17 00:00:00 2001 From: IceSentry Date: Sun, 5 Nov 2023 00:14:16 -0400 Subject: [PATCH 2/3] fix clippy --- src/render/shadow.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/render/shadow.rs b/src/render/shadow.rs index a9b5c0e..9646aec 100644 --- a/src/render/shadow.rs +++ b/src/render/shadow.rs @@ -439,6 +439,7 @@ impl RenderCommand

for SetGridShadowBindGroup, grid_entity_query: QueryState>, From 9ff886ecf5e4a510ba8f5d406d59ffed16048a2d Mon Sep 17 00:00:00 2001 From: IceSentry Date: Sun, 5 Nov 2023 00:15:12 -0400 Subject: [PATCH 3/3] fix merge --- src/render/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/mod.rs b/src/render/mod.rs index c8794ae..fd83776 100755 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -296,11 +296,11 @@ fn extract_infinite_grids( fn extract_grid_shadows( mut commands: Commands, - grids: Extract>, + grids: Extract>, ) { let extracted: Vec<_> = grids .iter() - .filter(|(_, grid, _)| grid.shadow_color.is_some()) + .filter(|(_, grid_settings, _)| grid_settings.shadow_color.is_some()) .map(|(entity, _, intersect)| (entity, (*intersect,))) .collect(); commands.insert_or_spawn_batch(extracted);