Skip to content

Commit 789891f

Browse files
authored
Solari: Skip ReSTIR GI for smooth metallic surfaces (#22671)
# Objective - Save perf on scenes with smooth metallic surfaces ## Solution - Skip ReSTIR GI for these surfaces as the contribution will be zero anyways ## Testing - Tested on a half metallic half non-metallic scene with varying roughness
1 parent 7b0a905 commit 789891f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/bevy_solari/src/realtime/restir_gi.wgsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enable wgpu_ray_query;
1212
#import bevy_solari::scene_bindings::{trace_ray, resolve_ray_hit_full, RAY_T_MIN, RAY_T_MAX}
1313
#import bevy_solari::world_cache::{query_world_cache, WORLD_CACHE_CELL_LIFETIME}
1414
#import bevy_solari::realtime_bindings::{view_output, gi_reservoirs_a, gi_reservoirs_b, gbuffer, depth_buffer, motion_vectors, previous_gbuffer, previous_depth_buffer, view, previous_view, constants, Reservoir}
15+
#import bevy_solari::specular_gi::DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD
1516

1617
const SPATIAL_REUSE_RADIUS_PIXELS = 30.0;
1718
const CONFIDENCE_WEIGHT_CAP = 8.0;
@@ -29,6 +30,10 @@ fn initial_and_temporal(@builtin(global_invocation_id) global_id: vec3<u32>) {
2930
return;
3031
}
3132
let surface = gpixel_resolve(textureLoad(gbuffer, global_id.xy, 0), depth, global_id.xy, view.main_pass_viewport.zw, view.world_from_clip);
33+
if surface.material.metallic > 0.9999 && surface.material.roughness <= DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD {
34+
gi_reservoirs_b[pixel_index] = empty_reservoir();
35+
return;
36+
}
3237

3338
let initial_reservoir = generate_initial_reservoir(surface.world_position, surface.world_normal, &rng);
3439
let temporal = load_temporal_reservoir(global_id.xy, depth, surface.world_position, surface.world_normal);
@@ -51,6 +56,10 @@ fn spatial_and_shade(@builtin(global_invocation_id) global_id: vec3<u32>) {
5156
return;
5257
}
5358
let surface = gpixel_resolve(textureLoad(gbuffer, global_id.xy, 0), depth, global_id.xy, view.main_pass_viewport.zw, view.world_from_clip);
59+
if surface.material.metallic > 0.9999 && surface.material.roughness <= DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD {
60+
gi_reservoirs_a[pixel_index] = empty_reservoir();
61+
return;
62+
}
5463

5564
let input_reservoir = gi_reservoirs_b[pixel_index];
5665
let spatial = load_spatial_reservoir(global_id.xy, depth, surface.world_position, surface.world_normal, &rng);

0 commit comments

Comments
 (0)