Commit: 48f985d080f46477afc6c606c9ac47f586cc1a7b
Author: Antonio Vazquez
Date:   Thu Aug 17 17:37:18 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB48f985d080f46477afc6c606c9ac47f586cc1a7b

New VFX pixelate modifier

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

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/draw/CMakeLists.txt
M       source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.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/gpencil_vfx.c
A       source/blender/draw/engines/gpencil/shaders/gpencil_pixel_frag.glsl
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesrna/RNA_access.h
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/modifiers/CMakeLists.txt
M       source/blender/modifiers/MOD_modifiertypes.h
A       source/blender/modifiers/intern/MOD_gpencilpixel.c
M       source/blender/modifiers/intern/MOD_util.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 6d8d5341278..c92f669a30b 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1801,6 +1801,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "period")
         col.prop(md, "phase")
 
+    def GP_PIXEL(self, layout, ob, md):
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Size:")
+        col.prop(md, "size", text="")
+
+        col.separator()
+        col.prop(md, "use_lines")
+
+        row = col.row()
+        col = row.column()
+        col.enabled = md.use_lines
+        col.prop(md, "color")
+
+
 classes = (
     DATA_PT_modifiers,
 )
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 7e74cec5e3f..bfb8450daea 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -216,6 +216,7 @@ 
data_to_c_simple(engines/gpencil/shaders/gpencil_point_geom.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_point_frag.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_gaussian_blur_frag.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_wave_frag.glsl SRC)
+data_to_c_simple(engines/gpencil/shaders/gpencil_pixel_frag.glsl SRC)
 
 list(APPEND INC
 )
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index fa41ded5e9d..644f8cd6b75 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -91,6 +91,9 @@ void gpencil_object_cache_add(tGPencilObjectCache *cache, 
Object *ob, int *gp_ca
        cache[*gp_cache_used].init_vfx_blur_sh_4 = NULL;
        cache[*gp_cache_used].end_vfx_blur_sh_4 = NULL;
 
+       cache[*gp_cache_used].init_vfx_pixel_sh = NULL;
+       cache[*gp_cache_used].end_vfx_pixel_sh = NULL;
+
        /* calculate zdepth from point of view */
        float zdepth = 0.0;
        if (rv3d->is_persp) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 3190a4bbed6..3344df5e699 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -47,6 +47,7 @@ extern char datatoc_gpencil_point_geom_glsl[];
 extern char datatoc_gpencil_point_frag_glsl[];
 extern char datatoc_gpencil_gaussian_blur_frag_glsl[];
 extern char datatoc_gpencil_wave_frag_glsl[];
+extern char datatoc_gpencil_pixel_frag_glsl[];
 
 /* *********** STATIC *********** */
 static GPENCIL_e_data e_data = {NULL}; /* Engine data */
@@ -147,6 +148,7 @@ static void GPENCIL_engine_free(void)
        DRW_SHADER_FREE_SAFE(e_data.gpencil_fullscreen_sh);
        DRW_SHADER_FREE_SAFE(e_data.gpencil_vfx_blur_sh);
        DRW_SHADER_FREE_SAFE(e_data.gpencil_vfx_wave_sh);
+       DRW_SHADER_FREE_SAFE(e_data.gpencil_vfx_pixel_sh);
 
        DRW_TEXTURE_FREE_SAFE(e_data.gpencil_blank_texture);
 }
@@ -196,6 +198,9 @@ static void GPENCIL_cache_init(void *vedata)
        if (!e_data.gpencil_vfx_wave_sh) {
                e_data.gpencil_vfx_wave_sh = 
DRW_shader_create_fullscreen(datatoc_gpencil_wave_frag_glsl, NULL);
        }
+       if (!e_data.gpencil_vfx_pixel_sh) {
+               e_data.gpencil_vfx_pixel_sh = 
DRW_shader_create_fullscreen(datatoc_gpencil_pixel_frag_glsl, NULL);
+       }
 
        {
                /* Stroke pass */
@@ -255,6 +260,14 @@ 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);
 
+               /* 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_BLEND | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS);
+               DRWShadingGroup *vfx_copy_shgrp = 
DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->vfx_copy_pass);
+               DRW_shgroup_call_add(vfx_copy_shgrp, vfxquad, NULL);
+               DRW_shgroup_uniform_buffer(vfx_copy_shgrp, "strokeColor", 
&e_data.vfx_fbcolor_color_tx_b);
+               DRW_shgroup_uniform_buffer(vfx_copy_shgrp, "strokeDepth", 
&e_data.vfx_fbcolor_depth_tx_b);
+
                /* VFX pass */
                psl->vfx_wave_pass = DRW_pass_create("GPencil VFX Wave Pass", 
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS);
 
@@ -262,6 +275,8 @@ static void GPENCIL_cache_init(void *vedata)
                psl->vfx_blur_pass_2 = DRW_pass_create("GPencil VFX Blur Pass 
2", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS);
                psl->vfx_blur_pass_3 = DRW_pass_create("GPencil VFX Blur Pass 
3", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS);
                psl->vfx_blur_pass_4 = DRW_pass_create("GPencil VFX Blur Pass 
4", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS);
+
+               psl->vfx_pixel_pass = DRW_pass_create("GPencil VFX Pixel Pass", 
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS);
        }
 }
 
@@ -386,7 +401,7 @@ static void GPENCIL_draw_scene(void *vedata)
                        }
 
                        /* vfx pass */
-                       if ((cache->init_vfx_wave_sh) && 
(cache->init_vfx_wave_sh)) {
+                       if ((cache->init_vfx_wave_sh) && 
(cache->end_vfx_wave_sh)) {
                                DRW_framebuffer_bind(fbl->vfx_color_fb_a);
                                DRW_framebuffer_clear(true, true, false, 
clearcol, 1.0f);
 
@@ -418,6 +433,19 @@ static void GPENCIL_draw_scene(void *vedata)
                                                cache->init_vfx_blur_sh_4,
                                                cache->end_vfx_blur_sh_4);
                                }
+                               /* pixel pass */
+                               if ((cache->init_vfx_pixel_sh) && 
(cache->end_vfx_pixel_sh)) {
+                                       
DRW_framebuffer_bind(fbl->vfx_color_fb_b);
+                                       DRW_framebuffer_clear(true, true, 
false, clearcol, 1.0f);
+                                       /* pixel pass */
+                                       
DRW_draw_pass_subset(psl->vfx_pixel_pass,
+                                               cache->init_vfx_pixel_sh,
+                                               cache->end_vfx_pixel_sh);
+                                       /* copy pass from b to a */
+                                       
DRW_framebuffer_bind(fbl->vfx_color_fb_a);
+                                       DRW_framebuffer_clear(true, true, 
false, clearcol, 1.0f);
+                                       DRW_draw_pass(psl->vfx_copy_pass);
+                               }
                                /* Combine with scene buffer */
                                DRW_framebuffer_bind(dfbl->default_fb);
                                /* Mix VFX Pass */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 05bbfadd015..7c653bb72e0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -44,6 +44,12 @@ struct GPENCIL_StorageList;
 #define GPENCIL_COLOR_PATTERN 2
 
  /* *********** OBJECTS CACHE *********** */
+typedef struct GPencilVFXPixel {
+       float size[2];
+       float rgba[4];
+       int lines;
+} GPencilVFXPixel;
+
 typedef struct GPencilVFXBlur {
        float x;
        float y;
@@ -63,6 +69,7 @@ typedef struct tGPencilObjectCache {
        int init_grp, end_grp;
        DRWShadingGroup *init_vfx_wave_sh;
        DRWShadingGroup *end_vfx_wave_sh;
+
        DRWShadingGroup *init_vfx_blur_sh_1;
        DRWShadingGroup *end_vfx_blur_sh_1;
        DRWShadingGroup *init_vfx_blur_sh_2;
@@ -71,6 +78,9 @@ typedef struct tGPencilObjectCache {
        DRWShadingGroup *end_vfx_blur_sh_3;
        DRWShadingGroup *init_vfx_blur_sh_4;
        DRWShadingGroup *end_vfx_blur_sh_4;
+
+       DRWShadingGroup *init_vfx_pixel_sh;
+       DRWShadingGroup *end_vfx_pixel_sh;
        float zdepth;
 } tGPencilObjectCache;
 
@@ -78,6 +88,7 @@ typedef struct tGPencilObjectCache {
 typedef struct GPENCIL_vfx {
        GPencilVFXBlur vfx_blur;
        GPencilVFXWave vfx_wave;
+       GPencilVFXPixel vfx_pixel;
 } GPENCIL_vfx;
 
 typedef struct GPENCIL_shgroup {
@@ -118,11 +129,13 @@ typedef struct GPENCIL_PassList {
        struct DRWPass *drawing_pass;
        struct DRWPass *mix_pass;
        struct DRWPass *mix_vfx_pass;
+       struct DRWPass *vfx_copy_pass;
        struct DRWPass *vfx_wave_pass;
        struct DRWPass *vfx_blur_pass_1;
        struct DRWPass *vfx_blur_pass_2;
        struct DRWPass *vfx_blur_pass_3;
        struct DRWPass *vfx_blur_pass_4;
+       struct DRWPass *vfx_pixel_pass;
 } GPENCIL_PassList;
 
 typedef struct GPENCIL_FramebufferList {
@@ -170,6 +183,7 @@ typedef struct GPENCIL_e_data {
        struct GPUShader *gpencil_fullscreen_sh;
        struct GPUShader *gpencil_vfx_blur_sh;
        struct GPUShader *gpencil_vfx_wave_sh;
+       struct GPUShader *gpencil_vfx_pixel_sh;
        /* temp depth texture */
        struct GPUTexture *temp_fbcolor_depth_tx;
        struct GPUTexture *temp_fbcolor_color_tx;
diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.c 
b/source/blender/draw/engines/gpencil/gpencil_vfx.c
index 74e5fb5c632..f0a5dab1186 100644
--- a/source/blender/draw/engines/gpencil/gpencil_vfx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_vfx.c
@@ -227,6 +227,40 @@ static void DRW_gpencil_vfx_blur(ModifierData *md, int 
ob_idx, GPENCIL_e_data *e
        cache->end_vfx_blur_sh_4 = vfx_shgrp;
 }
 
+/* Pixelate VFX */
+static void DRW_gpencil_vfx_pixel(ModifierData *md, int ob_idx, GPENCIL_e_data 
*e_data, GPENCIL_Data *vedata, Object *ob, tGPencilObjectCache *cache)
+{
+       if (md == NULL) {
+               return;
+       }
+
+       GpencilPixelModifierData *mmd = (GpencilPixelModifierData *)md;
+
+       GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
+       GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
+       DRWShadingGroup *vfx_shgrp;
+       stl->vfx[ob_idx].vfx_pixel.size[0] = mmd->size[0];
+       stl->vfx[ob_idx].vfx_pixel.size[1] = mmd->size[1];
+       copy_v4_v4(stl->vfx[ob_idx].vfx_pixel.rgba, mmd->rgba);
+       stl->vfx[ob_idx].vfx_pixel.lines = (int)mmd->flag & GP_PIXEL_USE_LINES;
+
+       struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
+       vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_pixel_sh, 
psl->vfx_pixel_pass);
+       DRW_shgroup_call_add(vfx_shgrp, vfxquad, NULL);
+       DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeColor", 
&e_data->vfx_fbcolor_color_tx_a);
+       DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeDepth", 
&e_data->vfx_fbcolor_depth_tx_a);
+       DRW_shgroup_uniform_vec2(vfx_shgrp, "size", 
&stl->vfx[ob_idx].vfx_pixel.size[0], 1);
+       DRW_shgroup_uniform_vec4(vfx_shgrp, "color", 
&stl->vfx[ob_idx].vfx_pixel.rgba[0], 1);
+       DRW_shgroup_uniform_int(vfx_shgrp, "uselines", 
&stl->vfx[ob_idx].vfx_pixel.lines, 1);
+
+       /* set first effect sh */
+       if (c

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to