Set scissor on upscale to match camera viewport (#14287)
# Objective When the user renders multiple cameras to the same output texture, it can sometimes be confusing what `ClearColorConfig` is necessary for each camera to avoid overwriting the previous camera's output. This is particular true in cases where the user uses mixed HDR cameras, which means that their scene is being rendered to different internal textures. ## Solution When a view has a configured viewport, set the GPU scissor in the upscaling node so we don't overwrite areas that were written to by other cameras. ## Testing Ran the `split_screen` example.
This commit is contained in:
parent
d65eb39277
commit
3830e71076
@ -84,6 +84,14 @@ impl ViewNode for UpscalingNode {
|
||||
.command_encoder()
|
||||
.begin_render_pass(&pass_descriptor);
|
||||
|
||||
if let Some(camera) = camera {
|
||||
if let Some(viewport) = &camera.viewport {
|
||||
let size = viewport.physical_size;
|
||||
let position = viewport.physical_position;
|
||||
render_pass.set_scissor_rect(position.x, position.y, size.x, size.y);
|
||||
}
|
||||
}
|
||||
|
||||
render_pass.set_pipeline(pipeline);
|
||||
render_pass.set_bind_group(0, bind_group, &[]);
|
||||
render_pass.draw(0..3, 0..1);
|
||||
|
@ -68,12 +68,6 @@ fn setup(
|
||||
camera: Camera {
|
||||
// Renders cameras with different priorities to prevent ambiguities
|
||||
order: index as isize,
|
||||
// Don't clear after the first camera because the first camera already cleared the entire window
|
||||
clear_color: if index > 0 {
|
||||
ClearColorConfig::None
|
||||
} else {
|
||||
ClearColorConfig::default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
|
Loading…
Reference in New Issue
Block a user