Skip to content

Commit

Permalink
Added a heuristic component to the temporal filter to reduce its smea…
Browse files Browse the repository at this point in the history
…ring of specular reflections.

With the new materials and BRDF, specular channel often becomes more pronounced, and the temporal filter blurs it by redistributing the energy between the bilinear taps from the previous frame. Shortening the effective history when the surfaces are moving helps reduce that effect.
  • Loading branch information
apanteleev committed Sep 7, 2021
1 parent 17cad10 commit 8404266
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/refresh/vkpt/shader/asvgf_temporal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ main()
pos_prev = ((vec2(ipos) + vec2(0.5)) * vec2(global_ubo.inv_width * 2, global_ubo.inv_height) + motion.xy) * vec2(global_ubo.prev_width / 2, global_ubo.prev_height);
}

float motion_length = length(motion.xy * vec2(global_ubo.width, global_ubo.height));

// Load the parameters of the target pixel
float depth_curr;
vec3 normal_curr;
Expand Down Expand Up @@ -342,7 +344,8 @@ main()
if(temporal_sample_valid_spec)
{
// Same sequence as above, only for the specular channel
float antilag_alpha_spec = clamp(mix(1.0, global_ubo.flt_antilag_spec * grad_hf_spec.y, global_ubo.flt_temporal_spec), 0, 1);
float antilag = grad_hf_spec.y * global_ubo.flt_antilag_spec + motion_length * global_ubo.flt_antilag_spec_motion;
float antilag_alpha_spec = clamp(mix(1.0, antilag, global_ubo.flt_temporal_spec), 0, 1);
float hist_len_spec = min(temporal_color_histlen_spec.a * pow(1.0 - antilag_alpha_spec, 10) + 1.0, 256.0);
float alpha_color_spec = max(global_ubo.flt_min_alpha_color_spec, 1.0 / hist_len_spec);
alpha_color_spec = mix(alpha_color_spec, 1.0, antilag_alpha_spec);
Expand Down
1 change: 1 addition & 0 deletions src/refresh/vkpt/shader/global_ubo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
UBO_CVAR_DO(flt_antilag_hf, 1) /* A-SVGF anti-lag filter strength, [0..inf) */ \
UBO_CVAR_DO(flt_antilag_lf, 0.2) \
UBO_CVAR_DO(flt_antilag_spec, 2) \
UBO_CVAR_DO(flt_antilag_spec_motion, 0.004) /* scaler for motion vector scaled specular anti-blur adjustment */ \
UBO_CVAR_DO(flt_atrous_depth, 0.5) /* wavelet fitler sensitivity to depth, [0..inf) */ \
UBO_CVAR_DO(flt_atrous_deflicker_lf, 2) /* max brightness difference between adjacent pixels in the LF channel, (0..inf) */ \
UBO_CVAR_DO(flt_atrous_hf, 4) /* number of a-trous wavelet filter iterations on the LF channel, [0..4] */ \
Expand Down

0 comments on commit 8404266

Please sign in to comment.