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.
This commit is contained in:
parent
5a13f682ee
commit
0961ce04cb
Notes:
blender-bot
2023-02-14 02:43:21 +01:00
Referenced by issue #95398, Unable to adjust Opacity of Camera Background Image Referenced by issue #78124, Bug with transparency on camera background image
|
@ -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;
|
||||
|
||||
|
|
|
@ -26,4 +26,7 @@ void main()
|
|||
fragColor.a = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pre-multiplied blending. */
|
||||
fragColor.rgb *= fragColor.a;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue