diff --git a/crates/bevy_solari/src/realtime/restir_di.wgsl b/crates/bevy_solari/src/realtime/restir_di.wgsl index f56d80fb15..b9a5bfa60c 100644 --- a/crates/bevy_solari/src/realtime/restir_di.wgsl +++ b/crates/bevy_solari/src/realtime/restir_di.wgsl @@ -112,7 +112,6 @@ fn generate_initial_reservoir(world_position: vec3, world_normal: vec3 reservoir.unbiased_contribution_weight = reservoir.weight_sum * inverse_target_function; reservoir.visibility = trace_light_visibility(reservoir.sample, world_position); - reservoir.unbiased_contribution_weight *= reservoir.visibility; } reservoir.confidence_weight = 1.0; @@ -175,8 +174,8 @@ fn load_spatial_reservoir(pixel_id: vec2, depth: f32, world_position: vec3< } fn get_neighbor_pixel_id(center_pixel_id: vec2, rng: ptr) -> vec2 { - var spatial_id = vec2(center_pixel_id) + vec2(sample_disk(SPATIAL_REUSE_RADIUS_PIXELS, rng)); - spatial_id = clamp(spatial_id, vec2(0i), vec2(view.viewport.zw) - 1i); + var spatial_id = vec2(center_pixel_id) + sample_disk(SPATIAL_REUSE_RADIUS_PIXELS, rng); + spatial_id = clamp(spatial_id, vec2(0.0), view.viewport.zw - 1.0); return vec2(spatial_id); } @@ -288,7 +287,7 @@ fn merge_reservoirs( fn reservoir_target_function(reservoir: Reservoir, world_position: vec3, world_normal: vec3, diffuse_brdf: vec3) -> vec4 { if !reservoir_valid(reservoir) { return vec4(0.0); } - let light_contribution = calculate_light_contribution(reservoir.sample, world_position, world_normal).radiance; + let light_contribution = calculate_light_contribution(reservoir.sample, world_position, world_normal).radiance * reservoir.visibility; let target_function = luminance(light_contribution * diffuse_brdf); return vec4(light_contribution, target_function); } diff --git a/crates/bevy_solari/src/realtime/restir_gi.wgsl b/crates/bevy_solari/src/realtime/restir_gi.wgsl index 13bb5d15eb..2b0cff5de7 100644 --- a/crates/bevy_solari/src/realtime/restir_gi.wgsl +++ b/crates/bevy_solari/src/realtime/restir_gi.wgsl @@ -172,8 +172,8 @@ fn load_spatial_reservoir(pixel_id: vec2, depth: f32, world_position: vec3< } fn get_neighbor_pixel_id(center_pixel_id: vec2, rng: ptr) -> vec2 { - var spatial_id = vec2(center_pixel_id) + vec2(sample_disk(SPATIAL_REUSE_RADIUS_PIXELS, rng)); - spatial_id = clamp(spatial_id, vec2(0i), vec2(view.viewport.zw) - 1i); + var spatial_id = vec2(center_pixel_id) + sample_disk(SPATIAL_REUSE_RADIUS_PIXELS, rng); + spatial_id = clamp(spatial_id, vec2(0.0), view.viewport.zw - 1.0); return vec2(spatial_id); } diff --git a/release-content/release-notes/bevy_solari.md b/release-content/release-notes/bevy_solari.md index e6727deb47..66f258eeb1 100644 --- a/release-content/release-notes/bevy_solari.md +++ b/release-content/release-notes/bevy_solari.md @@ -1,7 +1,7 @@ --- title: Initial raytraced lighting progress (bevy_solari) authors: ["@JMS55"] -pull_requests: [19058, 19620, 19790, 20020] +pull_requests: [19058, 19620, 19790, 20020, 20113] --- (TODO: Embed solari example screenshot here)