|
1 | 1 | use crate::{ |
2 | | - core_3d::Opaque3d, |
| 2 | + core_3d::{Opaque3d, Transparent3d, ViewSortedRenderPhases}, |
3 | 3 | skybox::{SkyboxBindGroup, SkyboxPipelineId}, |
4 | 4 | }; |
5 | 5 | use bevy_ecs::{entity::Entity, prelude::World, query::QueryItem}; |
@@ -48,23 +48,24 @@ impl ViewNode for MainOpaquePass3dNode { |
48 | 48 | ): QueryItem<'w, Self::ViewQuery>, |
49 | 49 | world: &'w World, |
50 | 50 | ) -> Result<(), NodeRunError> { |
51 | | - let (Some(opaque_phases), Some(alpha_mask_phases)) = ( |
| 51 | + let (Some(opaque_phases), Some(alpha_mask_phases), Some(transparent_phases)) = ( |
52 | 52 | world.get_resource::<ViewBinnedRenderPhases<Opaque3d>>(), |
53 | 53 | world.get_resource::<ViewBinnedRenderPhases<AlphaMask3d>>(), |
| 54 | + world.get_resource::<ViewSortedRenderPhases<Transparent3d>>(), |
54 | 55 | ) else { |
55 | 56 | return Ok(()); |
56 | 57 | }; |
57 | 58 |
|
58 | | - let (Some(opaque_phase), Some(alpha_mask_phase)) = |
59 | | - (opaque_phases.get(&view), alpha_mask_phases.get(&view)) |
| 59 | + let (Some(opaque_phase), Some(alpha_mask_phase), Some(transparent_phase)) = |
| 60 | + (opaque_phases.get(&view), alpha_mask_phases.get(&view), transparent_phases.get(&view)) |
60 | 61 | else { |
61 | 62 | return Ok(()); |
62 | 63 | }; |
63 | 64 |
|
64 | 65 | let diagnostics = render_context.diagnostic_recorder(); |
65 | 66 |
|
66 | 67 | let color_attachments = [Some(target.get_color_attachment())]; |
67 | | - let depth_stencil_attachment = Some(depth.get_attachment(StoreOp::Store)); |
| 68 | + let depth_stencil_attachment = Some(depth.get_attachment(StoreOp::Discard)); |
68 | 69 |
|
69 | 70 | let view_entity = graph.view_entity(); |
70 | 71 | render_context.add_command_buffer_generation_task(move |render_device| { |
@@ -110,6 +111,15 @@ impl ViewNode for MainOpaquePass3dNode { |
110 | 111 | } |
111 | 112 | } |
112 | 113 |
|
| 114 | + // Alpha draws |
| 115 | + if !transparent_phase.items.is_empty() { |
| 116 | + #[cfg(feature = "trace")] |
| 117 | + let _transparent_main_pass_3d_span = info_span!("transparent_main_pass_3d").entered(); |
| 118 | + if let Err(err) = transparent_phase.render(&mut render_pass, world, view_entity) { |
| 119 | + error!("Error encountered while rendering the alpha mask phase {err:?}"); |
| 120 | + } |
| 121 | + } |
| 122 | + |
113 | 123 | // Skybox draw using a fullscreen triangle |
114 | 124 | if let (Some(skybox_pipeline), Some(SkyboxBindGroup(skybox_bind_group))) = |
115 | 125 | (skybox_pipeline, skybox_bind_group) |
|
0 commit comments