Eevee: SSR: Fix Opengl Render.

Add a constant number of 4 drawing loop to accumulate 4 "bounce" of light in SSRs.
This commit is contained in:
Clément Foucault
2017-07-22 20:36:34 +02:00
parent 56ba01a561
commit 76bf4f2cd3
2 changed files with 48 additions and 32 deletions

View File

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

View File

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