[Bf-blender-cvs] [fdb51ac2800] greasepencil-object: Enable layer opacity in blend layers

Antonioya noreply at git.blender.org
Sun Nov 25 16:27:06 CET 2018


Commit: fdb51ac2800100dd3f068bf7920e192ee7ad87e5
Author: Antonioya
Date:   Sun Nov 25 16:26:01 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBfdb51ac2800100dd3f068bf7920e192ee7ad87e5

Enable layer opacity in blend layers

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index d6da5648ab5..52049704ded 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -144,7 +144,6 @@ class DATA_PT_gpencil_datapanel(Panel):
             subrow.prop(gpl, "disable_mask", text="", icon='MOD_MASK')
 
             srow = col.row(align=True)
-            srow.enabled = gpl.blend_mode == 'NORMAL'
             srow.prop(gpl, "opacity", text="Opacity", slider=True)
 
         col = row.column()
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index e28fdb81c31..2e58af04e1c 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -525,7 +525,6 @@ class TOPBAR_PT_gpencil_layers(Panel):
             subrow.prop(gpl, "disable_mask", text="", icon='MOD_MASK')
 
             srow = col.row(align=True)
-            srow.enabled = gpl.blend_mode == 'NORMAL'
             srow.prop(gpl, "opacity", text="Opacity", slider=True)
 
         col = row.column()
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 7c59c7cd396..4b449c53411 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1398,6 +1398,7 @@ static void DRW_gpencil_shgroups_create(
 			array_elm = &cache_ob->shgrp_array[idx];
 			array_elm->mode = idx == 0 ? eGplBlendMode_Normal: gpl->blend_mode;
 			array_elm->disable_mask = gpl->flag & GP_LAYER_USE_MASK;
+			array_elm->blend_opacity = gpl->opacity;
 			array_elm->init_shgrp = shgrp;
 			cache_ob->tot_layers++;
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 61da4dcfa9d..8451002f029 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -504,6 +504,7 @@ void GPENCIL_cache_init(void *vedata)
 		DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendDepth", &e_data.temp_depth_tx_fx);
 		DRW_shgroup_uniform_int(blend_shgrp, "mode", &stl->storage->blend_mode, 1);
 		DRW_shgroup_uniform_int(blend_shgrp, "disable_mask", &stl->storage->disable_mask, 1);
+		DRW_shgroup_uniform_float(blend_shgrp, "blend_opacity", &stl->storage->blend_opacity, 1);
 
 		/* create effects passes */
 		if (!stl->storage->simplify_fx) {
@@ -806,6 +807,7 @@ void GPENCIL_draw_scene(void *ved)
 							GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
 							stl->storage->blend_mode = array_elm->mode;
 							stl->storage->disable_mask = (int)array_elm->disable_mask;
+							stl->storage->blend_opacity = array_elm->blend_opacity;
 							DRW_draw_pass(psl->blend_pass);
 
 							/* Copy B texture to A texture to follow loop */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 70e37365f19..ddbd6dd38e1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -61,6 +61,7 @@ struct RenderLayer;
 typedef struct tGPencilObjectCache_shgrp {
 	int mode;
 	bool disable_mask;
+	float blend_opacity;
 	DRWShadingGroup *init_shgrp;
 	DRWShadingGroup *end_shgrp;
 } tGPencilObjectCache_shgrp;
@@ -138,6 +139,7 @@ typedef struct GPENCIL_Storage {
 
 	int blend_mode;
 	int disable_mask;
+	float blend_opacity;
 
 	/* simplify settings*/
 	bool simplify_fill;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
index 3c8023bc1a9..4ac34f9f8ab 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
@@ -8,6 +8,7 @@ uniform sampler2D blendColor;
 uniform sampler2D blendDepth;
 uniform int mode;
 uniform int disable_mask;
+uniform float blend_opacity;
 
 #define ON 1
 #define OFF 0
@@ -41,33 +42,33 @@ vec4 get_blend_color(int mode, vec4 src_color, vec4 blend_color)
 		outcolor = src_color;
 	}
 	else if (mode == MODE_OVERLAY) {
-		mix_color.rgb = mix_color.rgb * mix_color.a;
+		mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
 		outcolor.r = overlay_color(src_color.r, mix_color.r);
 		outcolor.g = overlay_color(src_color.g, mix_color.g);
 		outcolor.b = overlay_color(src_color.b, mix_color.b);
 		outcolor.a = src_color.a;
 	}
 	else if (mode == MODE_ADD){
-		mix_color.rgb = mix_color.rgb * mix_color.a;
+		mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
 		outcolor = src_color + mix_color;
 		outcolor.a = src_color.a;
 	}
 	else if (mode == MODE_SUB){
 		outcolor = src_color - mix_color;
-		outcolor.a = clamp(src_color.a - mix_color.a, 0.0, 1.0);
+		outcolor.a = clamp(src_color.a - (mix_color.a * blend_opacity), 0.0, 1.0);
 	}
 	else if (mode == MODE_MULTIPLY)	{
-		mix_color.rgb = mix_color.rgb * mix_color.a;
+		mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
 		outcolor = src_color * mix_color;
 		outcolor.a = src_color.a;
 	}
 	else if (mode == MODE_DIVIDE) {
-		mix_color.rgb = mix_color.rgb * mix_color.a;
+		mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
 		outcolor = src_color / mix_color;
 		outcolor.a = src_color.a;
 	}
 	else {
-		outcolor = mix_color;
+		outcolor = mix_color * blend_opacity;;
 		outcolor.a = src_color.a;
 	}



More information about the Bf-blender-cvs mailing list