summaryrefslogtreecommitdiff
path: root/examples/sparkle
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sparkle')
-rw-r--r--examples/sparkle/shaders/sparkle-effect.frag10
-rw-r--r--examples/sparkle/shaders/sparkle-effect.vert53
-rw-r--r--examples/sparkle/sparkle-effect-example.cpp4
-rw-r--r--examples/sparkle/sparkle-effect.h2
4 files changed, 37 insertions, 32 deletions
diff --git a/examples/sparkle/shaders/sparkle-effect.frag b/examples/sparkle/shaders/sparkle-effect.frag
index 006a7d2b..e2213894 100644
--- a/examples/sparkle/shaders/sparkle-effect.frag
+++ b/examples/sparkle/shaders/sparkle-effect.frag
@@ -1,11 +1,13 @@
+//@version 100
+
precision highp float;
-uniform sampler2D sTexture;
-varying vec2 vTexCoord;
+UNIFORM sampler2D sTexture;
-varying lowp vec4 vColor;
+INPUT vec2 vTexCoord;
+INPUT lowp vec4 vColor;
void main()
{
gl_FragColor = vColor;
- gl_FragColor.a *= texture2D(sTexture, vTexCoord).a;
+ gl_FragColor.a *= TEXTURE(sTexture, vTexCoord).a;
}
diff --git a/examples/sparkle/shaders/sparkle-effect.vert b/examples/sparkle/shaders/sparkle-effect.vert
index 02c33df8..45689ab8 100644
--- a/examples/sparkle/shaders/sparkle-effect.vert
+++ b/examples/sparkle/shaders/sparkle-effect.vert
@@ -1,29 +1,32 @@
+//@version 100
precision highp float;
-attribute vec2 aTexCoord;
-uniform mat4 uMvpMatrix;
-varying vec2 vTexCoord;
+INPUT vec2 aTexCoord;
+INPUT vec2 aParticlePath0;
+INPUT vec2 aParticlePath1;
+INPUT vec2 aParticlePath2;
+INPUT vec2 aParticlePath3;
+INPUT vec2 aParticlePath4;
+INPUT vec2 aParticlePath5;
-attribute vec2 aParticlePath0;
-attribute vec2 aParticlePath1;
-attribute vec2 aParticlePath2;
-attribute vec2 aParticlePath3;
-attribute vec2 aParticlePath4;
-attribute vec2 aParticlePath5;
+OUTPUT lowp vec4 vColor;
+OUTPUT vec2 vTexCoord;
-uniform float uPercentage;
-uniform float uPercentageMarked;
-uniform vec3 uParticleColors[NUM_COLOR];
-uniform float uOpacity[NUM_PARTICLE];
-uniform vec2 uTapIndices;
-uniform float uTapOffset[MAXIMUM_ANIMATION_COUNT];
-uniform vec2 uTapPoint[MAXIMUM_ANIMATION_COUNT];
-uniform float uAcceleration;
-uniform float uRadius;
-uniform float uScale;
-uniform float uBreak;
-
-varying lowp vec4 vColor;
+UNIFORM_BLOCK Custom
+{
+UNIFORM mat4 uMvpMatrix;
+UNIFORM float uPercentage;
+UNIFORM float uPercentageMarked;
+UNIFORM vec3 uParticleColors[NUM_COLOR];
+UNIFORM float uOpacity[NUM_PARTICLE];
+UNIFORM vec2 uTapIndices;
+UNIFORM float uTapOffset[MAXIMUM_ANIMATION_COUNT];
+UNIFORM vec2 uTapPoint[MAXIMUM_ANIMATION_COUNT];
+UNIFORM float uAcceleration;
+UNIFORM float uRadius;
+UNIFORM float uEffectScale;
+UNIFORM float uBreak;
+};
void main()
{
@@ -38,7 +41,7 @@ void main()
return;
}
- // As the movement along the b-curve has nonuniform speed with a uniform increasing parameter 'uPercentage'
+ // As the movement along the b-curve has nonUNIFORM speed with a UNIFORM increasing parameter 'uPercentage'
// we give different particles the different 'percentage' to make them looks more random
float increment = idx / float(NUM_PARTICLE)*5.0;
float percentage = mod(uPercentage +uAcceleration+increment, 1.0);
@@ -75,8 +78,8 @@ void main()
position = mix( position, vec2( 250.0,250.0 ),uBreak*(1.0-uOpacity[int(idx)]) ) ;
// vertex position on the mesh: (sign(aTexCoord.x), sign(aTexCoord.y))*PARTICLE_HALF_SIZE
- gl_Position = uMvpMatrix * vec4( position.x+sign(aTexCoord.x)*PARTICLE_HALF_SIZE/uScale,
- position.y+sign(aTexCoord.y)*PARTICLE_HALF_SIZE/uScale,
+ gl_Position = uMvpMatrix * vec4( position.x+sign(aTexCoord.x)*PARTICLE_HALF_SIZE/uEffectScale,
+ position.y+sign(aTexCoord.y)*PARTICLE_HALF_SIZE/uEffectScale,
0.0, 1.0 );
// we store the color index inside texCoord attribute
diff --git a/examples/sparkle/sparkle-effect-example.cpp b/examples/sparkle/sparkle-effect-example.cpp
index a6c7a83c..3f7d9ebb 100644
--- a/examples/sparkle/sparkle-effect-example.cpp
+++ b/examples/sparkle/sparkle-effect-example.cpp
@@ -356,12 +356,12 @@ private:
// prepare the animation by setting the uniform to the required value
mEffect.SetProperty(mEffect.GetPropertyIndex(BREAK_UNIFORM_NAME), 1.f);
mMeshActor.SetProperty(Actor::Property::SCALE, 0.01f);
- mEffect.SetProperty(mEffect.GetPropertyIndex("uScale"), 0.01f);
+ mEffect.SetProperty(mEffect.GetPropertyIndex("uEffectScale"), 0.01f);
mMeshActor.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.f, 1.f));
Animation breakAnimation = Animation::New(duration * 1.5f);
breakAnimation.AnimateTo(Property(mMeshActor, Actor::Property::SCALE), Vector3(ACTOR_SCALE, ACTOR_SCALE, ACTOR_SCALE), EaseOutSquare);
- breakAnimation.AnimateTo(Property(mEffect, "uScale"), ACTOR_SCALE, EaseOutSquare);
+ breakAnimation.AnimateTo(Property(mEffect, "uEffectScale"), ACTOR_SCALE, EaseOutSquare);
breakAnimation.AnimateTo(Property(mMeshActor, Actor::Property::POSITION), ACTOR_POSITION, EaseOutSquare);
breakAnimation.FinishedSignal().Connect(this, &SparkleEffectExample::OnBreakAnimationFinished);
diff --git a/examples/sparkle/sparkle-effect.h b/examples/sparkle/sparkle-effect.h
index 2f0247ad..2deee478 100644
--- a/examples/sparkle/sparkle-effect.h
+++ b/examples/sparkle/sparkle-effect.h
@@ -244,7 +244,7 @@ Shader New()
handle.RegisterProperty(oss.str(), PARTICLE_COLORS[i].RGB);
}
handle.RegisterProperty("uRadius", 250.f);
- handle.RegisterProperty("uScale", ACTOR_SCALE);
+ handle.RegisterProperty("uEffectScale", ACTOR_SCALE);
// set the initial uniform values