diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 36568632ffa..5cca61d4c78 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -685,6 +685,7 @@ static void paint_draw_tex_overlay( immUniformColor4f(1.0f, 1.0f, 1.0f, overlay_alpha * 0.01f); } else { + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_ALPHA_COLOR); immUniformColor3fvAlpha(U.sculpt_paint_overlay_col, overlay_alpha * 0.01f); } @@ -704,6 +705,7 @@ static void paint_draw_tex_overlay( immEnd(); immUnbindProgram(); + GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_VIEW)) { GPU_matrix_pop(); @@ -764,7 +766,8 @@ static void paint_draw_cursor_overlay( uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_ALPHA_COLOR); immUniformColor3fvAlpha(U.sculpt_paint_overlay_col, brush->cursor_overlay_alpha * 0.01f); @@ -786,6 +789,8 @@ static void paint_draw_cursor_overlay( immUnbindProgram(); + GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); + if (do_pop) GPU_matrix_pop(); } diff --git a/source/blender/gpu/shaders/gpu_shader_image_alpha_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_alpha_color_frag.glsl index 727c3c0a832..fc0c8609069 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_alpha_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_alpha_color_frag.glsl @@ -7,5 +7,8 @@ uniform sampler2D image; void main() { - fragColor = texture(image, texCoord_interp).r * color; + fragColor = texture(image, texCoord_interp).r * color.rgba; + /* Premul by alpha (not texture alpha) + * Use blending function GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); */ + fragColor.rgb *= color.a; }