diff options
Diffstat (limited to 'source/blender/draw')
5 files changed, 66 insertions, 1 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 9b900a53d8d..9788d38478c 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -98,6 +98,7 @@ static void OVERLAY_engine_init(void *vedata) OVERLAY_image_init(vedata); OVERLAY_outline_init(vedata); OVERLAY_wireframe_init(vedata); + OVERLAY_paint_init(vedata); } static void OVERLAY_cache_init(void *vedata) diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index e88a69b695e..bb0b124f2ae 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -28,6 +28,15 @@ #include "overlay_private.h" +void OVERLAY_paint_init(OVERLAY_Data *vedata) +{ + OVERLAY_StorageList *stl = vedata->stl; + OVERLAY_PrivateData *pd = stl->pd; + const DRWContextState *draw_ctx = DRW_context_state_get(); + + pd->painting.in_front = draw_ctx->obact && (draw_ctx->obact->dtx & OB_DRAWXRAY); +} + void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) { const DRWContextState *draw_ctx = DRW_context_state_get(); @@ -194,12 +203,15 @@ void OVERLAY_paint_weight_cache_populate(OVERLAY_Data *vedata, Object *ob) void OVERLAY_paint_draw(OVERLAY_Data *vedata) { + OVERLAY_StorageList *stl = vedata->stl; + OVERLAY_PrivateData *pd = stl->pd; + OVERLAY_PassList *psl = vedata->psl; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); if (DRW_state_is_fbo()) { /* Pain overlay needs final color because of multiply blend mode. */ - GPU_framebuffer_bind(dfbl->default_fb); + GPU_framebuffer_bind(pd->painting.in_front ? dfbl->in_front_fb : dfbl->default_fb); } if (psl->paint_color_ps) { diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index de35d4f760e..47c52c885b2 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -317,6 +317,9 @@ typedef struct OVERLAY_PrivateData { bool do_pose_fade_geom; } armature; struct { + bool in_front; + } painting; + struct { DRWCallBuffer *handle[2]; } mball; } OVERLAY_PrivateData; /* Transient data */ @@ -524,6 +527,7 @@ void OVERLAY_outline_cache_populate(OVERLAY_Data *vedata, bool init_dupli); void OVERLAY_outline_draw(OVERLAY_Data *vedata); +void OVERLAY_paint_init(OVERLAY_Data *vedata); void OVERLAY_paint_cache_init(OVERLAY_Data *vedata); void OVERLAY_paint_texture_cache_populate(OVERLAY_Data *vedata, Object *ob); void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob); diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c index 3cd21dfeace..3050093062f 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c @@ -133,6 +133,32 @@ void workbench_antialiasing_view_updated(WORKBENCH_Data *vedata) } } +/* This function checks if the overlay engine should need center in front depth's. + * When that is the case the in front depth are stored and restored. Otherwise it + * will be filled with the current sample data. */ +static bool workbench_in_front_history_needed(WORKBENCH_Data *vedata) +{ + WORKBENCH_StorageList *stl = vedata->stl; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const View3D *v3d = draw_ctx->v3d; + const Object *obact = draw_ctx->obact; + + if (!v3d || (v3d->flag2 & V3D_HIDE_OVERLAYS)) { + return false; + } + + if (stl->wpd->is_playback) { + return false; + } + + if (!obact || draw_ctx->object_mode != OB_MODE_WEIGHT_PAINT || + v3d->overlay.weight_paint_mode_opacity == 0.0) { + return false; + } + + return true; +} + void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata) { WORKBENCH_FramebufferList *fbl = vedata->fbl; @@ -168,6 +194,13 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata) DRW_texture_ensure_fullscreen_2d(&txl->history_buffer_tx, GPU_RGBA16F, DRW_TEX_FILTER); DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0); + const bool in_front_history = workbench_in_front_history_needed(vedata); + if (in_front_history) { + DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_in_front_tx, GPU_DEPTH24_STENCIL8, 0); + } + else { + DRW_TEXTURE_FREE_SAFE(txl->depth_buffer_in_front_tx); + } wpd->smaa_edge_tx = DRW_texture_pool_query_fullscreen(GPU_RG8, owner); wpd->smaa_weight_tx = DRW_texture_pool_query_fullscreen(GPU_RGBA8, owner); @@ -177,6 +210,12 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata) GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_tx), GPU_ATTACHMENT_TEXTURE(txl->history_buffer_tx), }); + if (in_front_history) { + GPU_framebuffer_ensure_config(&fbl->antialiasing_in_front_fb, + { + GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_in_front_tx), + }); + } GPU_framebuffer_ensure_config(&fbl->smaa_edge_fb, { @@ -227,6 +266,7 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata) /* Cleanup */ DRW_TEXTURE_FREE_SAFE(txl->history_buffer_tx); DRW_TEXTURE_FREE_SAFE(txl->depth_buffer_tx); + DRW_TEXTURE_FREE_SAFE(txl->depth_buffer_in_front_tx); DRW_TEXTURE_FREE_SAFE(txl->smaa_search_tx); DRW_TEXTURE_FREE_SAFE(txl->smaa_area_tx); } @@ -387,6 +427,9 @@ void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata) * In this case no need to save the depth buffer. */ eGPUFrameBufferBits bits = GPU_COLOR_BIT | (!wpd->is_playback ? GPU_DEPTH_BIT : 0); GPU_framebuffer_blit(dfbl->default_fb, 0, fbl->antialiasing_fb, 0, bits); + if (workbench_in_front_history_needed(vedata)) { + GPU_framebuffer_blit(dfbl->in_front_fb, 0, fbl->antialiasing_in_front_fb, 0, GPU_DEPTH_BIT); + } } else { /* Accumulate result to the TAA buffer. */ @@ -394,6 +437,9 @@ void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata) DRW_draw_pass(psl->aa_accum_ps); /* Copy back the saved depth buffer for correct overlays. */ GPU_framebuffer_blit(fbl->antialiasing_fb, 0, dfbl->default_fb, 0, GPU_DEPTH_BIT); + if (workbench_in_front_history_needed(vedata)) { + GPU_framebuffer_blit(fbl->antialiasing_in_front_fb, 0, dfbl->in_front_fb, 0, GPU_DEPTH_BIT); + } } if (!DRW_state_is_image_render() || wpd->taa_sample + 1 == wpd->taa_sample_len) { diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 1fa49c8f818..87b1c82ce94 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -88,6 +88,7 @@ typedef struct WORKBENCH_FramebufferList { struct GPUFrameBuffer *dof_blur2_fb; struct GPUFrameBuffer *antialiasing_fb; + struct GPUFrameBuffer *antialiasing_in_front_fb; struct GPUFrameBuffer *smaa_edge_fb; struct GPUFrameBuffer *smaa_weight_fb; } WORKBENCH_FramebufferList; @@ -97,6 +98,7 @@ typedef struct WORKBENCH_TextureList { struct GPUTexture *coc_halfres_tx; struct GPUTexture *history_buffer_tx; struct GPUTexture *depth_buffer_tx; + struct GPUTexture *depth_buffer_in_front_tx; struct GPUTexture *smaa_search_tx; struct GPUTexture *smaa_area_tx; struct GPUTexture *dummy_image_tx; |