From 184ad9fef532cafc43bf5bbc376381b9132a241f Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Thu, 10 Jul 2025 14:20:41 -0400 Subject: [PATCH] Misc --- crates/bevy_solari/src/realtime/restir_gi.wgsl | 11 +++++------ crates/bevy_solari/src/scene/sampling.wgsl | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/bevy_solari/src/realtime/restir_gi.wgsl b/crates/bevy_solari/src/realtime/restir_gi.wgsl index 074e99ba3d..34918c0db1 100644 --- a/crates/bevy_solari/src/realtime/restir_gi.wgsl +++ b/crates/bevy_solari/src/realtime/restir_gi.wgsl @@ -98,6 +98,7 @@ fn generate_initial_reservoir(world_position: vec3, world_normal: vec3 } reservoir.sample_point_world_position = sample_point.world_position; + reservoir.sample_point_world_normal = sample_point.world_normal; reservoir.confidence_weight = 1.0; let sample_point_diffuse_brdf = sample_point.material.base_color / PI; @@ -203,10 +204,8 @@ struct Reservoir { weight_sum: f32, radiance: vec3, confidence_weight: f32, + sample_point_world_normal: vec3, unbiased_contribution_weight: f32, - padding1: f32, - padding2: f32, - padding3: f32, } fn empty_reservoir() -> Reservoir { @@ -215,9 +214,7 @@ fn empty_reservoir() -> Reservoir { 0.0, vec3(0.0), 0.0, - 0.0, - 0.0, - 0.0, + vec3(0.0), 0.0, ); } @@ -243,12 +240,14 @@ fn merge_reservoirs(canonical_reservoir: Reservoir, other_reservoir: Reservoir, if rand_f(rng) < other_resampling_weight / combined_reservoir.weight_sum { combined_reservoir.sample_point_world_position = other_reservoir.sample_point_world_position; + combined_reservoir.sample_point_world_normal = other_reservoir.sample_point_world_normal; combined_reservoir.radiance = other_reservoir.radiance; let inverse_target_function = select(0.0, 1.0 / other_target_function, other_target_function > 0.0); combined_reservoir.unbiased_contribution_weight = combined_reservoir.weight_sum * inverse_target_function; } else { combined_reservoir.sample_point_world_position = canonical_reservoir.sample_point_world_position; + combined_reservoir.sample_point_world_normal = canonical_reservoir.sample_point_world_normal; combined_reservoir.radiance = canonical_reservoir.radiance; let inverse_target_function = select(0.0, 1.0 / canonical_target_function, canonical_target_function > 0.0); diff --git a/crates/bevy_solari/src/scene/sampling.wgsl b/crates/bevy_solari/src/scene/sampling.wgsl index 740e44aa6a..e1f67ac1ed 100644 --- a/crates/bevy_solari/src/scene/sampling.wgsl +++ b/crates/bevy_solari/src/scene/sampling.wgsl @@ -191,8 +191,9 @@ fn trace_emissive_mesh_visibility(light_sample: LightSample, instance_id: u32, r } fn trace_point_visibility(ray_origin: vec3, point: vec3) -> f32 { - let dist = distance(ray_origin, point); - let ray_direction = (point - ray_origin) / dist; + let ray = point - ray_origin; + let dist = length(ray); + let ray_direction = ray / dist; let ray_t_max = dist - RAY_T_MIN - RAY_T_MIN; if ray_t_max < RAY_T_MIN { return 0.0; }