diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-01 09:55:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-07-01 09:55:20 +0300 |
commit | 6c7d0aebcbf05f35e256e32603be4b9026c16327 (patch) | |
tree | d4649fde579de7d177578a1a12ae9057b26b8b5e /source/blender/draw/engines | |
parent | 9f634a195d1f2bd4c16332fa513dfeffa0301977 (diff) |
Fix T75483: 3D Text selection obscures text
This avoids logic op and having to draw on the render frame-buffer.
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_edit_text.c | 27 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_private.h | 5 |
2 files changed, 27 insertions, 5 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.c index c4d020adc11..4ee936f5ce6 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.c +++ b/source/blender/draw/engines/overlay/overlay_edit_text.c @@ -53,13 +53,22 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.colorWire); } { - state = DRW_STATE_WRITE_COLOR | DRW_STATE_LOGIC_INVERT; + state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->edit_text_overlay_ps, state | pd->clipping_state); sh = OVERLAY_shader_uniform_color(); pd->edit_text_overlay_grp = grp = DRW_shgroup_create(sh, psl->edit_text_overlay_ps); - DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){1.0f, 1.0f, 1.0f, 1.0f}); + DRW_shgroup_uniform_vec4(grp, "color", pd->edit_text.overlay_color, 1); + + state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_MUL | DRW_STATE_DEPTH_GREATER_EQUAL | + pd->clipping_state; + DRW_PASS_INSTANCE_CREATE(psl->edit_text_darken_ps, psl->edit_text_overlay_ps, state); + } + { + /* Create view which will render everything (hopefully) behind the text geometry. */ + DRWView *default_view = (DRWView *)DRW_view_default_get(); + pd->view_edit_text = DRW_view_create_with_zoffset(default_view, draw_ctx->rv3d, -5.0f); } } @@ -193,16 +202,24 @@ void OVERLAY_edit_text_cache_populate(OVERLAY_Data *vedata, Object *ob) void OVERLAY_edit_text_draw(OVERLAY_Data *vedata) { + OVERLAY_PrivateData *pd = vedata->stl->pd; OVERLAY_PassList *psl = vedata->psl; - DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + OVERLAY_FramebufferList *fbl = vedata->fbl; if (DRW_state_is_fbo()) { - /* Text overlay need final color for color inversion. */ - GPU_framebuffer_bind(dfbl->default_fb); + GPU_framebuffer_bind(fbl->overlay_default_fb); } DRW_draw_pass(psl->edit_text_wire_ps[0]); DRW_draw_pass(psl->edit_text_wire_ps[1]); + DRW_view_set_active(pd->view_edit_text); + + /* Alpha blended. */ + copy_v4_fl4(pd->edit_text.overlay_color, 0.8f, 0.8f, 0.8f, 0.5f); DRW_draw_pass(psl->edit_text_overlay_ps); + + /* Multiply previous result where depth test fail. */ + copy_v4_fl4(pd->edit_text.overlay_color, 0.0f, 0.0f, 0.0f, 1.0f); + DRW_draw_pass(psl->edit_text_darken_ps); } diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index b643b8f535f..59fa58c0c03 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -71,6 +71,7 @@ typedef struct OVERLAY_PassList { DRWPass *edit_mesh_normals_ps; DRWPass *edit_particle_ps; DRWPass *edit_text_overlay_ps; + DRWPass *edit_text_darken_ps; DRWPass *edit_text_wire_ps[2]; DRWPass *extra_ps[2]; DRWPass *extra_blend_ps; @@ -264,6 +265,7 @@ typedef struct OVERLAY_PrivateData { DRWView *view_edit_faces_cage; DRWView *view_edit_edges; DRWView *view_edit_verts; + DRWView *view_edit_text; DRWView *view_reference_images; /** TODO get rid of this. */ @@ -300,6 +302,9 @@ typedef struct OVERLAY_PrivateData { int handle_display; } edit_curve; struct { + float overlay_color[4]; + } edit_text; + struct { int ghost_ob; int edit_ob; bool do_zbufclip; |