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/workbench | |
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/workbench')
12 files changed, 74 insertions, 182 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_background_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_background_lib.glsl deleted file mode 100644 index 3ac220aee59..00000000000 --- a/source/blender/draw/engines/workbench/shaders/workbench_background_lib.glsl +++ /dev/null @@ -1,5 +0,0 @@ -vec3 background_color(WorldData world_data, float y) -{ - return mix(world_data.background_color_low, world_data.background_color_high, y).xyz + - (world_data.background_dither_factor * bayer_dither_noise()); -} diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl index f60eca24821..0c984b094d3 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl @@ -5,17 +5,12 @@ struct LightData { }; struct WorldData { - vec4 background_color_low; - vec4 background_color_high; vec4 object_outline_color; vec4 shadow_direction_vs; LightData lights[4]; vec4 ambient_color; int num_lights; int matcap_orientation; - float background_alpha; float curvature_ridge; float curvature_valley; - float background_dither_factor; - int pad[2]; }; diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl index 45ebf09d623..22fa2babbbf 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl @@ -13,11 +13,10 @@ layout(std140) uniform world_block void main() { vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize; - vec3 background = background_color(world_data, uv_viewport.y); #ifndef V3D_SHADING_OBJECT_OUTLINE - fragColor = vec4(background, world_data.background_alpha); + fragColor = vec4(0.0); #else /* !V3D_SHADING_OBJECT_OUTLINE */ @@ -25,16 +24,7 @@ void main() uint object_id = texelFetch(objectId, texel, 0).r; float object_outline = calculate_object_outline(objectId, texel, object_id); - if (object_outline == 0.0) { - fragColor = vec4(background, world_data.background_alpha); - } - else { - /* Do correct alpha blending. */ - vec4 background_color = vec4(background, 1.0) * world_data.background_alpha; - vec4 outline_color = vec4(world_data.object_outline_color.rgb, 1.0); - fragColor = mix(outline_color, background_color, object_outline); - fragColor = vec4(fragColor.rgb / max(1e-8, fragColor.a), fragColor.a); - } + fragColor = vec4(world_data.object_outline_color.rgb, 1.0) * (1.0 - object_outline); #endif /* !V3D_SHADING_OBJECT_OUTLINE */ } diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl index 6915055e356..91e1ebabae4 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl @@ -25,21 +25,11 @@ void main() vec3 trans_color = trans_accum.rgb / clamp(trans_accum.a, 1e-4, 5e4); -#ifndef ALPHA_COMPOSITE - vec3 bg_color = background_color(world_data, uv_viewport.y); - - bg_color = (world_data.background_alpha == 0.0) ? trans_color : bg_color; - vec4 color = mix( - vec4(trans_color, 1.0), vec4(bg_color, world_data.background_alpha), trans_revealage); + fragColor = vec4(trans_color, 1.0 - trans_revealage); -# ifdef V3D_SHADING_OBJECT_OUTLINE +#ifdef V3D_SHADING_OBJECT_OUTLINE uint object_id = texelFetch(objectId, texel, 0).r; float outline = calculate_object_outline(objectId, texel, object_id); - color = mix(vec4(world_data.object_outline_color.rgb, 1.0), color, outline); -# endif - - fragColor = color; -#else - fragColor = vec4(trans_color, 1.0 - trans_revealage); + fragColor = mix(vec4(world_data.object_outline_color.rgb, 1.0), fragColor, outline); #endif } diff --git a/source/blender/draw/engines/workbench/solid_mode.c b/source/blender/draw/engines/workbench/solid_mode.c index e1050751830..fed7e230a86 100644 --- a/source/blender/draw/engines/workbench/solid_mode.c +++ b/source/blender/draw/engines/workbench/solid_mode.c @@ -58,13 +58,12 @@ static void workbench_solid_cache_finish(void *vedata) workbench_deferred_cache_finish(data); } -static void workbench_solid_draw_background(void *vedata) +static void workbench_solid_draw_scene(void *vedata) { WORKBENCH_Data *data = vedata; 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); @@ -113,8 +112,7 @@ DrawEngineType draw_engine_workbench_solid = { &workbench_solid_cache_init, &workbench_solid_cache_populate, &workbench_solid_cache_finish, - &workbench_solid_draw_background, - NULL, + &workbench_solid_draw_scene, &workbench_solid_view_update, &workbench_solid_id_update, &workbench_render_to_image, diff --git a/source/blender/draw/engines/workbench/transparent_mode.c b/source/blender/draw/engines/workbench/transparent_mode.c index bd2fb24dd85..fef1ffded8d 100644 --- a/source/blender/draw/engines/workbench/transparent_mode.c +++ b/source/blender/draw/engines/workbench/transparent_mode.c @@ -56,13 +56,12 @@ static void workbench_transparent_cache_finish(void *vedata) workbench_forward_cache_finish(data); } -static void workbench_transparent_draw_background(void *vedata) +static void workbench_transparent_draw_scene(void *vedata) { WORKBENCH_Data *data = vedata; 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); @@ -91,8 +90,7 @@ DrawEngineType draw_engine_workbench_transparent = { &workbench_transparent_cache_init, &workbench_transparent_cache_populate, &workbench_transparent_cache_finish, - &workbench_transparent_draw_background, - NULL, + &workbench_transparent_draw_scene, &workbench_transparent_view_update, NULL, NULL, diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index f07b21ebcc2..056e6a6c364 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -99,8 +99,27 @@ static void workbench_world_data_update_shadow_direction_vs(WORKBENCH_PrivateDat /* Shadow direction. */ mul_v3_mat3_m4v3(wd->shadow_direction_vs, view_matrix, light_direction); } + /* \} */ +void workbench_clear_color_get(float color[4]) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + const Scene *scene = draw_ctx->scene; + + if (!DRW_state_is_scene_render() || !DRW_state_draw_background()) { + zero_v4(color); + } + else if (scene->world) { + copy_v3_v3(color, &scene->world->horr); + color[3] = 1.0f; + } + else { + zero_v3(color); + color[3] = 1.0f; + } +} + void workbench_effect_info_init(WORKBENCH_EffectInfo *effect_info) { effect_info->jitter_index = 0; @@ -152,39 +171,6 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) WORKBENCH_UBO_World *wd = &wpd->world_data; wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; - wd->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f; - - if ((scene->world != NULL) && - (!v3d || (v3d && ((v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD) || - (v3d->shading.type == OB_RENDER))))) { - copy_v3_v3(wd->background_color_low, &scene->world->horr); - copy_v3_v3(wd->background_color_high, &scene->world->horr); - } - else if (v3d && (v3d->shading.background_type == V3D_SHADING_BACKGROUND_VIEWPORT)) { - copy_v3_v3(wd->background_color_low, v3d->shading.background_color); - copy_v3_v3(wd->background_color_high, v3d->shading.background_color); - } - else if (v3d) { - UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_BACK_GRAD : TH_BACK, - wd->background_color_low); - UI_GetThemeColor3fv(TH_BACK, wd->background_color_high); - - /* XXX: Really quick conversion to avoid washed out background. - * Needs to be addressed properly (color managed using ocio). */ - if (wpd->use_color_management) { - srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high); - srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low); - } - else { - copy_v3_v3(wd->background_color_high, wd->background_color_high); - copy_v3_v3(wd->background_color_low, wd->background_color_low); - } - } - else { - zero_v3(wd->background_color_low); - zero_v3(wd->background_color_high); - } - wd->background_dither_factor = workbench_background_dither_factor(wpd); studiolight_update_world(wpd, wpd->studio_light, wd); @@ -197,13 +183,6 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) /* Will be NULL when rendering. */ if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { wpd->world_clip_planes = rv3d->clip; - UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, wpd->world_clip_planes_color); - if (wpd->use_color_management) { - srgb_to_linearrgb_v3_v3(wpd->world_clip_planes_color, wpd->world_clip_planes_color); - } - else { - copy_v3_v3(wpd->world_clip_planes_color, wpd->world_clip_planes_color); - } } else { wpd->world_clip_planes = NULL; @@ -298,5 +277,4 @@ void workbench_private_data_free(WORKBENCH_PrivateData *wpd) } DRW_UBO_FREE_SAFE(wpd->dof_ubo); - GPU_BATCH_DISCARD_SAFE(wpd->world_clip_planes_batch); } diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 3a62e150a9f..dfeb50248df 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -105,7 +105,6 @@ extern char datatoc_workbench_shadow_geom_glsl[]; extern char datatoc_workbench_shadow_caps_geom_glsl[]; extern char datatoc_workbench_shadow_debug_frag_glsl[]; -extern char datatoc_workbench_background_lib_glsl[]; extern char datatoc_workbench_cavity_lib_glsl[]; extern char datatoc_workbench_common_lib_glsl[]; extern char datatoc_workbench_data_lib_glsl[]; @@ -122,7 +121,6 @@ static char *workbench_build_composite_frag(WORKBENCH_PrivateData *wpd) BLI_dynstr_append(ds, datatoc_common_view_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl); - BLI_dynstr_append(ds, datatoc_workbench_background_lib_glsl); if (!FLAT_ENABLED(wpd)) { BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl); @@ -260,7 +258,6 @@ static GPUShader *ensure_background_shader(WORKBENCH_PrivateData *wpd) const char *defines = (index) ? "#define V3D_SHADING_OBJECT_OUTLINE\n" : NULL; char *frag = BLI_string_joinN(datatoc_workbench_data_lib_glsl, datatoc_workbench_common_lib_glsl, - datatoc_workbench_background_lib_glsl, datatoc_workbench_object_outline_lib_glsl, datatoc_workbench_deferred_background_frag_glsl); e_data.background_sh[index] = DRW_shader_create_fullscreen(frag, defines); @@ -481,8 +478,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) const float *viewport_size = DRW_viewport_size_get(); const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; const eGPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F; - const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : - GPU_R11F_G11F_B10F; + const eGPUTextureFormat comp_tex_format = GPU_RGBA16F; const eGPUTextureFormat col_tex_format = workbench_color_texture_format(wpd); const eGPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8; @@ -718,8 +714,12 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) /* Background Pass */ { - psl->background_pass = DRW_pass_create("Background", - DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; + if (DRW_state_is_scene_render()) { + /* Composite the scene over cleared background. */ + state |= DRW_STATE_BLEND_ALPHA_PREMUL; + } + psl->background_pass = DRW_pass_create("Background", state); grp = DRW_shgroup_create(wpd->background_sh, psl->background_pass); DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1); @@ -727,14 +727,6 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx); } DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL); - - if (RV3D_CLIPPING_ENABLED(draw_ctx->v3d, draw_ctx->rv3d)) { - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR_BACKGROUND); - grp = DRW_shgroup_create(shader, psl->background_pass); - wpd->world_clip_planes_batch = DRW_draw_background_clipping_batch_from_rv3d(draw_ctx->rv3d); - DRW_shgroup_call(grp, wpd->world_clip_planes_batch, NULL); - DRW_shgroup_uniform_vec4(grp, "color", &wpd->world_clip_planes_color[0], 1); - } } /* Deferred Mix Pass */ @@ -1269,30 +1261,6 @@ void workbench_deferred_cache_finish(WORKBENCH_Data *vedata) } } -void workbench_deferred_draw_background(WORKBENCH_Data *vedata) -{ - WORKBENCH_StorageList *stl = vedata->stl; - WORKBENCH_FramebufferList *fbl = vedata->fbl; - WORKBENCH_PrivateData *wpd = stl->g_data; - const float clear_depth = 1.0f; - const float clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - uint clear_stencil = 0x00; - - DRW_stats_group_start("Clear Background"); - - if (OBJECT_ID_PASS_ENABLED(wpd)) { - /* From all the color buffers, only object id needs to be cleared. */ - GPU_framebuffer_bind(fbl->id_clear_fb); - GPU_framebuffer_clear_color(fbl->id_clear_fb, clear_color); - } - - GPU_framebuffer_bind(fbl->prepass_fb); - int clear_bits = GPU_DEPTH_BIT; - SET_FLAG_FROM_TEST(clear_bits, SHADOW_ENABLED(wpd), GPU_STENCIL_BIT); - GPU_framebuffer_clear(fbl->prepass_fb, clear_bits, clear_color, clear_depth, clear_stencil); - DRW_stats_group_end(); -} - void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) { WORKBENCH_PassList *psl = vedata->psl; @@ -1306,8 +1274,21 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) workbench_taa_draw_scene_start(vedata); } - /* clear in background */ + const float clear_depth = 1.0f; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + uint clear_stencil = 0x00; + int clear_bits = GPU_DEPTH_BIT; + SET_FLAG_FROM_TEST(clear_bits, SHADOW_ENABLED(wpd), GPU_STENCIL_BIT); + + if (OBJECT_ID_PASS_ENABLED(wpd)) { + /* From all the color buffers, only object id needs to be cleared. */ + GPU_framebuffer_bind(fbl->id_clear_fb); + GPU_framebuffer_clear_color(fbl->id_clear_fb, clear_col); + } + GPU_framebuffer_bind(fbl->prepass_fb); + GPU_framebuffer_clear(fbl->prepass_fb, clear_bits, clear_col, clear_depth, clear_stencil); + DRW_draw_pass(psl->prepass_pass); DRW_draw_pass(psl->prepass_hair_pass); @@ -1334,6 +1315,13 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) DRW_draw_pass(psl->cavity_pass); } + if (DRW_state_is_scene_render()) { + float clear_color[4]; + workbench_clear_color_get(clear_color); + GPU_framebuffer_bind(fbl->composite_fb); + GPU_framebuffer_clear_color(fbl->composite_fb, clear_color); + } + if (SHADOW_ENABLED(wpd)) { #ifdef DEBUG_SHADOW_VOLUME GPU_framebuffer_bind(fbl->composite_fb); diff --git a/source/blender/draw/engines/workbench/workbench_effect_aa.c b/source/blender/draw/engines/workbench/workbench_effect_aa.c index ed311db0626..c03fe5cd5c8 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_aa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_aa.c @@ -22,6 +22,8 @@ #include "ED_screen.h" +#include "draw_color_management.h" + #include "workbench_private.h" void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx) @@ -53,16 +55,9 @@ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx) } } -static void workspace_aa_draw_transform(GPUTexture *tx, WORKBENCH_PrivateData *wpd) +static void workspace_aa_draw_transform(GPUTexture *tx, WORKBENCH_PrivateData *UNUSED(wpd)) { - if (DRW_state_do_color_management()) { - /* Display space result for viewport. */ - DRW_transform_to_display(tx, wpd->use_color_render_settings, wpd->use_color_render_settings); - } - else { - /* Linear result for render. */ - DRW_transform_none(tx); - } + DRW_transform_none(tx); } void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 05494b79af0..8d78373a057 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -72,7 +72,6 @@ extern char datatoc_workbench_forward_composite_frag_glsl[]; extern char datatoc_workbench_forward_depth_frag_glsl[]; extern char datatoc_workbench_forward_transparent_accum_frag_glsl[]; extern char datatoc_workbench_data_lib_glsl[]; -extern char datatoc_workbench_background_lib_glsl[]; extern char datatoc_workbench_checkerboard_depth_frag_glsl[]; extern char datatoc_workbench_object_outline_lib_glsl[]; extern char datatoc_workbench_curvature_lib_glsl[]; @@ -128,7 +127,6 @@ static char *workbench_build_forward_composite_frag(void) BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl); - BLI_dynstr_append(ds, datatoc_workbench_background_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_object_outline_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_curvature_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_forward_composite_frag_glsl); @@ -367,8 +365,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) const float *viewport_size = DRW_viewport_size_get(); const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; - const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : - GPU_R11F_G11F_B10F; + const eGPUTextureFormat comp_tex_format = GPU_RGBA16F; e_data.object_id_tx = DRW_texture_pool_query_2d( size[0], size[1], GPU_R32UI, &draw_engine_workbench_transparent); @@ -420,6 +417,10 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) /* Composite */ { int state = DRW_STATE_WRITE_COLOR; + if (DRW_state_is_scene_render()) { + /* Composite the scene over cleared background. */ + state |= DRW_STATE_BLEND_ALPHA_PREMUL; + } psl->composite_pass = DRW_pass_create("Composite", state); grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass); @@ -433,19 +434,6 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL); } - /* TODO(campbell): displays but masks geometry, - * only use with wire or solid-without-xray for now. */ - if ((wpd->shading.type != OB_WIRE && !XRAY_FLAG_ENABLED(wpd)) && - RV3D_CLIPPING_ENABLED(draw_ctx->v3d, draw_ctx->rv3d)) { - psl->background_pass = DRW_pass_create("Background", - DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR_BACKGROUND); - grp = DRW_shgroup_create(shader, psl->background_pass); - wpd->world_clip_planes_batch = DRW_draw_background_clipping_batch_from_rv3d(draw_ctx->rv3d); - DRW_shgroup_call(grp, wpd->world_clip_planes_batch, NULL); - DRW_shgroup_uniform_vec4(grp, "color", &wpd->world_clip_planes_color[0], 1); - } - { workbench_aa_create_pass(vedata, &e_data.transparent_accum_tx); } @@ -783,16 +771,6 @@ void workbench_forward_cache_finish(WORKBENCH_Data *UNUSED(vedata)) { } -void workbench_forward_draw_background(WORKBENCH_Data *UNUSED(vedata)) -{ - const float clear_depth = 1.0f; - DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - DRW_stats_group_start("Clear depth"); - GPU_framebuffer_bind(dfbl->default_fb); - GPU_framebuffer_clear_depth_stencil(dfbl->default_fb, clear_depth, 0xFF); - DRW_stats_group_end(); -} - void workbench_forward_draw_scene(WORKBENCH_Data *vedata) { WORKBENCH_PassList *psl = vedata->psl; @@ -827,6 +805,13 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata) /* Composite */ GPU_framebuffer_bind(fbl->composite_fb); + + if (DRW_state_is_scene_render()) { + float clear_color[4]; + workbench_clear_color_get(clear_color); + GPU_framebuffer_clear_color(fbl->composite_fb, clear_color); + } + DRW_draw_pass(psl->composite_pass); DRW_draw_pass(psl->volume_pass); diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index e100f6e875c..6b459c3693e 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -183,19 +183,14 @@ typedef struct WORKBENCH_UBO_Light { } WORKBENCH_UBO_Light; typedef struct WORKBENCH_UBO_World { - float background_color_low[4]; - float background_color_high[4]; float object_outline_color[4]; float shadow_direction_vs[4]; WORKBENCH_UBO_Light lights[4]; float ambient_color[4]; int num_lights; int matcap_orientation; - float background_alpha; float curvature_ridge; float curvature_valley; - float background_dither_factor; - int pad[2]; } WORKBENCH_UBO_World; BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_World, 16) @@ -249,8 +244,6 @@ typedef struct WORKBENCH_PrivateData { bool is_playback; float (*world_clip_planes)[4]; - struct GPUBatch *world_clip_planes_batch; - float world_clip_planes_color[4]; /* Volumes */ bool volumes_do; @@ -434,26 +427,15 @@ BLI_INLINE eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_Priv TEXTURE_DRAWING_ENABLED(wpd)) { result = GPU_RGBA16F; } - else if (workbench_is_in_vertex_paint_mode() || VERTEX_COLORS_ENABLED(wpd)) { - result = GPU_RGBA16; - } else { - result = GPU_RGBA8; + result = GPU_RGBA16; } return result; } -BLI_INLINE bool workbench_background_dither_factor(const WORKBENCH_PrivateData *wpd) -{ - /* Only apply dithering when rendering on a RGBA8 texture. - * The dithering will remove banding when using a gradient as background */ - return workbench_color_texture_format(wpd) == GPU_RGBA8; -} - /* workbench_deferred.c */ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); -void workbench_deferred_draw_background(WORKBENCH_Data *vedata); void workbench_deferred_draw_scene(WORKBENCH_Data *vedata); void workbench_deferred_draw_finish(WORKBENCH_Data *vedata); void workbench_deferred_cache_init(WORKBENCH_Data *vedata); @@ -463,7 +445,6 @@ void workbench_deferred_cache_finish(WORKBENCH_Data *vedata); /* workbench_forward.c */ void workbench_forward_engine_init(WORKBENCH_Data *vedata); void workbench_forward_engine_free(void); -void workbench_forward_draw_background(WORKBENCH_Data *vedata); void workbench_forward_draw_scene(WORKBENCH_Data *vedata); void workbench_forward_draw_finish(WORKBENCH_Data *vedata); void workbench_forward_cache_init(WORKBENCH_Data *vedata); @@ -567,6 +548,7 @@ void workbench_effect_info_init(WORKBENCH_EffectInfo *effect_info); void workbench_private_data_init(WORKBENCH_PrivateData *wpd); void workbench_private_data_free(WORKBENCH_PrivateData *wpd); void workbench_private_data_get_light_direction(float r_light_direction[3]); +void workbench_clear_color_get(float color[4]); /* workbench_volume.c */ void workbench_volume_engine_init(void); diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c index 899fbdc9b71..c8f74120113 100644 --- a/source/blender/draw/engines/workbench/workbench_render.c +++ b/source/blender/draw/engines/workbench/workbench_render.c @@ -159,7 +159,6 @@ void workbench_render(WORKBENCH_Data *data, if (RE_engine_test_break(engine)) { break; } - workbench_deferred_draw_background(data); workbench_deferred_draw_scene(data); } @@ -186,7 +185,6 @@ void workbench_render(WORKBENCH_Data *data, break; } - workbench_forward_draw_background(data); workbench_forward_draw_scene(data); } |