[Bf-blender-cvs] [1b7b1d60c5d] blender2.8: Fix T57835: Textured-fill layer opacity not working

Antonioya noreply at git.blender.org
Sun Nov 18 16:29:04 CET 2018


Commit: 1b7b1d60c5df7f2ca498e27c3f0977ff4a8ac25b
Author: Antonioya
Date:   Sun Nov 18 16:28:57 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB1b7b1d60c5df7f2ca498e27c3f0977ff4a8ac25b

Fix T57835: Textured-fill layer opacity not working

This was an unsupported feature.

===================================================================

M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl

===================================================================

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index ae62e61c5c1..9646a32d094 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -279,7 +279,8 @@ static void DRW_gpencil_recalc_geometry_caches(Object *ob, MaterialGPencilStyle
 /* create shading group for filling */
 static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
         GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass,
-        GPUShader *shader, bGPdata *gpd, MaterialGPencilStyle *gp_style, int id)
+        GPUShader *shader, bGPdata *gpd, bGPDlayer *gpl,
+		MaterialGPencilStyle *gp_style, int id)
 {
 	GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
 
@@ -330,6 +331,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
 	DRW_shgroup_uniform_vec2(grp, "texture_scale", gp_style->texture_scale, 1);
 	DRW_shgroup_uniform_vec2(grp, "texture_offset", gp_style->texture_offset, 1);
 	DRW_shgroup_uniform_float(grp, "texture_opacity", &gp_style->texture_opacity, 1);
+	DRW_shgroup_uniform_float(grp, "layer_opacity", &gpl->opacity, 1);
 
 	stl->shgroups[id].texture_mix = gp_style->flag & GP_STYLE_COLOR_TEX_MIX ? 1 : 0;
 	DRW_shgroup_uniform_int(grp, "texture_mix", &stl->shgroups[id].texture_mix, 1);
@@ -841,7 +843,8 @@ static void gpencil_draw_strokes(
 				    (gp_style->flag & GP_STYLE_FILL_SHOW))
 				{
 					stl->shgroups[id].shgrps_fill = DRW_gpencil_shgroup_fill_create(
-					        e_data, vedata, psl->stroke_pass, e_data->gpencil_fill_sh, gpd, gp_style, id);
+					        e_data, vedata, psl->stroke_pass, e_data->gpencil_fill_sh,
+							gpd, gpl, gp_style, id);
 				}
 				else {
 					stl->shgroups[id].shgrps_fill = NULL;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index d2cad4e44f7..1d57cdc4bcf 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -15,6 +15,7 @@ uniform int texture_mix;
 uniform int texture_flip;
 uniform float texture_opacity;
 uniform int xraymode;
+uniform float layer_opacity;
 
 uniform sampler2D myTexture;
 uniform int texture_clamp;
@@ -66,6 +67,7 @@ void set_color(in vec4 color, in vec4 color2, in vec4 tcolor, in float mixv, in
 			ocolor = (flip == 0) ? mix(color, color2, factor) : mix(color2, color, factor);
 		}
 	}
+	ocolor.a *= layer_opacity;
 }
 
 void main()
@@ -115,15 +117,17 @@ void main()
 			}
 			/* mix with texture */
 			fragColor = (texture_mix == 1) ? mix(chesscolor, text_color, mix_factor) : chesscolor;
+			fragColor.a *= layer_opacity;
 		}
 		/* texture */
 		if (fill_type == TEXTURE) {
 			fragColor = (texture_mix == 1) ? mix(text_color, finalColor, mix_factor) : text_color;
+			fragColor.a *= layer_opacity;
 		}
 		/* pattern */
 		if (fill_type == PATTERN) {
 			fragColor = finalColor;
-			fragColor.a = min(text_color.a, finalColor.a);
+			fragColor.a = min(text_color.a, finalColor.a) * layer_opacity;
 		}
 	}



More information about the Bf-blender-cvs mailing list