Workbench: Fix TAA logic
authorClément Foucault <foucault.clem@gmail.com>
Tue, 21 May 2019 08:07:41 +0000 (10:07 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Wed, 22 May 2019 11:29:04 +0000 (13:29 +0200)
Having both TAA and FXAA enabled at the same time resulted in conflicts.
The jitter_index was incremented twice before being used instead of once.

source/blender/draw/engines/workbench/workbench_effect_aa.c
source/blender/draw/engines/workbench/workbench_effect_taa.c
source/blender/draw/engines/workbench/workbench_private.h

index b4cdcfc..965f5a5 100644 (file)
@@ -49,6 +49,7 @@ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx)
   }
   else {
     psl->effect_aa_pass = NULL;
+    effect_info->jitter_index = 0;
   }
 }
 
index 69f41f5..7fd68ba 100644 (file)
@@ -243,7 +243,7 @@ void workbench_taa_draw_scene_start(WORKBENCH_Data *vedata)
 
   const int jitter_index = effect_info->jitter_index;
   const float *transform_offset = samples[jitter_index];
-  effect_info->taa_mix_factor = 1.0f / (effect_info->jitter_index + 1);
+  effect_info->taa_mix_factor = 1.0f / (jitter_index + 1);
   effect_info->jitter_index = (jitter_index + 1) % num_samples;
 
   /* construct new matrices from transform delta */
index af94019..240d06c 100644 (file)
@@ -326,7 +326,8 @@ BLI_INLINE bool workbench_is_taa_enabled(WORKBENCH_PrivateData *wpd)
     }
   }
   else {
-    return wpd->preferences->viewport_aa > SCE_DISPLAY_AA_FXAA && !wpd->is_playback;
+    return !(IS_NAVIGATING(wpd) || wpd->is_playback) &&
+           wpd->preferences->viewport_aa > SCE_DISPLAY_AA_FXAA;
   }
 }
 
@@ -346,8 +347,9 @@ BLI_INLINE bool workbench_is_fxaa_enabled(WORKBENCH_PrivateData *wpd)
       return true;
     }
 
-    /* when navigating or animation playback use FXAA. */
-    return (IS_NAVIGATING(wpd) || wpd->is_playback) && workbench_is_taa_enabled(wpd);
+    /* when navigating or animation playback use FXAA if scene uses TAA. */
+    return (IS_NAVIGATING(wpd) || wpd->is_playback) &&
+           wpd->preferences->viewport_aa > SCE_DISPLAY_AA_FXAA;
   }
 }