Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-09-10 00:24:06 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-09-10 00:26:14 +0300
commit6b551c0b8cb0a3de5fe9ae5e9f9ee3181cd931fc (patch)
treec099c311118e864fff4500338ff635918033df83 /source/blender/draw/engines/eevee/eevee_temporal_sampling.c
parentd69d68621fbc382b5a46c6c9edb191f1f7848aee (diff)
Eevee: Depth of Feild: Fix ringing issue of background objects
There was an issue caused by Antialiasing being done after DoF. Move TAA after DOF and Motion Blur. Also certain pixel with lower CoC would be spread all over the background because the neighbooring pixel have higher CoC. So we need to apply some bilateral filtering when downsampling. Currently we limit the influence of neighbor pixels with a CoC inside the range [MaxCoC-2, MaxCoC].
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_temporal_sampling.c')
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 6cb2d1d3b53..384fb28a776 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -297,8 +297,8 @@ void EEVEE_temporal_sampling_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data
psl->taa_resolve = DRW_pass_create("Temporal AA Resolve", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->taa_resolve);
- DRW_shgroup_uniform_texture_ref(grp, "colorHistoryBuffer", &txl->color_double_buffer);
- DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &txl->color);
+ DRW_shgroup_uniform_texture_ref(grp, "colorHistoryBuffer", &txl->taa_history);
+ DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &effects->source_buffer);
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
if (effects->enabled_effects & EFFECT_TAA_REPROJECT) {
@@ -312,16 +312,6 @@ void EEVEE_temporal_sampling_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data
}
}
-/* Special Swap */
-#define SWAP_BUFFER_TAA() do { \
- SWAP(struct GPUFrameBuffer *, fbl->effect_fb, fbl->double_buffer_fb); \
- SWAP(struct GPUFrameBuffer *, fbl->effect_color_fb, fbl->double_buffer_color_fb); \
- SWAP(GPUTexture *, txl->color_post, txl->color_double_buffer); \
- effects->swap_double_buffer = false; \
- effects->source_buffer = txl->color_double_buffer; \
- effects->target_buffer = fbl->main_color_fb; \
-} while (0);
-
void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
@@ -340,7 +330,7 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
effects->taa_alpha = 1.0f / (float)(effects->taa_current_sample);
}
- GPU_framebuffer_bind(fbl->effect_color_fb);
+ GPU_framebuffer_bind(effects->target_buffer);
DRW_draw_pass(psl->taa_resolve);
/* Restore the depth from sample 1. */
@@ -348,26 +338,30 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
GPU_framebuffer_blit(fbl->double_buffer_depth_fb, 0, fbl->main_fb, 0, GPU_DEPTH_BIT);
}
- SWAP_BUFFER_TAA();
+ SWAP_BUFFERS_TAA();
}
else {
if (!DRW_state_is_image_render()) {
- /* Do reprojection for noise reduction */
- /* TODO : do AA jitter if in only render view. */
- if ((effects->enabled_effects & EFFECT_TAA_REPROJECT) != 0 &&
- stl->g_data->valid_double_buffer)
- {
- GPU_framebuffer_bind(fbl->effect_color_fb);
- DRW_draw_pass(psl->taa_resolve);
-
- SWAP_BUFFER_TAA();
- }
-
/* Save the depth buffer for the next frame.
* This saves us from doing anything special
* in the other mode engines. */
GPU_framebuffer_blit(fbl->main_fb, 0, fbl->double_buffer_depth_fb, 0, GPU_DEPTH_BIT);
}
+
+ /* Do reprojection for noise reduction */
+ /* TODO : do AA jitter if in only render view. */
+ if (!DRW_state_is_image_render() &&
+ (effects->enabled_effects & EFFECT_TAA_REPROJECT) != 0 &&
+ stl->g_data->valid_taa_history)
+ {
+ GPU_framebuffer_bind(effects->target_buffer);
+ DRW_draw_pass(psl->taa_resolve);
+ SWAP_BUFFERS_TAA();
+ }
+ else {
+ struct GPUFrameBuffer *source_fb = (effects->target_buffer == fbl->main_color_fb) ? fbl->effect_color_fb : fbl->main_color_fb;
+ GPU_framebuffer_blit(source_fb, 0, fbl->taa_history_color_fb, 0, GPU_COLOR_BIT);
+ }
}
/* Make each loop count when doing a render. */