Revert bilinear temporal reprojection for now, didn't make a big difference

This commit is contained in:
JMS55 2025-07-07 16:52:56 -04:00
parent fe55cd7588
commit 31c2477247
2 changed files with 4 additions and 62 deletions

View File

@ -121,7 +121,8 @@ fn generate_initial_reservoir(world_position: vec3<f32>, world_normal: vec3<f32>
fn load_temporal_reservoir(pixel_id: vec2<u32>, depth: f32, world_position: vec3<f32>, world_normal: vec3<f32>, rng: ptr<function, u32>) -> Reservoir {
let motion_vector = textureLoad(motion_vectors, pixel_id, 0).xy;
let temporal_pixel_id_float = vec2<f32>(pixel_id) - (motion_vector * view.viewport.zw);
let temporal_pixel_id_float = round(vec2<f32>(pixel_id) - (motion_vector * view.viewport.zw));
let temporal_pixel_id = vec2<u32>(temporal_pixel_id_float);
// Check if the current pixel was off screen during the previous frame (current pixel is newly visible),
// or if all temporal history should assumed to be invalid
@ -129,36 +130,6 @@ fn load_temporal_reservoir(pixel_id: vec2<u32>, depth: f32, world_position: vec3
return empty_reservoir();
}
// https://en.wikipedia.org/wiki/Bilinear_interpolation#On_the_unit_square
let tl = vec2<u32>(temporal_pixel_id_float);
let tr = tl + vec2(1u, 0u);
let bl = tl + vec2(0u, 1u);
let br = tl + vec2(1u, 1u);
let f = fract(temporal_pixel_id_float);
let tl_w = (1.0 - f.x) * (1.0 - f.y);
let tr_w = f.x * (1.0 - f.y);
let bl_w = (1.0 - f.x) * f.y;
// Choose a random pixel from the 2x2 quad, weighted by the bilinear weights
// This gives better results than always using the nearest pixel
var temporal_pixel_id = tl;
var weight_sum = tl_w;
let r = rand_f(rng);
if (r > weight_sum) {
temporal_pixel_id = tr;
weight_sum += tr_w;
}
if (r > weight_sum) {
temporal_pixel_id = bl;
weight_sum += bl_w;
}
if (r > weight_sum) {
temporal_pixel_id = br;
}
// Clamp to view size, since 2x2 quad may go off screen
temporal_pixel_id = min(temporal_pixel_id, vec2<u32>(view.viewport.zw - 1.0));
// Check if the pixel features have changed heavily between the current and previous frame
let temporal_depth = textureLoad(previous_depth_buffer, temporal_pixel_id, 0);
let temporal_gpixel = textureLoad(previous_gbuffer, temporal_pixel_id, 0);

View File

@ -112,7 +112,8 @@ fn generate_initial_reservoir(world_position: vec3<f32>, world_normal: vec3<f32>
fn load_temporal_reservoir(pixel_id: vec2<u32>, depth: f32, world_position: vec3<f32>, world_normal: vec3<f32>, rng: ptr<function, u32>) -> Reservoir {
let motion_vector = textureLoad(motion_vectors, pixel_id, 0).xy;
let temporal_pixel_id_float = vec2<f32>(pixel_id) - (motion_vector * view.viewport.zw);
let temporal_pixel_id_float = round(vec2<f32>(pixel_id) - (motion_vector * view.viewport.zw));
let temporal_pixel_id = vec2<u32>(temporal_pixel_id_float);
// Check if the current pixel was off screen during the previous frame (current pixel is newly visible),
// or if all temporal history should assumed to be invalid
@ -120,36 +121,6 @@ fn load_temporal_reservoir(pixel_id: vec2<u32>, depth: f32, world_position: vec3
return empty_reservoir();
}
// https://en.wikipedia.org/wiki/Bilinear_interpolation#On_the_unit_square
let tl = vec2<u32>(temporal_pixel_id_float);
let tr = tl + vec2(1u, 0u);
let bl = tl + vec2(0u, 1u);
let br = tl + vec2(1u, 1u);
let f = fract(temporal_pixel_id_float);
let tl_w = (1.0 - f.x) * (1.0 - f.y);
let tr_w = f.x * (1.0 - f.y);
let bl_w = (1.0 - f.x) * f.y;
// Choose a random pixel from the 2x2 quad, weighted by the bilinear weights
// This gives better results than always using the nearest pixel
var temporal_pixel_id = tl;
var weight_sum = tl_w;
let r = rand_f(rng);
if (r > weight_sum) {
temporal_pixel_id = tr;
weight_sum += tr_w;
}
if (r > weight_sum) {
temporal_pixel_id = bl;
weight_sum += bl_w;
}
if (r > weight_sum) {
temporal_pixel_id = br;
}
// Clamp to view size, since 2x2 quad may go off screen
temporal_pixel_id = min(temporal_pixel_id, vec2<u32>(view.viewport.zw - 1.0));
// Check if the pixel features have changed heavily between the current and previous frame
let temporal_depth = textureLoad(previous_depth_buffer, temporal_pixel_id, 0);
let temporal_gpixel = textureLoad(previous_gbuffer, temporal_pixel_id, 0);