Commit: 6abd28097d8355381a80054e70fd304518652629
Author: Antonio Vazquez
Date:   Sun Aug 6 17:07:53 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB6abd28097d8355381a80054e70fd304518652629

New VFX Wave modifier

Distorsion using sinusoidal wave

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

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/blenkernel/BKE_gpencil.h
M       source/blender/draw/CMakeLists.txt
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_wave_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_gpencilwave.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 11e1f78b1e0..6d8d5341278 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1789,6 +1789,18 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.label(text="Factor:")
         col.prop(md, "factor", text="")
 
+    def GP_WAVE(self, layout, ob, md):
+        row = layout.row(align=True)
+        row.prop(md, "orientation", expand=True)
+
+        split = layout.split()
+        col = split.column()
+        col.separator()
+        col.label(text="Wave:")
+        col.prop(md, "amplitude")
+        col.prop(md, "period")
+        col.prop(md, "phase")
+
 classes = (
     DATA_PT_modifiers,
 )
diff --git a/source/blender/blenkernel/BKE_gpencil.h 
b/source/blender/blenkernel/BKE_gpencil.h
index 570e64ac1af..09e12fde229 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -55,8 +55,6 @@ struct GpencilDupliModifierData;
 struct GpencilOpacityModifierData;
 struct GpencilLatticeModifierData;
 
-struct GpencilBlurModifierData;
-
 /* ------------ Grease-Pencil API ------------------ */
 
 void BKE_gpencil_free_point_weights(struct bGPDspoint *pt);
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index a8dcffc94ee..92aa801c67d 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -213,6 +213,7 @@ 
data_to_c_simple(engines/gpencil/shaders/gpencil_point_vert.glsl SRC)
 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)
 
 list(APPEND INC
 )
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 9a3106d3743..a6d22ee8446 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -46,6 +46,7 @@ extern char datatoc_gpencil_point_vert_glsl[];
 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[];
 
 /* *********** STATIC *********** */
 static GPENCIL_e_data e_data = {NULL}; /* Engine data */
@@ -128,6 +129,7 @@ static void GPENCIL_engine_free(void)
        DRW_SHADER_FREE_SAFE(e_data.gpencil_point_sh);
        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_TEXTURE_FREE_SAFE(e_data.gpencil_blank_texture);
 }
@@ -172,6 +174,9 @@ static void GPENCIL_cache_init(void *vedata)
        if (!e_data.gpencil_vfx_blur_sh) {
                e_data.gpencil_vfx_blur_sh = 
DRW_shader_create_fullscreen(datatoc_gpencil_gaussian_blur_frag_glsl, NULL);
        }
+       if (!e_data.gpencil_vfx_wave_sh) {
+               e_data.gpencil_vfx_wave_sh = 
DRW_shader_create_fullscreen(datatoc_gpencil_wave_frag_glsl, NULL);
+       }
 
        {
                /* Stroke pass */
@@ -280,6 +285,7 @@ static void GPENCIL_cache_finish(void *vedata)
                        /* VFX pass */
                        cache = &stl->g_data->gp_object_cache[i];
                        DRW_gpencil_vfx_blur(i, &e_data, vedata, ob, cache);
+                       DRW_gpencil_vfx_wave(i, &e_data, vedata, ob, cache);
                }
        }
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index f7afc034246..1d84ce7ceb0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -49,6 +49,13 @@ typedef struct GPencilVFXBlur {
        float y;
 } GPencilVFXBlur;
 
+typedef struct GPencilVFXWave {
+       int orientation;
+       float amplitude;
+       float period;
+       float phase;
+} GPencilVFXWave;
+
  /* used to save gpencil objects */
 typedef struct tGPencilObjectCache {
        struct Object *ob;
@@ -61,6 +68,7 @@ typedef struct tGPencilObjectCache {
   /* *********** LISTS *********** */
 typedef struct GPENCIL_vfx {
        GPencilVFXBlur vfx_blur;
+       GPencilVFXWave vfx_wave;
 } GPENCIL_vfx;
 
 typedef struct GPENCIL_shgroup {
@@ -145,6 +153,7 @@ typedef struct GPENCIL_e_data {
        struct GPUShader *gpencil_drawing_fill_sh;
        struct GPUShader *gpencil_fullscreen_sh;
        struct GPUShader *gpencil_vfx_blur_sh;
+       struct GPUShader *gpencil_vfx_wave_sh;
        /* temp depth texture */
        struct GPUTexture *temp_fbcolor_depth_tx;
        struct GPUTexture *temp_fbcolor_color_tx;
@@ -204,5 +213,6 @@ void gpencil_object_cache_add(struct tGPencilObjectCache 
*cache, struct Object *
 void gpencil_array_modifiers(struct GPENCIL_StorageList *stl, struct Object 
*ob);
 
 void DRW_gpencil_vfx_blur(int ob_idx, struct GPENCIL_e_data *e_data, struct 
GPENCIL_Data *vedata, struct Object *ob, struct tGPencilObjectCache *cache);
+void DRW_gpencil_vfx_wave(int ob_idx, struct GPENCIL_e_data *e_data, struct 
GPENCIL_Data *vedata, struct Object *ob, struct tGPencilObjectCache *cache);
 
 #endif /* __GPENCIL_ENGINE_H__ */
diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.c 
b/source/blender/draw/engines/gpencil/gpencil_vfx.c
index dd05dbe988e..f0bc3c5c2bc 100644
--- a/source/blender/draw/engines/gpencil/gpencil_vfx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_vfx.c
@@ -107,3 +107,40 @@ void DRW_gpencil_vfx_blur(int ob_idx, GPENCIL_e_data 
*e_data, GPENCIL_Data *veda
        /* set last effect sh */
        cache->end_vfx_sh = vfx_shgrp;
 }
+
+/* Wave Distorsion VFX */
+void DRW_gpencil_vfx_wave(int ob_idx, GPENCIL_e_data *e_data, GPENCIL_Data 
*vedata, Object *ob, tGPencilObjectCache *cache)
+{
+       ModifierData *md = modifier_available(ob, eModifierType_GpencilWave);
+       if (md == NULL) {
+               return;
+       }
+
+       GpencilWaveModifierData *mmd = (GpencilWaveModifierData *)md;
+
+       GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
+       GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
+       stl->vfx[ob_idx].vfx_wave.amplitude = mmd->amplitude;
+       stl->vfx[ob_idx].vfx_wave.period = mmd->period;
+       stl->vfx[ob_idx].vfx_wave.phase = mmd->phase;
+       stl->vfx[ob_idx].vfx_wave.orientation = mmd->orientation;
+
+       struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
+
+       DRWShadingGroup *vfx_shgrp = 
DRW_shgroup_create(e_data->gpencil_vfx_wave_sh, psl->vfx_pass);
+       DRW_shgroup_call_add(vfx_shgrp, vfxquad, NULL);
+       DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeColor", 
&e_data->temp_fbcolor_color_tx);
+       DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeDepth", 
&e_data->temp_fbcolor_depth_tx);
+       DRW_shgroup_uniform_float(vfx_shgrp, "amplitude", 
&stl->vfx[ob_idx].vfx_wave.amplitude, 1);
+       DRW_shgroup_uniform_float(vfx_shgrp, "period", 
&stl->vfx[ob_idx].vfx_wave.period, 1);
+       DRW_shgroup_uniform_float(vfx_shgrp, "phase", 
&stl->vfx[ob_idx].vfx_wave.phase, 1);
+       DRW_shgroup_uniform_int(vfx_shgrp, "orientation", 
&stl->vfx[ob_idx].vfx_wave.orientation, 1);
+
+       /* set first effect sh */
+       if (cache->init_vfx_sh == NULL) {
+               cache->init_vfx_sh = vfx_shgrp;
+       }
+
+       /* set last effect sh */
+       cache->end_vfx_sh = vfx_shgrp;
+}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl
new file mode 100644
index 00000000000..96f95f8194d
--- /dev/null
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl
@@ -0,0 +1,33 @@
+
+out vec4 FragColor;
+
+uniform sampler2D strokeColor;
+uniform sampler2D strokeDepth;
+
+uniform float amplitude;
+uniform float period;
+uniform float phase;
+uniform int orientation;
+
+#define HORIZONTAL 0
+#define VERTICAL 1
+
+void main()
+{
+       vec4 outcolor;
+       ivec2 uv = ivec2(gl_FragCoord.xy);
+       float stroke_depth = texelFetch(strokeDepth, uv, 0).r;
+       gl_FragDepth = stroke_depth;
+
+       float value;
+       if (orientation == HORIZONTAL) {
+               value = amplitude * sin((period * uv.x) + phase);
+               outcolor = texelFetch(strokeColor, ivec2(uv.x, uv.y + value), 
0);
+       }
+       else {
+               value = amplitude * sin((period * uv.y) + phase);
+               outcolor = texelFetch(strokeColor, ivec2(uv.x + value, uv.y), 
0);
+       }
+
+       FragColor = outcolor;
+}
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 90e2a5c7907..50b5dc936e8 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -98,6 +98,7 @@ typedef enum ModifierType {
        eModifierType_GpencilLattice    = 62,
        eModifierType_GpencilSimplify   = 63,
        eModifierType_GpencilBlur       = 64,
+       eModifierType_GpencilWave       = 65,
        NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1808,6 +1809,16 @@ typedef struct GpencilBlurModifierData {
        char pad[4];
 } GpencilBlurModifierData;
 
+typedef struct GpencilWaveModifierData {
+       ModifierData modifier;
+       float amplitude;
+       float period;
+       float phase;
+       int orientation;
+       int flag;                    /* flags */
+       char pad[4];
+} GpencilWaveModifierData;
+
 #define MOD_MESHSEQ_READ_ALL \
        (MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | 
MOD_MESHSEQ_READ_COLOR)
 
diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index f5f40546109..5bc586b74fe 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -623,6 +623,7 @@ extern StructRNA RNA_GpencilDupliModifier;
 extern StructRNA RNA_GpencilOpacityModifier;
 extern StructRNA RNA_GpencilLatticeModifier;
 extern StructRNA RNA_GpencilBlurModifier;
+extern StructRNA RNA_GpencilWaveModifier;
 extern StructRNA RNA_TexMapping;
 extern StructRNA RNA_Text;
 extern StructRNA RNA_TextBox;
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index d2639419659..112388e6b9a 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -133,6 +133,7 @@ EnumPropertyItem rna_enum_object_modifier_type_items[] = {
        {eModifierType_GpencilOpacity, "GP_OPACITY", ICON_MOD_MASK, "Opacity", 
"Opacity of the strokes" },
        { 0, "", 0, N_("

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to