[Bf-blender-cvs] [461008a3e8b] soc-2019-npr: Image and viewport now both support GPencil stroke overlay

YimingWu noreply at git.blender.org
Mon Jun 3 10:31:49 CEST 2019


Commit: 461008a3e8b00f0a48d0cd1704906575a42f0f9a
Author: YimingWu
Date:   Mon Jun 3 14:20:52 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB461008a3e8b00f0a48d0cd1704906575a42f0f9a

Image and viewport now both support GPencil stroke overlay

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

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

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index a97a4a27833..6d48f40ee61 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -1035,13 +1035,20 @@ void GPENCIL_draw_scene(void *ved)
           stl->storage->do_select_outline = 0;
         }
 
+        stl->storage->no_depth_composition = gpd->no_depth;
+
         /* draw mix pass */
         if(gpd->no_depth){
-              DRW_pass_state_remove(psl->mix_pass,        DRW_STATE_WRITE_DEPTH|DRW_STATE_DEPTH_LESS);
-              //DRW_pass_state_remove(psl->mix_pass_noblend,DRW_STATE_WRITE_DEPTH|DRW_STATE_DEPTH_LESS);
-            }
+            DRW_pass_state_remove(psl->mix_pass,DRW_STATE_WRITE_DEPTH|DRW_STATE_DEPTH_LESS);
+          }
+
         DRW_draw_pass(psl->mix_pass);
 
+        /* restore */
+        if(gpd->no_depth){
+          DRW_pass_state_add(psl->mix_pass,DRW_STATE_WRITE_DEPTH|DRW_STATE_DEPTH_LESS);
+        }
+
         /* disable select flag */
         stl->storage->do_select_outline = 0;
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index a7e4c9d58d6..14a94e50323 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -172,6 +172,8 @@ typedef struct GPENCIL_Storage {
 
   short framebuffer_flag; /* flag what framebuffer need to create */
 
+  int no_depth_composition;
+
   int blend_mode;
   int clamp_layer;
   float blend_opacity;
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c
index 301c29af335..41c9ef0a177 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -345,8 +345,8 @@ void GPENCIL_render_to_image(void *vedata,
       /* check grease pencil render transparency */
       if (gp_pixel_rgba[3] > 0.0f) {
         if (src_pixel_rgba[3] > 0.0f) {
-          /* check z-depth */
-          if (gp_pixel_depth[0] > src_pixel_depth[0]) {
+          /* if depth enabled, then check z-depth */
+          if (!stl->storage->no_depth_composition && gp_pixel_depth[0] > src_pixel_depth[0]) {
             /* copy source z-depth */
             gp_pixel_depth[0] = src_pixel_depth[0];
             /* blend object on top */



More information about the Bf-blender-cvs mailing list