diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-05-02 16:18:53 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-05-02 17:19:12 +0300 |
commit | b52a0c78aff3afd49c0712ee35ba01f6b48662f7 (patch) | |
tree | 3dadc3f008de4c77962299777357a6075732ce41 /source/blender/draw/engines | |
parent | 76193106d2e3d1d211af33f39a3714e22944cb18 (diff) |
Workbench,EEVEE: Viewport Render Samples
- Add `render_aa` and `viewport_aa` sampling setting for workbench. 0
samples means no AA, 1 sample uses FXAA and more samples will use
TAA.
The viewport `gpu_viewport_quality` can still limit viewport anti-aliasing
method.
- Use TAA when rendering images. (this used to be CPU based FSAA)
- Removed `R_OSA` related settings.
Reviewers: fclem, brecht
Maniphest Tasks: T60847
Differential Revision: https://developer.blender.org/D4773
Diffstat (limited to 'source/blender/draw/engines')
8 files changed, 77 insertions, 35 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 962bc8e5efb..26f33f4db31 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -180,12 +180,13 @@ static void eevee_draw_background(void *vedata) /* Sort transparents before the loop. */ DRW_pass_sort_shgroup_z(psl->transparent_pass); - /* Number of iteration: needed for all temporal effect (SSR, volumetrics) - * when using opengl render. */ - int loop_len = (DRW_state_is_image_render() && - (stl->effects->enabled_effects & (EFFECT_VOLUMETRIC | EFFECT_SSR)) != 0) ? - 4 : - 1; + /* Number of iteration: Use viewport taa_samples when using viewport rendering */ + int loop_len = 1; + if (DRW_state_is_image_render()) { + const DRWContextState *draw_ctx = DRW_context_state_get(); + const Scene *scene = draw_ctx->scene; + loop_len = MAX2(1, scene->eevee.taa_samples); + } while (loop_len--) { float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; diff --git a/source/blender/draw/engines/workbench/solid_mode.c b/source/blender/draw/engines/workbench/solid_mode.c index a01b14f17fb..e1050751830 100644 --- a/source/blender/draw/engines/workbench/solid_mode.c +++ b/source/blender/draw/engines/workbench/solid_mode.c @@ -61,8 +61,12 @@ static void workbench_solid_cache_finish(void *vedata) static void workbench_solid_draw_background(void *vedata) { WORKBENCH_Data *data = vedata; - workbench_deferred_draw_background(data); - workbench_deferred_draw_scene(data); + const int num_samples = workbench_num_viewport_rendering_iterations(data); + + for (int sample = 0; sample < num_samples; sample++) { + workbench_deferred_draw_background(data); + workbench_deferred_draw_scene(data); + } workbench_deferred_draw_finish(data); } diff --git a/source/blender/draw/engines/workbench/transparent_mode.c b/source/blender/draw/engines/workbench/transparent_mode.c index 0f4150ff986..bd2fb24dd85 100644 --- a/source/blender/draw/engines/workbench/transparent_mode.c +++ b/source/blender/draw/engines/workbench/transparent_mode.c @@ -59,8 +59,12 @@ static void workbench_transparent_cache_finish(void *vedata) static void workbench_transparent_draw_background(void *vedata) { WORKBENCH_Data *data = vedata; - workbench_forward_draw_background(data); - workbench_forward_draw_scene(data); + const int num_samples = workbench_num_viewport_rendering_iterations(data); + + for (int sample = 0; sample < num_samples; sample++) { + workbench_forward_draw_background(data); + workbench_forward_draw_scene(data); + } workbench_forward_draw_finish(data); } diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 5d7bdc72546..a4c09efb28b 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -1156,7 +1156,7 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) WORKBENCH_PrivateData *wpd = stl->g_data; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - if (TAA_ENABLED(wpd)) { + if (workbench_is_taa_enabled(wpd)) { workbench_taa_draw_scene_start(vedata); } diff --git a/source/blender/draw/engines/workbench/workbench_effect_aa.c b/source/blender/draw/engines/workbench/workbench_effect_aa.c index a80f6ce338b..b4cdcfcfc99 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_aa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_aa.c @@ -40,10 +40,10 @@ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx) wpd->is_playback = false; } - if (TAA_ENABLED(wpd)) { + if (workbench_is_taa_enabled(wpd)) { psl->effect_aa_pass = workbench_taa_create_pass(vedata, tx); } - else if (FXAA_ENABLED(wpd)) { + else if (workbench_is_fxaa_enabled(wpd)) { psl->effect_aa_pass = workbench_fxaa_create_pass(tx); effect_info->jitter_index = 0; } @@ -73,13 +73,13 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) WORKBENCH_EffectInfo *effect_info = stl->effects; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - if (FXAA_ENABLED(wpd)) { + if (workbench_is_fxaa_enabled(wpd)) { GPU_framebuffer_bind(fbl->effect_fb); workspace_aa_draw_transform(tx, wpd); GPU_framebuffer_bind(dfbl->color_only_fb); DRW_draw_pass(psl->effect_aa_pass); } - else if (TAA_ENABLED(wpd)) { + else if (workbench_is_taa_enabled(wpd)) { /* * when drawing the first TAA frame, we transform directly to the * color_only_fb as the TAA shader is just performing a direct copy. diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 0435a804fab..7c411135634 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -90,26 +90,40 @@ int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata) { WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PrivateData *wpd = stl->g_data; - int result = 1; - if (TAA_ENABLED(wpd)) { + const Scene *scene = DRW_context_state_get()->scene; + int result = scene->display.viewport_aa; + if (workbench_is_taa_enabled(wpd)) { if (DRW_state_is_image_render()) { - const Scene *scene = DRW_context_state_get()->scene; - result = (scene->r.mode & R_OSA) ? scene->r.osa : 1; + result = scene->display.render_aa; } else if (IN_RANGE_INCL(wpd->preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_TAA8, GPU_VIEWPORT_QUALITY_TAA16)) { - result = 8; + result = MIN2(result, 8); } else if (IN_RANGE_INCL(wpd->preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_TAA16, GPU_VIEWPORT_QUALITY_TAA32)) { - result = 16; + result = MIN2(result, 16); } else { - result = 32; + result = MIN2(result, 32); } } + else { + /* when no TAA is disabled return 1 to render a single sample + * see `workbench_render.c` */ + result = 1; + } + return result; +} + +int workbench_num_viewport_rendering_iterations(WORKBENCH_Data *UNUSED(vedata)) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + const Scene *scene = draw_ctx->scene; + int result = DRW_state_is_image_render() ? scene->display.viewport_aa : 1; + result = MAX2(result, 1); return result; } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 00590940ac3..7766fe918ca 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -682,7 +682,7 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata) WORKBENCH_PrivateData *wpd = stl->g_data; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - if (TAA_ENABLED(wpd)) { + if (workbench_is_taa_enabled(wpd)) { workbench_taa_draw_scene_start(vedata); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 3cfb1283416..e25503aef6e 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -75,18 +75,7 @@ #define IS_NAVIGATING(wpd) \ ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING)) -#define FXAA_ENABLED(wpd) \ - ((!DRW_state_is_opengl_render()) && \ - (IN_RANGE(wpd->preferences->gpu_viewport_quality, \ - GPU_VIEWPORT_QUALITY_FXAA, \ - GPU_VIEWPORT_QUALITY_TAA8) || \ - ((IS_NAVIGATING(wpd) || wpd->is_playback) && \ - (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8)))) -#define TAA_ENABLED(wpd) \ - ((DRW_state_is_image_render() && DRW_context_state_get()->scene->r.mode & R_OSA) || \ - (!DRW_state_is_image_render() && \ - wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd) && \ - !wpd->is_playback)) + #define SPECULAR_HIGHLIGHT_ENABLED(wpd) \ (STUDIOLIGHT_ENABLED(wpd) && (wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && \ (!STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd))) @@ -326,6 +315,35 @@ typedef struct WORKBENCH_ObjectData { int object_id; } WORKBENCH_ObjectData; +/* inline helper functions */ +BLI_INLINE bool workbench_is_taa_enabled(WORKBENCH_PrivateData *wpd) +{ + if (DRW_state_is_image_render()) { + return DRW_context_state_get()->scene->display.render_aa > SCE_DISPLAY_AA_FXAA; + } + else { + return DRW_context_state_get()->scene->display.viewport_aa > SCE_DISPLAY_AA_FXAA && + wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && + !wpd->is_playback; + } +} + +BLI_INLINE bool workbench_is_fxaa_enabled(WORKBENCH_PrivateData *wpd) +{ + if (DRW_state_is_image_render()) { + return DRW_context_state_get()->scene->display.render_aa == SCE_DISPLAY_AA_FXAA; + } + else { + if (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_FXAA && + DRW_context_state_get()->scene->display.viewport_aa == SCE_DISPLAY_AA_FXAA) { + return true; + } + + /* when navigating or animation playback use FXAA. */ + return (IS_NAVIGATING(wpd) || wpd->is_playback) && workbench_is_taa_enabled(wpd); + } +} + /* workbench_deferred.c */ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); @@ -375,6 +393,7 @@ void workbench_taa_draw_scene_start(WORKBENCH_Data *vedata); void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata); void workbench_taa_view_updated(WORKBENCH_Data *vedata); int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata); +int workbench_num_viewport_rendering_iterations(WORKBENCH_Data *vedata); /* workbench_effect_dof.c */ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera); |