[Bf-blender-cvs] [af74e6c07ae] greasepencil-object: Basic holes running in Viewport and Render

Antonio Vazquez noreply at git.blender.org
Thu Jul 9 17:04:21 CEST 2020


Commit: af74e6c07aefe0b1deb89f09279c79bc015b871a
Author: Antonio Vazquez
Date:   Wed Jul 1 17:19:16 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBaf74e6c07aefe0b1deb89f09279c79bc015b871a

Basic holes running in Viewport and Render

Pending of render layer by layer

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

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_frag.glsl

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 5d22671b057..dded83bacf1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -188,53 +188,6 @@ void GPENCIL_engine_init(void *ved)
   }
 }
 
-static void GPENCIL_mat_masking_start(GPENCIL_Data *vedata)
-{
-  GPENCIL_PrivateData *pd = vedata->stl->pd;
-  GPENCIL_FramebufferList *fbl = vedata->fbl;
-  GPENCIL_TextureList *txl = vedata->txl;
-
-  const float *size = DRW_viewport_size_get();
-  DRW_texture_ensure_2d(&txl->mat_mask_depth_tx, size[0], size[1], GPU_DEPTH24_STENCIL8, 0);
-  DRW_texture_ensure_2d(&txl->mat_mask_color_tx, size[0], size[1], GPU_R11F_G11F_B10F, 0);
-  DRW_texture_ensure_2d(&txl->mat_mask_reveal_tx, size[0], size[1], GPU_R11F_G11F_B10F, 0);
-
-  GPU_framebuffer_ensure_config(&fbl->mat_mask_fb,
-                                {
-                                    GPU_ATTACHMENT_TEXTURE(txl->mat_mask_depth_tx),
-                                    GPU_ATTACHMENT_TEXTURE(txl->mat_mask_color_tx),
-                                    GPU_ATTACHMENT_TEXTURE(txl->mat_mask_reveal_tx),
-                                });
-
-  pd->mat_mask_depth_tx = txl->mat_mask_depth_tx;
-  pd->mat_mask_color_tx = txl->mat_mask_color_tx;
-  pd->mat_mask_reveal_tx = txl->mat_mask_reveal_tx;
-}
-
-static void GPENCIL_mat_masking_copy(GPENCIL_Data *vedata)
-{
-  GPENCIL_FramebufferList *fbl = vedata->fbl;
-  DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
-
-  /* Copy actual image. */
-  if (dfbl->default_fb != NULL) {
-    GPU_framebuffer_blit(dfbl->default_fb, 0, fbl->mat_mask_fb, 0, GPU_DEPTH_BIT);
-    GPU_framebuffer_blit(fbl->gpencil_fb, 0, fbl->mat_mask_fb, 0, GPU_COLOR_BIT);
-    GPU_framebuffer_blit(fbl->gpencil_fb, 1, fbl->mat_mask_fb, 1, GPU_COLOR_BIT);
-  }
-}
-
-static void GPENCIL_mat_masking_end(GPENCIL_Data *vedata)
-{
-  GPENCIL_FramebufferList *fbl = vedata->fbl;
-  GPENCIL_TextureList *txl = vedata->txl;
-
-  GPU_FRAMEBUFFER_FREE_SAFE(fbl->mat_mask_fb);
-  DRW_TEXTURE_FREE_SAFE(txl->mat_mask_depth_tx);
-  DRW_TEXTURE_FREE_SAFE(txl->mat_mask_color_tx);
-  DRW_TEXTURE_FREE_SAFE(txl->mat_mask_reveal_tx);
-}
-
 void GPENCIL_cache_init(void *ved)
 {
   GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
@@ -381,11 +334,6 @@ void GPENCIL_cache_init(void *ved)
     /* Disable DoF blur scalling. */
     pd->camera = NULL;
   }
-
-  /* Material masking framebuffer. */
-  if (txl->mat_mask_color_tx == NULL) {
-    GPENCIL_mat_masking_start(vedata);
-  }
 }
 
 #define DRAW_NOW 2
@@ -527,9 +475,6 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl,
   DRW_shgroup_uniform_texture(grp, "gpFillTexture", iter->tex_fill);
   DRW_shgroup_uniform_texture(grp, "gpStrokeTexture", iter->tex_stroke);
   DRW_shgroup_uniform_int_copy(grp, "gpMaterialOffset", iter->mat_ofs);
-  DRW_shgroup_uniform_texture(grp, "matMaskDepthTexture", pd->mat_mask_depth_tx);
-  DRW_shgroup_uniform_texture(grp, "matMaskColorTexture", pd->mat_mask_color_tx);
-  DRW_shgroup_uniform_texture(grp, "matMaskRevealTexture", pd->mat_mask_reveal_tx);
   DRW_shgroup_uniform_float_copy(grp, "strokeIndexOffset", iter->stroke_index_offset);
 }
 
@@ -580,9 +525,6 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
       DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", tex_stroke);
       iter->tex_stroke = tex_stroke;
     }
-    DRW_shgroup_uniform_texture(iter->grp, "matMaskDepthTexture", iter->pd->mat_mask_depth_tx);
-    DRW_shgroup_uniform_texture(iter->grp, "matMaskColorTexture", iter->pd->mat_mask_color_tx);
-    DRW_shgroup_uniform_texture(iter->grp, "matMaskRevealTexture", iter->pd->mat_mask_reveal_tx);
 
     /* TODO(fclem): This is a quick workaround but
      * ideally we should have this as a permanent bind. */
@@ -999,14 +941,9 @@ void GPENCIL_draw_scene(void *ved)
   }
 
   LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->tobjects) {
-    if (ob->do_mat_masking) {
-      GPENCIL_mat_masking_copy(vedata);
-    }
     GPENCIL_draw_object(vedata, ob);
   }
 
-  GPENCIL_mat_masking_end(vedata);
-
   if (pd->do_fast_drawing) {
     GPENCIL_fast_draw_end(vedata);
   }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 2c9399a53e4..28b6f437b79 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -239,11 +239,6 @@ typedef struct GPENCIL_TextureList {
   /* Textures used during render. Containing underlying rendered scene. */
   struct GPUTexture *render_depth_tx;
   struct GPUTexture *render_color_tx;
-  /* Mask textures for supporting material masking. */
-  struct GPUTexture *mat_mask_depth_tx;
-  struct GPUTexture *mat_mask_color_tx;
-  struct GPUTexture *mat_mask_reveal_tx;
-
 } GPENCIL_TextureList;
 
 typedef struct GPENCIL_Data {
@@ -294,10 +289,6 @@ typedef struct GPENCIL_PrivateData {
   GPUFrameBuffer *scene_fb;
   /* Copy of txl->dummy_tx */
   GPUTexture *dummy_tx;
-  /* Pointer to material masking textures. */
-  GPUTexture *mat_mask_depth_tx;
-  GPUTexture *mat_mask_color_tx;
-  GPUTexture *mat_mask_reveal_tx;
   /* Copy of v3d->shading.single_color. */
   float v3d_single_color[3];
   /* Copy of v3d->shading.color_type or -1 to ignore. */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
index d10eda3b0f6..e20a0038b60 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
@@ -3,10 +3,6 @@ uniform sampler2D gpFillTexture;
 uniform sampler2D gpStrokeTexture;
 uniform sampler2D gpSceneDepthTexture;
 uniform sampler2D gpMaskTexture;
-/* Textures for handling material masking for holes. */
-uniform sampler2D matMaskDepthTexture;
-uniform sampler2D matMaskColorTexture;
-uniform sampler2D matMaskRevealTexture;
 uniform vec3 gpNormal;
 
 layout(location = 0) out vec4 fragColor;
@@ -93,12 +89,10 @@ void main()
   fragColor *= stroke_round_cap_mask(
       strokePt1, strokePt2, strokeAspect, strokeThickness, strokeHardeness);
 
-  /* If material masking, retry previous texture data. */
+  /* If material masking. */
   if (GP_FLAG_TEST(matFlag, GP_STROKE_MASK)) {
-    vec2 uv = vec2(gl_FragCoord.x / sizeViewport.x, gl_FragCoord.y / sizeViewport.y);
-    fragColor = texture(matMaskColorTexture, uv);
-    revealColor = texture(matMaskRevealTexture, uv);
-    gl_FragDepth = texture(matMaskDepthTexture, uv).r;
+    fragColor = vec4(0.0, 0.0, 0.0, 1.0);
+    revealColor = vec4(1.0, 1.0, 1.0, 0.0);
   }
   else {
     /* For compatibility with colored alpha buffer.



More information about the Bf-blender-cvs mailing list