diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-07-22 21:36:34 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-07-24 16:36:36 +0300 |
commit | 76bf4f2cd3bb63a842cd9134637703d305090af7 (patch) | |
tree | a5215fbc9573e244525598146dd81dc329a9a603 /source/blender/draw/engines | |
parent | 56ba01a561f26d620dde51804f79da48950f199a (diff) |
Eevee: SSR: Fix Opengl Render.
Add a constant number of 4 drawing loop to accumulate 4 "bounce" of light in SSRs.
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_effects.c | 12 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_engine.c | 68 |
2 files changed, 48 insertions, 32 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 837d0a3b317..0c5f6ee9f4d 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -615,6 +615,8 @@ void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata) DRW_TEXTURE_FREE_SAFE(txl->ssr_normal_input); DRW_TEXTURE_FREE_SAFE(txl->ssr_specrough_input); DRW_FRAMEBUFFER_FREE_SAFE(fbl->screen_tracing_fb); + stl->g_data->ssr_hit_output = NULL; + stl->g_data->ssr_pdf_output = NULL; } /* Setup double buffer so we can access last frame as it was before post processes */ @@ -1219,12 +1221,20 @@ void EEVEE_draw_effects(EEVEE_Data *vedata) /* If no post processes is enabled, buffers are still not swapped, do it now. */ SWAP_DOUBLE_BUFFERS(); - if (!stl->g_data->valid_double_buffer && ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0)) { + if (!stl->g_data->valid_double_buffer && + ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0) && + (DRW_state_is_image_render() == false)) + { /* If history buffer is not valid request another frame. * This fix black reflections on area resize. */ DRW_viewport_request_redraw(); } + /* Update double buffer status if render mode. */ + if (DRW_state_is_image_render()) { + stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL); + DRW_viewport_matrix_get(stl->g_data->prev_persmat, DRW_MAT_PERS); + } } void EEVEE_effects_free(void) diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 0f6548d877d..2e0dce656da 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -144,48 +144,54 @@ static void EEVEE_draw_scene(void *vedata) /* Default framebuffer and texture */ DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - /* Refresh shadows */ - EEVEE_draw_shadows(sldata, psl); + /* Number of iteration: needed for all temporal effect (SSR, TAA) + * when using opengl render. */ + int loop_ct = DRW_state_is_image_render() ? 4 : 1; - /* Refresh Probes */ - EEVEE_lightprobes_refresh(sldata, vedata); + while (loop_ct--) { + /* Refresh shadows */ + EEVEE_draw_shadows(sldata, psl); - /* Attach depth to the hdr buffer and bind it */ - DRW_framebuffer_texture_detach(dtxl->depth); - DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0, 0); - DRW_framebuffer_bind(fbl->main); - DRW_framebuffer_clear(false, true, false, NULL, 1.0f); + /* Refresh Probes */ + EEVEE_lightprobes_refresh(sldata, vedata); - /* TODO move background after depth pass to cut some overdraw */ - DRW_draw_pass(psl->background_pass); + /* Attach depth to the hdr buffer and bind it */ + DRW_framebuffer_texture_detach(dtxl->depth); + DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0, 0); + DRW_framebuffer_bind(fbl->main); + DRW_framebuffer_clear(false, true, false, NULL, 1.0f); - /* Depth prepass */ - DRW_draw_pass(psl->depth_pass); - DRW_draw_pass(psl->depth_pass_cull); + /* TODO move background after depth pass to cut some overdraw */ + DRW_draw_pass(psl->background_pass); - /* Create minmax texture */ - EEVEE_create_minmax_buffer(vedata, dtxl->depth); + /* Depth prepass */ + DRW_draw_pass(psl->depth_pass); + DRW_draw_pass(psl->depth_pass_cull); - /* Restore main FB */ - DRW_framebuffer_bind(fbl->main); + /* Create minmax texture */ + EEVEE_create_minmax_buffer(vedata, dtxl->depth); - /* Shading pass */ - DRW_draw_pass(psl->probe_display); - EEVEE_draw_default_passes(psl); - DRW_draw_pass(psl->material_pass); + /* Restore main FB */ + DRW_framebuffer_bind(fbl->main); - /* Screen Space Reflections */ - EEVEE_effects_do_ssr(sldata, vedata); + /* Shading pass */ + DRW_draw_pass(psl->probe_display); + EEVEE_draw_default_passes(psl); + DRW_draw_pass(psl->material_pass); - /* Volumetrics */ - EEVEE_effects_do_volumetrics(sldata, vedata); + /* Screen Space Reflections */ + EEVEE_effects_do_ssr(sldata, vedata); - /* Transparent */ - DRW_pass_sort_shgroup_z(psl->transparent_pass); - DRW_draw_pass(psl->transparent_pass); + /* Volumetrics */ + EEVEE_effects_do_volumetrics(sldata, vedata); - /* Post Process */ - EEVEE_draw_effects(vedata); + /* Transparent */ + DRW_pass_sort_shgroup_z(psl->transparent_pass); + DRW_draw_pass(psl->transparent_pass); + + /* Post Process */ + EEVEE_draw_effects(vedata); + } } static void EEVEE_engine_free(void) |