From eb23b39b7f7f4e0531b9acff3769ec3fa4e236ee Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 14 May 2020 12:44:26 +0200 Subject: Fix T76558: Decreasing Viewport Anti-Aliasing Samples Makes Scene Whiter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting the Viewport Anti-Aliasing samples in the user preferences to a lower sample count the anti-aliasing was not reset. This lead to incorrect result as the accum buffer would still hold the values of the larger sample count. This fix resets the TAA when the sample count is changed. Reviewed By: Clément Foucault Differential Revision: https://developer.blender.org/D7728 --- .../draw/engines/workbench/workbench_effect_antialiasing.c | 8 ++++++++ source/blender/draw/engines/workbench/workbench_engine.c | 1 + source/blender/draw/engines/workbench/workbench_private.h | 2 ++ 3 files changed, 11 insertions(+) (limited to 'source/blender/draw/engines/workbench') diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c index 5c8730ac8f9..d2bd653a656 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c @@ -176,6 +176,14 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata) } } + /* Reset the TAA when we have already draw a sample, but the sample count differs from previous + * time. This removes render artifacts when the viewport anti-aliasing in the user preferences is + * set to a lower value. */ + if (wpd->taa_sample_len != wpd->taa_sample_len_previous) { + wpd->taa_sample = 0; + wpd->taa_sample_len_previous = wpd->taa_sample_len; + } + if (wpd->view_updated) { wpd->taa_sample = 0; wpd->view_updated = false; diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index a88076d5fd7..f11a4aab668 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -55,6 +55,7 @@ void workbench_engine_init(void *ved) if (!stl->wpd) { stl->wpd = MEM_callocN(sizeof(*stl->wpd), __func__); + stl->wpd->taa_sample_len_previous = -1; stl->wpd->view_updated = true; } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 2191e09bc24..967bdf9bae0 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -261,6 +261,8 @@ typedef struct WORKBENCH_PrivateData { /* Temporal Antialiasing */ /** Total number of samples to after which TAA stops accumulating samples. */ int taa_sample_len; + /** Total number of samples of the previous TAA. When changed TAA will be reset. */ + int taa_sample_len_previous; /** Current TAA sample index in [0..taa_sample_len[ range. */ int taa_sample; /** Inverse of taa_sample to divide the accumulation buffer. */ -- cgit v1.2.3