[Bf-blender-cvs] [be12ccff4a2] greasepencil-object: VFX Wave modifier uses PI range
Antonio Vazquez
noreply at git.blender.org
Tue Aug 8 11:19:17 CEST 2017
Commit: be12ccff4a227934b20841a16fab7cd51c3b2551
Author: Antonio Vazquez
Date: Mon Aug 7 11:04:41 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBbe12ccff4a227934b20841a16fab7cd51c3b2551
VFX Wave modifier uses PI range
The sinusoidal curve uses a loop between 0 and PI to get better and smooth result
===================================================================
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/gpencil_vfx.c
M source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl
M source/blender/modifiers/intern/MOD_gpencilwave.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index c22b32b447a..99de3296045 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -54,6 +54,7 @@ typedef struct GPencilVFXWave {
float amplitude;
float period;
float phase;
+ float wsize[2];
} GPencilVFXWave;
/* used to save gpencil objects */
diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.c b/source/blender/draw/engines/gpencil/gpencil_vfx.c
index b974c5afb2d..276aad85ae4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_vfx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_vfx.c
@@ -94,6 +94,9 @@ static void DRW_gpencil_vfx_wave(ModifierData *md, int ob_idx, GPENCIL_e_data *e
stl->vfx[ob_idx].vfx_wave.phase = mmd->phase;
stl->vfx[ob_idx].vfx_wave.orientation = mmd->orientation;
+ const float *viewport_size = DRW_viewport_size_get();
+ copy_v2_v2(stl->vfx[ob_idx].vfx_wave.wsize, viewport_size);
+
struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_wave_sh, psl->vfx_pass);
@@ -105,6 +108,7 @@ static void DRW_gpencil_vfx_wave(ModifierData *md, int ob_idx, GPENCIL_e_data *e
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);
+ DRW_shgroup_uniform_vec2(vfx_shgrp, "wsize", &stl->vfx[ob_idx].vfx_wave.wsize, 1);
/* set first effect sh */
if (cache->init_vfx_sh == NULL) {
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl
index 96f95f8194d..635bb027ca2 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_wave_frag.glsl
@@ -8,6 +8,9 @@ uniform float amplitude;
uniform float period;
uniform float phase;
uniform int orientation;
+uniform vec2 wsize;
+
+#define M_PI 3.1415926535897932384626433832795
#define HORIZONTAL 0
#define VERTICAL 1
@@ -21,11 +24,13 @@ void main()
float value;
if (orientation == HORIZONTAL) {
- value = amplitude * sin((period * uv.x) + phase);
+ float pval = (uv.x * M_PI) / wsize[0];
+ value = amplitude * sin((period * pval) + phase);
outcolor = texelFetch(strokeColor, ivec2(uv.x, uv.y + value), 0);
}
else {
- value = amplitude * sin((period * uv.y) + phase);
+ float pval = (uv.y * M_PI) / wsize[1];
+ value = amplitude * sin((period * pval) + phase);
outcolor = texelFetch(strokeColor, ivec2(uv.x + value, uv.y), 0);
}
diff --git a/source/blender/modifiers/intern/MOD_gpencilwave.c b/source/blender/modifiers/intern/MOD_gpencilwave.c
index 5e712e321bb..902de6c68b2 100644
--- a/source/blender/modifiers/intern/MOD_gpencilwave.c
+++ b/source/blender/modifiers/intern/MOD_gpencilwave.c
@@ -43,9 +43,9 @@
static void initData(ModifierData *md)
{
GpencilWaveModifierData *gpmd = (GpencilWaveModifierData *)md;
- gpmd->amplitude = 6.0f;
- gpmd->period = 0.2f;
- gpmd->phase = 11.0f;
+ gpmd->amplitude = 10.0f;
+ gpmd->period = 20.0f;
+ gpmd->phase = 0.0f;
gpmd->orientation = 1;
BKE_gpencil_batch_cache_alldirty();
More information about the Bf-blender-cvs
mailing list