Skip to content

Commit 3f08ae4

Browse files
authored
Solari: Support clear color (#21350)
<img width="2564" height="1500" alt="image" src="https://github.com/user-attachments/assets/8bd37bda-88b0-436a-9c01-a22fb63e9e87" /> * ClearColor is not supported for the pathtracer still * Tonemapping makes the clear color appear incorrect (the above image is supposed to be pure white), which is a little wonky. That's a separate issue though.
1 parent 2c742e2 commit 3f08ae4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

crates/bevy_solari/src/realtime/node.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use bevy_render::{
2323
storage_buffer_sized, texture_2d, texture_depth_2d, texture_storage_2d, uniform_buffer,
2424
},
2525
BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedComputePipelineId,
26-
ComputePassDescriptor, ComputePipelineDescriptor, PipelineCache, PushConstantRange,
27-
ShaderStages, StorageTextureAccess, TextureFormat, TextureSampleType,
26+
ComputePassDescriptor, ComputePipelineDescriptor, LoadOp, PipelineCache, PushConstantRange,
27+
RenderPassDescriptor, ShaderStages, StorageTextureAccess, TextureFormat, TextureSampleType,
2828
},
2929
renderer::{RenderContext, RenderDevice},
3030
view::{ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms},
@@ -156,12 +156,14 @@ impl ViewNode for SolariLightingNode {
156156
return Ok(());
157157
};
158158

159+
let view_target = view_target.get_unsampled_color_attachment();
160+
159161
let s = solari_lighting_resources;
160162
let bind_group = render_context.render_device().create_bind_group(
161163
"solari_lighting_bind_group",
162164
&self.bind_group_layout,
163165
&BindGroupEntries::sequential((
164-
view_target.get_unsampled_color_attachment().view,
166+
view_target.view,
165167
s.light_tile_samples.as_entire_binding(),
166168
s.light_tile_resolved_samples.as_entire_binding(),
167169
&s.di_reservoirs_a.1,
@@ -212,6 +214,17 @@ impl ViewNode for SolariLightingNode {
212214
let diagnostics = render_context.diagnostic_recorder();
213215
let command_encoder = render_context.command_encoder();
214216

217+
// Clear the view target if we're the first node to write to it
218+
if matches!(view_target.ops.load, LoadOp::Clear(_)) {
219+
command_encoder.begin_render_pass(&RenderPassDescriptor {
220+
label: Some("solari_lighting_clear"),
221+
color_attachments: &[Some(view_target)],
222+
depth_stencil_attachment: None,
223+
timestamp_writes: None,
224+
occlusion_query_set: None,
225+
});
226+
}
227+
215228
let mut pass = command_encoder.begin_compute_pass(&ComputePassDescriptor {
216229
label: Some("solari_lighting"),
217230
timestamp_writes: None,

crates/bevy_solari/src/realtime/restir_di.wgsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ fn spatial_and_shade(@builtin(global_invocation_id) global_id: vec3<u32>) {
6868
let depth = textureLoad(depth_buffer, global_id.xy, 0);
6969
if depth == 0.0 {
7070
store_reservoir_a(global_id.xy, empty_reservoir());
71-
textureStore(view_output, global_id.xy, vec4(vec3(0.0), 1.0));
7271
return;
7372
}
7473
let gpixel = textureLoad(gbuffer, global_id.xy, 0);

0 commit comments

Comments
 (0)