Skip to content

Commit 4de4e54

Browse files
committed
Update post_processing example to not render UI with first pass camera (#6469)
# Objective Make sure the post processing example won't render UI twice. ## Solution Disable UI on the first pass camera with `UiCameraConfig`
1 parent dc09ee3 commit 4de4e54

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

examples/shader/post_processing.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,24 @@ fn setup(
9595
});
9696

9797
// Main camera, first to render
98-
commands.spawn(Camera3dBundle {
99-
camera_3d: Camera3d {
100-
clear_color: ClearColorConfig::Custom(Color::WHITE),
101-
..default()
102-
},
103-
camera: Camera {
104-
target: RenderTarget::Image(image_handle.clone()),
98+
commands.spawn((
99+
Camera3dBundle {
100+
camera_3d: Camera3d {
101+
clear_color: ClearColorConfig::Custom(Color::WHITE),
102+
..default()
103+
},
104+
camera: Camera {
105+
target: RenderTarget::Image(image_handle.clone()),
106+
..default()
107+
},
108+
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
109+
.looking_at(Vec3::default(), Vec3::Y),
105110
..default()
106111
},
107-
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
108-
.looking_at(Vec3::default(), Vec3::Y),
109-
..default()
110-
});
112+
// Disable UI rendering for the first pass camera. This prevents double rendering of UI at
113+
// the cost of rendering the UI without any post processing effects.
114+
UiCameraConfig { show_ui: false },
115+
));
111116

112117
// This specifies the layer used for the post processing camera, which will be attached to the post processing camera and 2d quad.
113118
let post_processing_pass_layer = RenderLayers::layer((RenderLayers::TOTAL_LAYERS - 1) as u8);

0 commit comments

Comments
 (0)