diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-03 02:46:45 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-03 02:48:39 +0300 |
commit | 0961ce04cbf0e7b46020d3e0a594c5d429a46c65 (patch) | |
tree | 393f9a92d7d2e5e2aa9f0323bf28c8185d927c59 | |
parent | 5a13f682ee5f55717c2fbc35371cd5bf58829b88 (diff) |
Fix T78124 Overlay: Image: Camera background image transparency not working
This changes to premultiplied blending for all cases and put the premult
in the shader.
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_image.c | 6 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/shaders/image_frag.glsl | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c index be3510967b6..a754f7cbd49 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.c @@ -61,11 +61,11 @@ void OVERLAY_image_cache_init(OVERLAY_Data *vedata) state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; DRW_PASS_CREATE(psl->image_empties_ps, state | pd->clipping_state); - state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA; + state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA_PREMUL; DRW_PASS_CREATE(psl->image_empties_back_ps, state | pd->clipping_state); DRW_PASS_CREATE(psl->image_empties_blend_ps, state | pd->clipping_state); - state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; + state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL; DRW_PASS_CREATE(psl->image_empties_front_ps, state); DRW_PASS_CREATE(psl->image_foreground_ps, state); } @@ -342,7 +342,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) mul_m4_m4m4(mat, modelmat, mat); const bool is_foreground = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != 0; - float color_premult_alpha[4] = {bgpic->alpha, bgpic->alpha, bgpic->alpha, bgpic->alpha}; + float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, bgpic->alpha}; DRWPass *pass = is_foreground ? psl->image_foreground_ps : psl->image_background_ps; diff --git a/source/blender/draw/engines/overlay/shaders/image_frag.glsl b/source/blender/draw/engines/overlay/shaders/image_frag.glsl index 298ba1e27ed..4d37f1599a3 100644 --- a/source/blender/draw/engines/overlay/shaders/image_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/image_frag.glsl @@ -26,4 +26,7 @@ void main() fragColor.a = 1.0; } } + + /* Pre-multiplied blending. */ + fragColor.rgb *= fragColor.a; } |