From f798c16388fe179cb322572590dcc49ff747c96e Mon Sep 17 00:00:00 2001 From: Marco Buono Date: Tue, 6 Jun 2023 02:56:45 -0300 Subject: [PATCH] Add comments about transmissive steps --- .../src/core_3d/main_transmissive_pass_3d_node.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs index 683e6853c8..b77051ddf7 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs @@ -70,7 +70,12 @@ impl ViewNode for MainTransmissivePass3dNode { if transmissive_steps > 0 { let transmission = transmission.expect("`ViewTransmissionTexture` should exist at this point"); + + // `transmissive_phase.items` are depth sorted, so we split them into N = `transmissive_steps` ranges, + // rendering them back-to-front in multiple steps, allowing multiple levels of transparency. for range in split_range(0..transmissive_phase.items.len(), transmissive_steps) { + // Copy the main texture to the transmission texture, allowing to use the color output of the + // previous step (or of the `Opaque3d` phase, for the first step) as a transmissive color input render_context.command_encoder().copy_texture_to_texture( target.main_texture().as_image_copy(), transmission.texture.as_image_copy(), @@ -88,6 +93,7 @@ impl ViewNode for MainTransmissivePass3dNode { render_pass.set_camera_viewport(viewport); } + // render items in range transmissive_phase.render_range(&mut render_pass, world, view_entity, range); } } else {