aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/particles/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/particles/resources')
-rw-r--r--src/imports/particles/resources/ctfragment.shader11
-rw-r--r--src/imports/particles/resources/ctvertex.shader38
-rw-r--r--src/imports/particles/resources/defaultFadeInOut.pngbin0 -> 286 bytes
-rw-r--r--src/imports/particles/resources/deformablefragment.shader8
-rw-r--r--src/imports/particles/resources/deformablevertex.shader57
-rw-r--r--src/imports/particles/resources/identitytable.pngbin0 -> 90 bytes
-rw-r--r--src/imports/particles/resources/simplefragment.shader8
-rw-r--r--src/imports/particles/resources/simplevertex.shader36
-rw-r--r--src/imports/particles/resources/spritefragment.shader10
-rw-r--r--src/imports/particles/resources/spriteimagefragment.shader9
-rw-r--r--src/imports/particles/resources/spriteimagevertex.shader52
-rw-r--r--src/imports/particles/resources/spritevertex.shader77
-rw-r--r--src/imports/particles/resources/superfragment.shader11
-rw-r--r--src/imports/particles/resources/supervertex.shader57
-rw-r--r--src/imports/particles/resources/trailsfragment.shader8
-rw-r--r--src/imports/particles/resources/trailsvertex.shader37
-rw-r--r--src/imports/particles/resources/ultrafragment.shader16
-rw-r--r--src/imports/particles/resources/ultravertex.shader94
18 files changed, 529 insertions, 0 deletions
diff --git a/src/imports/particles/resources/ctfragment.shader b/src/imports/particles/resources/ctfragment.shader
new file mode 100644
index 0000000000..a17f5841ca
--- /dev/null
+++ b/src/imports/particles/resources/ctfragment.shader
@@ -0,0 +1,11 @@
+uniform sampler2D texture;
+uniform sampler2D colortable;
+uniform sampler2D opacitytable;
+
+varying highp vec2 fTex;
+varying lowp vec4 fColor;
+varying lowp float tt;
+
+void main() {
+ gl_FragColor = (texture2D(texture, fTex).w) * fColor * texture2D(colortable, vec2(tt, 0.5)) *( texture2D(opacitytable, vec2(tt, 0.5)).w);
+}
diff --git a/src/imports/particles/resources/ctvertex.shader b/src/imports/particles/resources/ctvertex.shader
new file mode 100644
index 0000000000..b20676cc49
--- /dev/null
+++ b/src/imports/particles/resources/ctvertex.shader
@@ -0,0 +1,38 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+attribute lowp vec4 vColor;
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform sampler2D sizetable;
+uniform sampler2D opacitytable;
+
+varying highp vec2 fTex;
+varying lowp vec4 fColor;
+varying lowp float tt;
+
+void main() {
+ fTex = vTex;
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t) * texture2D(sizetable, vec2(t,0.5)).w;
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ fColor = vColor;
+ tt = t;
+
+}
diff --git a/src/imports/particles/resources/defaultFadeInOut.png b/src/imports/particles/resources/defaultFadeInOut.png
new file mode 100644
index 0000000000..89c04eaefe
--- /dev/null
+++ b/src/imports/particles/resources/defaultFadeInOut.png
Binary files differ
diff --git a/src/imports/particles/resources/deformablefragment.shader b/src/imports/particles/resources/deformablefragment.shader
new file mode 100644
index 0000000000..494053e319
--- /dev/null
+++ b/src/imports/particles/resources/deformablefragment.shader
@@ -0,0 +1,8 @@
+uniform sampler2D texture;
+
+varying highp vec2 fTex;
+varying lowp float fFade;
+
+void main() {
+ gl_FragColor = (texture2D(texture, fTex)) * fFade;
+}
diff --git a/src/imports/particles/resources/deformablevertex.shader b/src/imports/particles/resources/deformablevertex.shader
new file mode 100644
index 0000000000..01570950b1
--- /dev/null
+++ b/src/imports/particles/resources/deformablevertex.shader
@@ -0,0 +1,57 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+attribute highp vec4 vDeformVec; //x,y x unit vector; z,w = y unit vector
+attribute highp vec3 vRotation; //x = radians of rotation, y=rotation speed, z= bool autoRotate
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform lowp float opacity;
+
+varying highp vec2 fTex;
+varying lowp float fFade;
+
+void main() {
+ fTex = vTex;
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ highp vec2 pos;
+ if (t < 0. || t > 1.){
+ currentSize = 0.;
+ pos = vPos;
+ }else{
+ highp float rotation = vRotation.x + vRotation.y * t * vData.y;
+ if(vRotation.z == 1.0){
+ highp vec2 curVel = vVec.zw * t * vData.y + vVec.xy;
+ rotation += atan(curVel.y, curVel.x);
+ }
+ highp vec2 trigCalcs = vec2(cos(rotation), sin(rotation));
+ highp vec2 xDeform = vDeformVec.xy * currentSize * (vTex.x-0.5);
+ highp vec2 yDeform = vDeformVec.zw * currentSize * (vTex.y-0.5);
+ highp vec2 xRotatedDeform;
+ xRotatedDeform.x = trigCalcs.x*xDeform.x - trigCalcs.y*xDeform.y;
+ xRotatedDeform.y = trigCalcs.y*xDeform.x + trigCalcs.x*xDeform.y;
+ highp vec2 yRotatedDeform;
+ yRotatedDeform.x = trigCalcs.x*yDeform.x - trigCalcs.y*yDeform.y;
+ yRotatedDeform.y = trigCalcs.y*yDeform.x + trigCalcs.x*yDeform.y;
+ pos = vPos
+ + xRotatedDeform
+ + yRotatedDeform
+ //- vec2(1,1) * currentSize * 0.5 // 'center'
+ + vVec.xy * t * vData.y // apply speed
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration
+ }
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * opacity;
+}
diff --git a/src/imports/particles/resources/identitytable.png b/src/imports/particles/resources/identitytable.png
new file mode 100644
index 0000000000..2cada1bfad
--- /dev/null
+++ b/src/imports/particles/resources/identitytable.png
Binary files differ
diff --git a/src/imports/particles/resources/simplefragment.shader b/src/imports/particles/resources/simplefragment.shader
new file mode 100644
index 0000000000..494053e319
--- /dev/null
+++ b/src/imports/particles/resources/simplefragment.shader
@@ -0,0 +1,8 @@
+uniform sampler2D texture;
+
+varying highp vec2 fTex;
+varying lowp float fFade;
+
+void main() {
+ gl_FragColor = (texture2D(texture, fTex)) * fFade;
+}
diff --git a/src/imports/particles/resources/simplevertex.shader b/src/imports/particles/resources/simplevertex.shader
new file mode 100644
index 0000000000..f185ef0700
--- /dev/null
+++ b/src/imports/particles/resources/simplevertex.shader
@@ -0,0 +1,36 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform lowp float opacity;
+
+varying highp vec2 fTex;
+varying lowp float fFade;
+
+void main() {
+ fTex = vTex;
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * opacity;
+}
diff --git a/src/imports/particles/resources/spritefragment.shader b/src/imports/particles/resources/spritefragment.shader
new file mode 100644
index 0000000000..4d89d69c6a
--- /dev/null
+++ b/src/imports/particles/resources/spritefragment.shader
@@ -0,0 +1,10 @@
+uniform sampler2D texture;
+
+varying highp vec2 fTexA;
+varying highp vec2 fTexB;
+varying lowp float progress;
+varying lowp vec4 fColor;
+
+void main() {
+ gl_FragColor = mix(texture2D(texture, fTexA), texture2D(texture, fTexB), progress) * fColor.w;
+}
diff --git a/src/imports/particles/resources/spriteimagefragment.shader b/src/imports/particles/resources/spriteimagefragment.shader
new file mode 100644
index 0000000000..ecd62cf390
--- /dev/null
+++ b/src/imports/particles/resources/spriteimagefragment.shader
@@ -0,0 +1,9 @@
+uniform sampler2D texture;
+
+varying highp vec2 fTexA;
+varying highp vec2 fTexB;
+varying lowp float progress;
+
+void main() {
+ gl_FragColor = mix(texture2D(texture, fTexA), texture2D(texture, fTexB), progress);
+}
diff --git a/src/imports/particles/resources/spriteimagevertex.shader b/src/imports/particles/resources/spriteimagevertex.shader
new file mode 100644
index 0000000000..27de2ada6a
--- /dev/null
+++ b/src/imports/particles/resources/spriteimagevertex.shader
@@ -0,0 +1,52 @@
+attribute highp vec2 vTex;
+attribute highp vec4 vAnimData;// idx, duration, frameCount (this anim), timestamp (this anim)
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform lowp float opacity;
+uniform highp float framecount; //maximum of all anims
+uniform highp float animcount;
+uniform highp float width;
+uniform highp float height;
+
+varying highp vec2 fTexA;
+varying highp vec2 fTexB;
+varying lowp float progress;
+
+
+void main() {
+ //Calculate frame location in texture
+ highp float frameIndex = mod((((timestamp - vAnimData.w)*1000.)/vAnimData.y),vAnimData.z);
+ progress = mod((timestamp - vAnimData.w)*1000., vAnimData.y) / vAnimData.y;
+
+ frameIndex = floor(frameIndex);
+ highp vec2 frameTex;
+ if(vTex.x == 0.)
+ frameTex.x = (frameIndex/framecount);
+ else
+ frameTex.x = 1. * ((frameIndex + 1.)/framecount);
+
+ if(vTex.y == 0.)
+ frameTex.y = (vAnimData.x/animcount);
+ else
+ frameTex.y = 1. * ((vAnimData.x + 1.)/animcount);
+
+ fTexA = frameTex;
+ //Next frame is also passed, for interpolation
+ if(frameIndex != vAnimData.z - 1.)//Can't do it for the last frame though, this anim may not loop
+ frameIndex = mod(frameIndex+1., vAnimData.z);
+
+ if(vTex.x == 0.)
+ frameTex.x = (frameIndex/framecount);
+ else
+ frameTex.x = 1. * ((frameIndex + 1.)/framecount);
+
+ if(vTex.y == 0.)
+ frameTex.y = (vAnimData.x/animcount);
+ else
+ frameTex.y = 1. * ((vAnimData.x + 1.)/animcount);
+ fTexB = frameTex;
+
+
+ gl_Position = matrix * vec4(width * vTex.x, height * vTex.y, 0, 1);
+}
diff --git a/src/imports/particles/resources/spritevertex.shader b/src/imports/particles/resources/spritevertex.shader
new file mode 100644
index 0000000000..78b8e36b3b
--- /dev/null
+++ b/src/imports/particles/resources/spritevertex.shader
@@ -0,0 +1,77 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+attribute highp vec4 vAnimData;// idx, duration, frameCount (this anim), timestamp (this anim)
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform lowp float opacity;
+uniform highp float framecount; //maximum of all anims
+uniform highp float animcount;
+
+varying highp vec2 fTexA;
+varying highp vec2 fTexB;
+varying lowp float progress;
+varying lowp vec4 fColor;
+
+void main() {
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ //Calculate frame location in texture
+ highp float frameIndex = mod((((timestamp - vAnimData.w)*1000.)/vAnimData.y),vAnimData.z);
+ progress = mod((timestamp - vAnimData.w)*1000., vAnimData.y) / vAnimData.y;
+
+ frameIndex = floor(frameIndex);
+ highp vec2 frameTex = vTex;
+ if(vTex.x == 0.)
+ frameTex.x = (frameIndex/framecount);
+ else
+ frameTex.x = 1. * ((frameIndex + 1.)/framecount);
+
+ if(vTex.y == 0.)
+ frameTex.y = (vAnimData.x/animcount);
+ else
+ frameTex.y = 1. * ((vAnimData.x + 1.)/animcount);
+
+ fTexA = frameTex;
+ //Next frame is also passed, for interpolation
+ //### Should the next anim be precalculated to allow for interpolation there?
+ if(frameIndex != vAnimData.z - 1.)//Can't do it for the last frame though, this anim may not loop
+ frameIndex = mod(frameIndex+1., vAnimData.z);
+
+ if(vTex.x == 0.)
+ frameTex.x = (frameIndex/framecount);
+ else
+ frameTex.x = 1. * ((frameIndex + 1.)/framecount);
+
+ if(vTex.y == 0.)
+ frameTex.y = (vAnimData.x/animcount);
+ else
+ frameTex.y = 1. * ((vAnimData.x + 1.)/animcount);
+ fTexB = frameTex;
+
+ //Applying Size here seems to screw with RockingAffector?
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ //If affector is mananging pos, they don't set speed?
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ // calculate opacity
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ lowp vec4 white = vec4(1.);
+ fColor = white * fadeIn * fadeOut * opacity;
+}
diff --git a/src/imports/particles/resources/superfragment.shader b/src/imports/particles/resources/superfragment.shader
new file mode 100644
index 0000000000..a17f5841ca
--- /dev/null
+++ b/src/imports/particles/resources/superfragment.shader
@@ -0,0 +1,11 @@
+uniform sampler2D texture;
+uniform sampler2D colortable;
+uniform sampler2D opacitytable;
+
+varying highp vec2 fTex;
+varying lowp vec4 fColor;
+varying lowp float tt;
+
+void main() {
+ gl_FragColor = (texture2D(texture, fTex).w) * fColor * texture2D(colortable, vec2(tt, 0.5)) *( texture2D(opacitytable, vec2(tt, 0.5)).w);
+}
diff --git a/src/imports/particles/resources/supervertex.shader b/src/imports/particles/resources/supervertex.shader
new file mode 100644
index 0000000000..432a23ce05
--- /dev/null
+++ b/src/imports/particles/resources/supervertex.shader
@@ -0,0 +1,57 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+attribute lowp vec4 vColor;
+attribute highp vec4 vDeformVec; //x,y x unit vector; z,w = y unit vector
+attribute highp vec3 vRotation; //x = radians of rotation, y=rotation speed, z= bool autoRotate
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform sampler2D sizetable;
+uniform sampler2D opacitytable;
+
+varying highp vec2 fTex;
+varying lowp vec4 fColor;
+varying lowp float tt;
+
+void main() {
+ fTex = vTex;
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t) * texture2D(sizetable, vec2(t,0.5)).w;
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos;
+ highp float rotation = vRotation.x + vRotation.y * t * vData.y;
+ if(vRotation.z == 1.0){
+ highp vec2 curVel = vVec.zw * t * vData.y + vVec.xy;
+ rotation += atan(curVel.y, curVel.x);
+ }
+ highp vec2 trigCalcs = vec2(cos(rotation), sin(rotation));
+ highp vec2 xDeform = vDeformVec.xy * currentSize * (vTex.x-0.5);
+ highp vec2 yDeform = vDeformVec.zw * currentSize * (vTex.y-0.5);
+ highp vec2 xRotatedDeform;
+ xRotatedDeform.x = trigCalcs.x*xDeform.x - trigCalcs.y*xDeform.y;
+ xRotatedDeform.y = trigCalcs.y*xDeform.x + trigCalcs.x*xDeform.y;
+ highp vec2 yRotatedDeform;
+ yRotatedDeform.x = trigCalcs.x*yDeform.x - trigCalcs.y*yDeform.y;
+ yRotatedDeform.y = trigCalcs.y*yDeform.x + trigCalcs.x*yDeform.y;
+ pos = vPos
+ + xRotatedDeform
+ + yRotatedDeform
+ //- vec2(1,1) * currentSize * 0.5 // 'center'
+ + vVec.xy * t * vData.y // apply speed
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ fColor = vColor;
+ tt = t;
+
+}
diff --git a/src/imports/particles/resources/trailsfragment.shader b/src/imports/particles/resources/trailsfragment.shader
new file mode 100644
index 0000000000..d3db87fa30
--- /dev/null
+++ b/src/imports/particles/resources/trailsfragment.shader
@@ -0,0 +1,8 @@
+uniform sampler2D texture;
+
+varying highp vec2 fTex;
+varying lowp vec4 fColor;
+
+void main() {
+ gl_FragColor = (texture2D(texture, fTex).w) * fColor;
+}
diff --git a/src/imports/particles/resources/trailsvertex.shader b/src/imports/particles/resources/trailsvertex.shader
new file mode 100644
index 0000000000..7bc1d66b71
--- /dev/null
+++ b/src/imports/particles/resources/trailsvertex.shader
@@ -0,0 +1,37 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+attribute lowp vec4 vColor;
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform lowp float opacity;
+
+varying highp vec2 fTex;
+varying lowp vec4 fColor;
+
+void main() {
+ fTex = vTex;
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fColor = vColor * fadeIn * fadeOut * opacity;
+}
diff --git a/src/imports/particles/resources/ultrafragment.shader b/src/imports/particles/resources/ultrafragment.shader
new file mode 100644
index 0000000000..0627d0f1e8
--- /dev/null
+++ b/src/imports/particles/resources/ultrafragment.shader
@@ -0,0 +1,16 @@
+uniform sampler2D texture;
+uniform sampler2D colortable;
+uniform sampler2D opacitytable;
+
+varying highp vec2 fTexA;
+varying highp vec2 fTexB;
+varying lowp float progress;
+varying lowp vec4 fColor;
+varying lowp float tt;
+
+void main() {
+ gl_FragColor = mix(texture2D(texture, fTexA), texture2D(texture, fTexB), progress)
+ * fColor
+ * texture2D(colortable, vec2(tt, 0.5))
+ *( texture2D(opacitytable, vec2(tt, 0.5)).w);
+}
diff --git a/src/imports/particles/resources/ultravertex.shader b/src/imports/particles/resources/ultravertex.shader
new file mode 100644
index 0000000000..65a1a3077a
--- /dev/null
+++ b/src/imports/particles/resources/ultravertex.shader
@@ -0,0 +1,94 @@
+attribute highp vec2 vPos;
+attribute highp vec2 vTex;
+attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+attribute lowp vec4 vColor;
+attribute highp vec4 vDeformVec; //x,y x unit vector; z,w = y unit vector
+attribute highp vec3 vRotation; //x = radians of rotation, y=rotation speed, z= bool autoRotate
+attribute highp vec4 vAnimData;// idx, duration, frameCount (this anim), timestamp (this anim)
+
+uniform highp mat4 matrix;
+uniform highp float timestamp;
+uniform highp float framecount; //maximum of all anims
+uniform highp float animcount;
+uniform sampler2D sizetable;
+
+varying lowp float tt;
+varying highp vec2 fTexA;
+varying highp vec2 fTexB;
+varying lowp float progress;
+varying lowp vec4 fColor;
+
+
+void main() {
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ //Calculate frame location in texture
+ highp float frameIndex = mod((((timestamp - vAnimData.w)*1000.)/vAnimData.y),vAnimData.z);
+ progress = mod((timestamp - vAnimData.w)*1000., vAnimData.y) / vAnimData.y;
+
+ frameIndex = floor(frameIndex);
+ highp vec2 frameTex = vTex;
+ if(vTex.x == 0.)
+ frameTex.x = (frameIndex/framecount);
+ else
+ frameTex.x = 1. * ((frameIndex + 1.)/framecount);
+
+ if(vTex.y == 0.)
+ frameTex.y = (vAnimData.x/animcount);
+ else
+ frameTex.y = 1. * ((vAnimData.x + 1.)/animcount);
+
+ fTexA = frameTex;
+ //Next frame is also passed, for interpolation
+ //### Should the next anim be precalculated to allow for interpolation there?
+ if(frameIndex != vAnimData.z - 1.)//Can't do it for the last frame though, this anim may not loop
+ frameIndex = mod(frameIndex+1., vAnimData.z);
+
+ if(vTex.x == 0.)
+ frameTex.x = (frameIndex/framecount);
+ else
+ frameTex.x = 1. * ((frameIndex + 1.)/framecount);
+
+ if(vTex.y == 0.)
+ frameTex.y = (vAnimData.x/animcount);
+ else
+ frameTex.y = 1. * ((vAnimData.x + 1.)/animcount);
+ fTexB = frameTex;
+
+ highp float currentSize = mix(size, endSize, t * t) * texture2D(sizetable, vec2(t,0.5)).w;
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos;
+ highp float rotation = vRotation.x + vRotation.y * t * vData.y;
+ if(vRotation.z == 1.0){
+ highp vec2 curVel = vVec.zw * t * vData.y + vVec.xy;
+ rotation += atan(curVel.y, curVel.x);
+ }
+ highp vec2 trigCalcs = vec2(cos(rotation), sin(rotation));
+ highp vec2 xDeform = vDeformVec.xy * currentSize * (vTex.x-0.5);
+ highp vec2 yDeform = vDeformVec.zw * currentSize * (vTex.y-0.5);
+ highp vec2 xRotatedDeform;
+ xRotatedDeform.x = trigCalcs.x*xDeform.x - trigCalcs.y*xDeform.y;
+ xRotatedDeform.y = trigCalcs.y*xDeform.x + trigCalcs.x*xDeform.y;
+ highp vec2 yRotatedDeform;
+ yRotatedDeform.x = trigCalcs.x*yDeform.x - trigCalcs.y*yDeform.y;
+ yRotatedDeform.y = trigCalcs.y*yDeform.x + trigCalcs.x*yDeform.y;
+ pos = vPos
+ + xRotatedDeform
+ + yRotatedDeform
+ //- vec2(1,1) * currentSize * 0.5 // 'center'
+ + vVec.xy * t * vData.y // apply speed
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration
+
+ gl_Position = matrix * vec4(pos.x, pos.y, 0, 1);
+
+ fColor = vColor;
+ tt = t;
+
+}