[Bf-blender-cvs] [72cc5c291f2] greasepencil-object: Use multisample for nomal blend

Antonioya noreply at git.blender.org
Sun Nov 25 16:12:22 CET 2018


Commit: 72cc5c291f2965f75b1c4af3c9a6a96f74894336
Author: Antonioya
Date:   Sun Nov 25 16:02:40 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB72cc5c291f2965f75b1c4af3c9a6a96f74894336

Use multisample for nomal blend

The layers are multisampled before blend

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

M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 08d32d33e25..61da4dcfa9d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -672,6 +672,7 @@ static void gpencil_free_obj_runtime(GPENCIL_StorageList *stl)
 static void gpencil_draw_pass_range(
 	GPENCIL_FramebufferList *fbl, GPENCIL_StorageList *stl,
 	GPENCIL_PassList *psl, GPENCIL_TextureList *txl,
+	GPUFrameBuffer *fb,
 	DRWShadingGroup *init_shgrp, DRWShadingGroup *end_shgrp)
 {
 	if (init_shgrp == NULL) {
@@ -687,7 +688,7 @@ static void gpencil_draw_pass_range(
 		psl->stroke_pass, init_shgrp, end_shgrp);
 
 	if (!stl->storage->is_mat_preview) {
-		MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fbl->temp_fb_a, txl);
+		MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fb, txl);
 	}
 
 }
@@ -786,7 +787,9 @@ void GPENCIL_draw_scene(void *ved)
 						else {
 							use_blend = true;
 							/* draw pending groups */
-							gpencil_draw_pass_range(fbl, stl, psl, txl, init_shgrp, end_shgrp);
+							gpencil_draw_pass_range(
+								fbl, stl, psl, txl, fbl->temp_fb_a,
+								init_shgrp, end_shgrp);
 
 							/* draw current group in separated texture */
 							init_shgrp = array_elm->init_shgrp;
@@ -794,7 +797,9 @@ void GPENCIL_draw_scene(void *ved)
 
 							GPU_framebuffer_bind(fbl->temp_fb_fx);
 							GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
-							DRW_draw_pass_subset(psl->stroke_pass, init_shgrp, end_shgrp);
+							gpencil_draw_pass_range(
+								fbl, stl, psl, txl, fbl->temp_fb_fx,
+								init_shgrp, end_shgrp);
 
 							/* Blend A texture and FX texture */
 							GPU_framebuffer_bind(fbl->temp_fb_b);
@@ -817,7 +822,7 @@ void GPENCIL_draw_scene(void *ved)
 
 					}
 					/* last group */
-					gpencil_draw_pass_range(fbl, stl, psl, txl, init_shgrp, end_shgrp);
+					gpencil_draw_pass_range(fbl, stl, psl, txl, fbl->temp_fb_a, init_shgrp, end_shgrp);
 				}
 
 				/* Current buffer drawing */
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 7d1ac993e18..3c8023bc1a9 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
@@ -9,7 +9,6 @@ uniform sampler2D blendDepth;
 uniform int mode;
 uniform int disable_mask;
 
-#define THRESHOLD 0.001f
 #define ON 1
 #define OFF 0
 
@@ -75,33 +74,6 @@ vec4 get_blend_color(int mode, vec4 src_color, vec4 blend_color)
 	return outcolor;
 }
 
-vec4 get_blurcolor(ivec2 uv, int limit)
-{
-	int pixels = ((limit * 2) + 1) * ((limit * 2) + 1);
-	vec4 blend_color = vec4(0, 0, 0, 0);
-	vec4 color;
-	int hit = 0;
-	for (int x = -limit; x < limit + 1; x++) {
-		for (int y = -limit; y < limit + 1; y++) {
-			color = texelFetch(blendColor, uv + ivec2(x, y), 0).rgba;
-			if (color.a > THRESHOLD) {
-				hit++;
-			}
-			blend_color += color;
-		}
-		
-	}
-	/* color is the result of the visible pixel */
-	if (hit > 0) {
-		blend_color.rgb = blend_color.rgb / hit;
-	}
-	/* alpha is divided by numberof pixels */
-	blend_color.a = blend_color.a / pixels;
-	
-
-	return blend_color;
-}
-
 void main()
 {
 	vec4 outcolor;
@@ -125,18 +97,20 @@ void main()
 	
 	/* Normal mode */
 	if (mode == MODE_NORMAL) {
-		if (mix_color.a > THRESHOLD) {
-			outcolor =  mix_color;
-			gl_FragDepth = mix_depth;
+		if (stroke_color.a > 0) {
+			if (mix_color.a > 0) {
+				FragColor = mix(stroke_color, mix_color, mix_color.a);
+				gl_FragDepth = mix_depth;
+			}
+			else {
+				FragColor = stroke_color;
+				gl_FragDepth = stroke_depth;
+			}
 		}
 		else {
-			/* blur edges with box blur */
-			vec4 blur = get_blurcolor(uv, 1);
-			/* interpolate color using the alpha factor */
-			outcolor = vec4(mix(stroke_color.rgb, blur.rgb, blur.a), stroke_color.a); 
-			gl_FragDepth = stroke_depth;
+			FragColor = mix_color;
+			gl_FragDepth = mix_depth;
 		}
-		FragColor = outcolor;
 		return;
 	}



More information about the Bf-blender-cvs mailing list