diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-02-11 17:18:55 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-02-11 17:19:04 +0300 |
commit | 804e90b42d728ecb1073af8d0bae15a91b13a469 (patch) | |
tree | 309de25d99c92286b10c9d27e547fd43a69299c1 /source/blender/draw/engines/eevee | |
parent | 58cdab8b9759dd59b55895f2f76b9624addbb324 (diff) |
DRW: Color Management improvement
Reviewed By: brecht sergey jbakker
Differential Revision: http://developer.blender.org/D6729
Diffstat (limited to 'source/blender/draw/engines/eevee')
5 files changed, 67 insertions, 123 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 824ea69ea73..a20921b639f 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -174,11 +174,6 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, effects->enabled_effects |= EFFECT_NORMAL_BUFFER; } - /* Alpha checker if background is not drawn in viewport. */ - if (!DRW_state_is_image_render() && !DRW_state_draw_background()) { - effects->enabled_effects |= EFFECT_ALPHA_CHECKER; - } - /** * MinMax Pyramid */ @@ -342,31 +337,6 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_uniform_mat4(grp, "pastPersmat", effects->velocity_past_persmat); DRW_shgroup_call(grp, quad, NULL); } - - if ((effects->enabled_effects & EFFECT_ALPHA_CHECKER) != 0) { - GPUShader *checker_sh = GPU_shader_get_builtin_shader(GPU_SHADER_2D_CHECKER); - - copy_v4_fl4(effects->color_checker_dark, 0.15f, 0.15f, 0.15f, 1.0f); - copy_v4_fl4(effects->color_checker_light, 0.2f, 0.2f, 0.2f, 1.0f); - - DRW_PASS_CREATE(psl->alpha_checker, - DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL); - grp = DRW_shgroup_create(checker_sh, psl->alpha_checker); - DRW_shgroup_uniform_vec4(grp, "color1", effects->color_checker_dark, 1); - DRW_shgroup_uniform_vec4(grp, "color2", effects->color_checker_light, 1); - DRW_shgroup_uniform_int_copy(grp, "size", 8); - DRW_shgroup_call(grp, quad, NULL); - - float viewmat[4][4], winmat[4][4]; - unit_m4(viewmat); - unit_m4(winmat); - /* Winmat must be negative. */ - swap_v3_v3(winmat[0], winmat[1]); - - /* Using default view bypasses the culling. */ - const DRWView *default_view = DRW_view_default_get(); - effects->checker_view = DRW_view_create_sub(default_view, viewmat, winmat); - } } void EEVEE_effects_draw_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) @@ -524,21 +494,6 @@ void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, i DRW_stats_group_end(); } -void EEVEE_draw_alpha_checker(EEVEE_Data *vedata) -{ - EEVEE_PassList *psl = vedata->psl; - EEVEE_StorageList *stl = vedata->stl; - EEVEE_EffectsInfo *effects = stl->effects; - - if ((effects->enabled_effects & EFFECT_ALPHA_CHECKER) != 0) { - DRW_view_set_active(effects->checker_view); - - DRW_draw_pass(psl->alpha_checker); - - DRW_view_set_active(NULL); - } -} - static void EEVEE_velocity_resolve(EEVEE_Data *vedata) { EEVEE_PassList *psl = vedata->psl; diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 420249ab930..e3b50bb2142 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -22,10 +22,11 @@ #include "DRW_render.h" +#include "draw_color_management.h" /* TODO remove dependency */ + #include "BLI_rand.h" #include "BKE_object.h" -#include "BKE_global.h" /* for G.debug_value */ #include "DEG_depsgraph_query.h" @@ -183,13 +184,11 @@ static void eevee_cache_finish(void *vedata) * the background and the scene pass are visible. * Note: we could break it up in two passes using some depth test * to reduce the fillrate */ -static void eevee_draw_background(void *vedata) +static void eevee_draw_scene(void *vedata) { EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; - EEVEE_TextureList *txl = ((EEVEE_Data *)vedata)->txl; EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; EEVEE_FramebufferList *fbl = ((EEVEE_Data *)vedata)->fbl; - EEVEE_EffectsInfo *effects = stl->effects; EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); /* Default framebuffer and texture */ @@ -338,79 +337,15 @@ static void eevee_draw_background(void *vedata) } if ((stl->g_data->render_passes & SCE_PASS_COMBINED) > 0) { - /* Tonemapping and transfer result to default framebuffer. */ - bool use_render_settings = stl->g_data->use_color_render_settings; - + /* Transfer result to default framebuffer. */ GPU_framebuffer_bind(dfbl->default_fb); - DRW_transform_to_display(stl->effects->final_tx, true, use_render_settings); - - /* Draw checkerboard with alpha under. */ - EEVEE_draw_alpha_checker(vedata); + DRW_transform_none(stl->effects->final_tx); } else { EEVEE_renderpasses_draw(sldata, vedata); } - /* Debug : Output buffer to view. */ - switch (G.debug_value) { - case 1: - if (txl->maxzbuffer) { - DRW_transform_to_display(txl->maxzbuffer, false, false); - } - break; - case 2: - if (effects->ssr_pdf_output) { - DRW_transform_to_display(effects->ssr_pdf_output, false, false); - } - break; - case 3: - if (effects->ssr_normal_input) { - DRW_transform_to_display(effects->ssr_normal_input, false, false); - } - break; - case 4: - if (effects->ssr_specrough_input) { - DRW_transform_to_display(effects->ssr_specrough_input, false, false); - } - break; - case 5: - if (txl->color_double_buffer) { - DRW_transform_to_display(txl->color_double_buffer, false, false); - } - break; - case 6: - if (effects->gtao_horizons_debug) { - DRW_transform_to_display(effects->gtao_horizons_debug, false, false); - } - break; - case 7: - if (effects->gtao_horizons) { - DRW_transform_to_display(effects->gtao_horizons, false, false); - } - break; - case 8: - if (effects->sss_irradiance) { - DRW_transform_to_display(effects->sss_irradiance, false, false); - } - break; - case 9: - if (effects->sss_radius) { - DRW_transform_to_display(effects->sss_radius, false, false); - } - break; - case 10: - if (effects->sss_albedo) { - DRW_transform_to_display(effects->sss_albedo, false, false); - } - break; - case 11: - if (effects->velocity_tx) { - DRW_transform_to_display(effects->velocity_tx, false, false); - } - break; - default: - break; - } + EEVEE_renderpasses_draw_debug(vedata); EEVEE_volumes_free_smoke_textures(); @@ -525,8 +460,7 @@ DrawEngineType draw_engine_eevee_type = { &eevee_cache_init, &EEVEE_cache_populate, &eevee_cache_finish, - &eevee_draw_background, - NULL, /* Everything is drawn in the background pass (see comment on function) */ + &eevee_draw_scene, &eevee_view_update, &eevee_id_update, &eevee_render_to_image, diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 97bde2e5f2e..8ba68589cbd 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -523,7 +523,6 @@ typedef enum EEVEE_EffectsFlag { EFFECT_VELOCITY_BUFFER = (1 << 12), /* Not really an effect but a feature */ EFFECT_TAA_REPROJECT = (1 << 13), /* should be mutually exclusive with EFFECT_TAA */ EFFECT_DEPTH_DOUBLE_BUFFER = (1 << 14), /* Not really an effect but a feature */ - EFFECT_ALPHA_CHECKER = (1 << 15), /* Not really an effect but a feature */ } EEVEE_EffectsFlag; typedef struct EEVEE_EffectsInfo { @@ -588,7 +587,6 @@ typedef struct EEVEE_EffectsInfo { /* Alpha Checker */ float color_checker_dark[4]; float color_checker_light[4]; - struct DRWView *checker_view; /* Other */ float prev_persmat[4][4]; /* Lookdev */ @@ -1057,6 +1055,7 @@ void EEVEE_renderpasses_postprocess(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, eScenePassType renderpass_type); void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); +void EEVEE_renderpasses_draw_debug(EEVEE_Data *vedata); void EEVEE_renderpasses_free(void); bool EEVEE_renderpasses_only_first_sample_pass_active(EEVEE_Data *vedata); diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c b/source/blender/draw/engines/eevee/eevee_renderpasses.c index 927ff70a52b..e3cdf98925c 100644 --- a/source/blender/draw/engines/eevee/eevee_renderpasses.c +++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c @@ -23,6 +23,10 @@ #include "DRW_engine.h" #include "DRW_render.h" +#include "draw_color_management.h" /* TODO remove dependency. */ + +#include "BKE_global.h" /* for G.debug_value */ + #include "BLI_string_utils.h" #include "DEG_depsgraph_query.h" @@ -239,6 +243,7 @@ void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) bool is_valid = (render_pass & EEVEE_RENDERPASSES_ALL) > 0; bool needs_color_transfer = (render_pass & EEVEE_RENDERPASSES_COLOR_PASS) > 0 && DRW_state_is_opengl_render(); + UNUSED_VARS(needs_color_transfer); /* When SSS isn't available, but the pass is requested, we mark it as invalid */ if ((render_pass & EEVEE_RENDERPASSES_SUBSURFACE) != 0 && @@ -261,7 +266,7 @@ void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) if (is_valid) { EEVEE_renderpasses_postprocess(sldata, vedata, render_pass); GPU_framebuffer_bind(dfbl->default_fb); - DRW_transform_to_display(txl->renderpass, needs_color_transfer, false); + DRW_transform_none(txl->renderpass); } else { /* Draw state is not valid for this pass, clear the buffer */ @@ -276,3 +281,54 @@ void EEVEE_renderpasses_free(void) { DRW_SHADER_FREE_SAFE(e_data.postprocess_sh); } + +void EEVEE_renderpasses_draw_debug(EEVEE_Data *vedata) +{ + EEVEE_TextureList *txl = vedata->txl; + EEVEE_StorageList *stl = vedata->stl; + EEVEE_EffectsInfo *effects = stl->effects; + + GPUTexture *tx = NULL; + /* Debug : Output buffer to view. */ + switch (G.debug_value) { + case 1: + tx = txl->maxzbuffer; + break; + case 2: + tx = effects->ssr_pdf_output; + break; + case 3: + tx = effects->ssr_normal_input; + break; + case 4: + tx = effects->ssr_specrough_input; + break; + case 5: + tx = txl->color_double_buffer; + break; + case 6: + tx = effects->gtao_horizons; + break; + case 7: + tx = effects->gtao_horizons; + break; + case 8: + tx = effects->sss_irradiance; + break; + case 9: + tx = effects->sss_radius; + break; + case 10: + tx = effects->sss_albedo; + break; + case 11: + tx = effects->velocity_tx; + break; + default: + break; + } + + if (tx) { + DRW_transform_none(tx); + } +}
\ No newline at end of file diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index 0f0b4a3e0a9..093a4780a97 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -198,7 +198,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data /** * Reset for each "redraw". When rendering using ogl render, - * we accumulate the redraw inside the drawing loop in eevee_draw_background(). + * we accumulate the redraw inside the drawing loop in eevee_draw_scene(). **/ effects->taa_render_sample = 1; effects->taa_view = NULL; @@ -251,7 +251,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data (effects->taa_current_sample < effects->taa_total_sample)) || DRW_state_is_image_render()) { if (view_is_valid) { - /* Viewport rendering updates the matrices in `eevee_draw_background` */ + /* Viewport rendering updates the matrices in `eevee_draw_scene` */ if (!DRW_state_is_image_render()) { effects->taa_current_sample += 1; repro_flag = 0; |