diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-08-22 17:38:42 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-08-22 20:49:32 +0300 |
commit | 477b4559ece0d12ec0bab88d317b9fe2e1832417 (patch) | |
tree | 0116d849a0a662845375383fabccffe2a624972d /source | |
parent | 07d0f2eb01554ca6695310ca1bcbc7d129ab30a0 (diff) |
Paint Overlay: Fix blending of the brush overlay
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 7 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_image_alpha_color_frag.glsl | 5 |
2 files changed, 10 insertions, 2 deletions
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; } |