Skip to content

Commit b4deee2

Browse files
JMS55ChristopherBiscardialice-i-cecile
authored
Solari: More examples, fix emissive (#22295)
* Add a small profiling overlay to the Solari example that times different parts of Solari's GPU work (DLSS-RR not added because wgpu timestamps aren't working correctly with wgpu_hal work, I need to fix that as a separate thing) * Add a many-lights stress test to the Solari example (100 lights) inspired by https://x.com/Roystoncinemo/status/1841917611833229411. Currently somewhat unusable, but this will ideally be a bigger focus for Solari 0.19. * Changed emissive to have exposure applied, as if `emissive_exposure_weight` was always set to 1.0 (StandardMaterial defaults to 0.0 which I'm not convinced is a good idea, but that's a separate topic). If we didn't do this, the emissive meshes would render as insanely bright white to the point of overflowing the texture and breaking DLSS-RR. I think the new behavior is more what people expect to happen, and matches the pathtracer result now. <img width="3206" height="1875" alt="image" src="https://github.com/user-attachments/assets/af3990d6-ae2d-4520-a7cd-f04041685152" /> --------- Co-authored-by: Chris Biscardi <[email protected]> Co-authored-by: Alice Cecile <[email protected]>
1 parent 9e8c600 commit b4deee2

File tree

3 files changed

+285
-15
lines changed

3 files changed

+285
-15
lines changed

crates/bevy_solari/src/realtime/node.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ impl ViewNode for SolariLightingNode {
240240
label: Some("solari_lighting"),
241241
timestamp_writes: None,
242242
});
243-
let pass_span = diagnostics.pass_span(&mut pass, "solari_lighting");
244243

245244
let dx = solari_lighting_resources.view_size.x.div_ceil(8);
246245
let dy = solari_lighting_resources.view_size.y.div_ceil(8);
@@ -262,12 +261,16 @@ impl ViewNode for SolariLightingNode {
262261
pass.dispatch_workgroups(dx, dy, 1);
263262
}
264263

264+
let d = diagnostics.time_span(&mut pass, "solari_lighting/presample_light_tiles");
265265
pass.set_pipeline(presample_light_tiles_pipeline);
266266
pass.set_push_constants(
267267
0,
268268
bytemuck::cast_slice(&[frame_index, solari_lighting.reset as u32]),
269269
);
270270
pass.dispatch_workgroups(LIGHT_TILE_BLOCKS as u32, 1, 1);
271+
d.end(&mut pass);
272+
273+
let d = diagnostics.time_span(&mut pass, "solari_lighting/world_cache");
271274

272275
pass.set_bind_group(2, &bind_group_world_cache_active_cells_dispatch, &[]);
273276

@@ -301,6 +304,10 @@ impl ViewNode for SolariLightingNode {
301304
0,
302305
);
303306

307+
d.end(&mut pass);
308+
309+
let d = diagnostics.time_span(&mut pass, "solari_lighting/direct_lighting");
310+
304311
pass.set_pipeline(di_initial_and_temporal_pipeline);
305312
pass.set_push_constants(
306313
0,
@@ -315,6 +322,10 @@ impl ViewNode for SolariLightingNode {
315322
);
316323
pass.dispatch_workgroups(dx, dy, 1);
317324

325+
d.end(&mut pass);
326+
327+
let d = diagnostics.time_span(&mut pass, "solari_lighting/diffuse_indirect_lighting");
328+
318329
pass.set_pipeline(gi_initial_and_temporal_pipeline);
319330
pass.set_push_constants(
320331
0,
@@ -329,14 +340,16 @@ impl ViewNode for SolariLightingNode {
329340
);
330341
pass.dispatch_workgroups(dx, dy, 1);
331342

343+
d.end(&mut pass);
344+
345+
let d = diagnostics.time_span(&mut pass, "solari_lighting/specular_indirect_lighting");
332346
pass.set_pipeline(specular_gi_pipeline);
333347
pass.set_push_constants(
334348
0,
335349
bytemuck::cast_slice(&[frame_index, solari_lighting.reset as u32]),
336350
);
337351
pass.dispatch_workgroups(dx, dy, 1);
338-
339-
pass_span.end(&mut pass);
352+
d.end(&mut pass);
340353

341354
Ok(())
342355
}

crates/bevy_solari/src/realtime/restir_di.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ fn spatial_and_shade(@builtin(global_invocation_id) global_id: vec3<u32>) {
9696
let brdf = evaluate_brdf(surface.world_normal, wo, merge_result.wi, surface.material);
9797

9898
var pixel_color = merge_result.selected_sample_radiance * combined_reservoir.unbiased_contribution_weight;
99-
pixel_color *= view.exposure;
10099
pixel_color *= brdf;
101100
pixel_color += surface.material.emissive;
101+
pixel_color *= view.exposure;
102102
textureStore(view_output, global_id.xy, vec4(pixel_color, 1.0));
103103
}
104104

0 commit comments

Comments
 (0)