[Bf-blender-cvs] [54c7ac2c7a3] greasepencil-object: Fix opacity problem with fast drawing.

Antonio Vazquez noreply at git.blender.org
Thu Sep 14 16:54:59 CEST 2017


Commit: 54c7ac2c7a3fa8423f0dbd3fb9defc9cfb207f71
Author: Antonio Vazquez
Date:   Thu Sep 14 16:54:47 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB54c7ac2c7a3fa8423f0dbd3fb9defc9cfb207f71

Fix opacity problem with fast drawing.

The pass was doing double blending.

Thanks to Clement Foucault for his help solving this issue.

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

M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index bfb6167f6c2..352e0e31c28 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -320,6 +320,22 @@ static void GPENCIL_cache_init(void *vedata)
 		DRW_shgroup_uniform_buffer(mix_vfx_shgrp, "strokeColor", &e_data.vfx_fbcolor_color_tx_a);
 		DRW_shgroup_uniform_buffer(mix_vfx_shgrp, "strokeDepth", &e_data.vfx_fbcolor_depth_tx_a);
 
+		/* mix pass no blend */
+		struct Gwn_Batch *quad_noblend = DRW_cache_fullscreen_quad_get();
+		psl->mix_pass_noblend = DRW_pass_create("GPencil Mix Pass no blend", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+		DRWShadingGroup *mix_shgrp_noblend = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_pass_noblend);
+		DRW_shgroup_call_add(mix_shgrp_noblend, quad_noblend, NULL);
+		DRW_shgroup_uniform_buffer(mix_shgrp_noblend, "strokeColor", &e_data.temp_fbcolor_color_tx);
+		DRW_shgroup_uniform_buffer(mix_shgrp_noblend, "strokeDepth", &e_data.temp_fbcolor_depth_tx);
+
+		/* mix vfx pass no blend */
+		struct Gwn_Batch *vfxquad_noblend = DRW_cache_fullscreen_quad_get();
+		psl->mix_vfx_pass_noblend = DRW_pass_create("GPencil Mix VFX Pass no blend", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+		DRWShadingGroup *mix_vfx_shgrp_noblend = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_vfx_pass_noblend);
+		DRW_shgroup_call_add(mix_vfx_shgrp_noblend, vfxquad_noblend, NULL);
+		DRW_shgroup_uniform_buffer(mix_vfx_shgrp_noblend, "strokeColor", &e_data.vfx_fbcolor_color_tx_a);
+		DRW_shgroup_uniform_buffer(mix_vfx_shgrp_noblend, "strokeDepth", &e_data.vfx_fbcolor_depth_tx_a);
+
 		/* vfx copy pass from txtb to txta */
 		vfxquad = DRW_cache_fullscreen_quad_get();
 		psl->vfx_copy_pass = DRW_pass_create("GPencil VFX Copy b to a Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
@@ -624,7 +640,7 @@ static void GPENCIL_draw_scene(void *vedata)
 					/* Mix VFX Pass */
 					DRW_draw_pass(psl->mix_vfx_pass);
 					/* prepare for fast drawing */	
-					gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_vfx_pass, clearcol);
+					gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_vfx_pass_noblend, clearcol);
 				}
 				else {
 					/* Combine with scene buffer without more passes */
@@ -632,7 +648,7 @@ static void GPENCIL_draw_scene(void *vedata)
 					/* Mix Pass: DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS */
 					DRW_draw_pass(psl->mix_pass);
 					/* prepare for fast drawing */
-					gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_pass, clearcol);
+					gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_pass_noblend, clearcol);
 				}
 			}
 			/* edit points */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 56fa0680983..d02a26c60cc 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -147,6 +147,8 @@ typedef struct GPENCIL_PassList {
 	struct DRWPass *drawing_pass;
 	struct DRWPass *mix_pass;
 	struct DRWPass *mix_vfx_pass;
+	struct DRWPass *mix_pass_noblend;
+	struct DRWPass *mix_vfx_pass_noblend;
 	struct DRWPass *vfx_copy_pass;
 	struct DRWPass *vfx_wave_pass;
 	struct DRWPass *vfx_blur_pass_1;



More information about the Bf-blender-cvs mailing list