Fix T76558: Decreasing Viewport Anti-Aliasing Samples Makes Scene Whiter

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
This commit is contained in:
Jeroen Bakker
2020-05-14 12:44:26 +02:00
committed by Jeroen Bakker
parent 80fffba132
commit eb23b39b7f
3 changed files with 11 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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. */