aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-10-10 17:12:06 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-10 10:23:17 +0200
commit70d98314ce9ea60c77af83e2cf7de069e87a2e56 (patch)
tree0288c9b65dc2a857a39e08da02daa1c76374050b /src
parent18c33423a54c24cf13b93115edfd22b6db0f1307 (diff)
Update SpriteImage to modern standards
Includes updating shaders to contain the recent size flexibilities added to QSGImageParticle, adding documentation, moving shaders into the source file, and optional interpolation. Small doc fixes, moving shaders into the source file, and moving the resources (because there are no longer any shaders there) were applied to ImageParticle and Turbulence (last user of particles resources). Change-Id: I5e2f133dc4b96dd05d49e7e983ae630e379fa66f Reviewed-on: http://codereview.qt-project.org/6303 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/items/qsgsprite.cpp73
-rw-r--r--src/declarative/items/qsgspriteimage.cpp206
-rw-r--r--src/declarative/items/qsgspriteimage_p.h17
-rw-r--r--src/declarative/particles/defaultshaders/coloredfragment.shader9
-rw-r--r--src/declarative/particles/defaultshaders/coloredvertex.shader44
-rw-r--r--src/declarative/particles/defaultshaders/defaultFadeInOut.pngbin286 -> 0 bytes
-rw-r--r--src/declarative/particles/defaultshaders/deformablefragment.shader9
-rw-r--r--src/declarative/particles/defaultshaders/deformablevertex.shader65
-rw-r--r--src/declarative/particles/defaultshaders/identitytable.pngbin90 -> 0 bytes
-rw-r--r--src/declarative/particles/defaultshaders/imagefragment.shader45
-rw-r--r--src/declarative/particles/defaultshaders/imagevertex.shader131
-rw-r--r--src/declarative/particles/defaultshaders/simplefragment.shader8
-rw-r--r--src/declarative/particles/defaultshaders/simplevertex.shader39
-rw-r--r--src/declarative/particles/defaultshaders/spritefragment.shader17
-rw-r--r--src/declarative/particles/defaultshaders/spriteimagefragment.shader9
-rw-r--r--src/declarative/particles/defaultshaders/spriteimagevertex.shader52
-rw-r--r--src/declarative/particles/defaultshaders/spritevertex.shader113
-rw-r--r--src/declarative/particles/defaultshaders/tabledfragment.shader23
-rw-r--r--src/declarative/particles/defaultshaders/tabledvertex.shader56
-rw-r--r--src/declarative/particles/particleresources/noise.png (renamed from src/declarative/particles/defaultshaders/noise.png)bin19477 -> 19477 bytes
-rw-r--r--src/declarative/particles/particles.qrc8
-rw-r--r--src/declarative/particles/qsgimageparticle.cpp230
-rw-r--r--src/declarative/particles/qsgturbulence.cpp2
23 files changed, 425 insertions, 731 deletions
diff --git a/src/declarative/items/qsgsprite.cpp b/src/declarative/items/qsgsprite.cpp
index 68f2e7827d..afd32a651f 100644
--- a/src/declarative/items/qsgsprite.cpp
+++ b/src/declarative/items/qsgsprite.cpp
@@ -44,6 +44,79 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass Sprite QSGSprite
+ \inqmlmodule QtQuick 2
+ \brief The Sprite element represents a sprite animation
+
+*/
+/*!
+ \qmlproperty int QtQuick2::Sprite::duration
+
+ Time between frames.
+*/
+/*!
+ \qmlproperty int QtQuick2::Sprite::durationVariation
+
+ The time between frames can vary by up to this amount.
+
+ Default is 0.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Sprite::name
+
+ The name of this sprite, for use in the to property of other sprites.
+*/
+/*!
+ \qmlproperty QVariantMap QtQuick2::Sprite::to
+
+ A list of other sprites and weighted transitions to them,
+ for example {"a":1, "b":2, "c":0} would specify that one-third should
+ transition to sprite "a" when this sprite is done, and two-thirds should
+ transition to sprite "b" when this sprite is done. As the transitions are
+ chosen randomly, these proportions will not be exact. With "c":0 in the list,
+ no sprites will randomly transition to "c", but it wll be a valid path if a sprite
+ goal is set.
+
+ If no list is specified, or the sum of weights in the list is zero, then the sprite
+ will repeat itself after completing.
+*/
+/*!
+ \qmlproperty int QtQuick2::Sprite::frames
+
+ Number of frames in this sprite.
+*/
+/*!
+ \qmlproperty int QtQuick2::Sprite::frameHeight
+
+ Height of a single frame in this sprite.
+*/
+/*!
+ \qmlproperty int QtQuick2::Sprite::frameWidth
+
+ Width of a single frame in this sprite.
+*/
+/*!
+ \qmlproperty url QtQuick2::Sprite::source
+
+ The image source for the animation.
+
+ If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames.
+ Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used.
+*/
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(int durationVariation READ durationVariance WRITE setDurationVariance NOTIFY durationVarianceChanged)
+ Q_PROPERTY(QVariantMap to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(qreal speedModifiesDuration READ speedModifer WRITE setSpeedModifier NOTIFY speedModifierChanged)
+ Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ //If frame height or width is not specified, it is assumed to be a single long row of square frames.
+ //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
+ Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
+ Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
+
QSGSprite::QSGSprite(QObject *parent) :
QSGStochasticState(parent)
, m_generatedCount(0)
diff --git a/src/declarative/items/qsgspriteimage.cpp b/src/declarative/items/qsgspriteimage.cpp
index 1814bc1d2c..20544ad28b 100644
--- a/src/declarative/items/qsgspriteimage.cpp
+++ b/src/declarative/items/qsgspriteimage.cpp
@@ -55,6 +55,47 @@
QT_BEGIN_NAMESPACE
+static const char vertexShaderCode[] =
+ "attribute highp vec2 vTex;\n"
+ "uniform highp vec4 animData;// interpolate(bool), duration, frameCount (this anim), timestamp (this anim)\n"
+ "uniform highp vec4 animPos;//sheet x,y, width/height of this anim\n"
+ "uniform highp vec4 animSheetSize; //width/height of whole sheet, width/height of element\n"
+ "\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "uniform highp float timestamp;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "\n"
+ "void main() {\n"
+ " //Calculate frame location in texture\n"
+ " highp float frameIndex = mod((((timestamp - animData.w)*1000.)/animData.y),animData.z);\n"
+ " progress = mod((timestamp - animData.w)*1000., animData.y) / animData.y;\n"
+ "\n"
+ " frameIndex = floor(frameIndex);\n"
+ " fTexS.xy = vec2(((frameIndex + vTex.x) * animPos.z / animSheetSize.x), ((animPos.y + vTex.y * animPos.w) / animSheetSize.y));\n"
+ "\n"
+ " //Next frame is also passed, for interpolation\n"
+ " //### Should the next anim be precalculated to allow for interpolation there?\n"
+ " if (animData.x == 1.0 && frameIndex != animData.z - 1.)//Can't do it for the last frame though, this anim may not loop\n"
+ " frameIndex = mod(frameIndex+1., animData.z);\n"
+ " fTexS.zw = vec2(((frameIndex + vTex.x) * animPos.z / animSheetSize.x), ((animPos.y + vTex.y * animPos.w) / animSheetSize.y));\n"
+ "\n"
+ " gl_Position = qt_Matrix * vec4(animSheetSize.z * vTex.x, animSheetSize.w * vTex.y, 0, 1);\n"
+ "}\n";
+
+static const char fragmentShaderCode[] =
+ "uniform sampler2D texture;\n"
+ "uniform lowp float qt_Opacity;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "void main() {\n"
+ " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n"
+ "}\n";
+
class QSGSpriteMaterial : public QSGMaterial
{
public:
@@ -70,20 +111,34 @@ public:
QSGTexture *texture;
qreal timestamp;
- qreal timelength;
- int framecount;
- int animcount;
- int width;
- int height;
+ float interpolate;
+ float frameDuration;
+ float frameCount;
+ float animT;
+ float animX;
+ float animY;
+ float animWidth;
+ float animHeight;
+ float sheetWidth;
+ float sheetHeight;
+ float elementWidth;
+ float elementHeight;
};
QSGSpriteMaterial::QSGSpriteMaterial()
: timestamp(0)
- , timelength(1)
- , framecount(1)
- , animcount(1)
- , width(0)
- , height(0)
+ , interpolate(1.0f)
+ , frameDuration(1.0f)
+ , frameCount(1.0f)
+ , animT(0.0f)
+ , animX(0.0f)
+ , animY(0.0f)
+ , animWidth(1.0f)
+ , animHeight(1.0f)
+ , sheetWidth(1.0f)
+ , sheetHeight(1.0f)
+ , elementWidth(1.0f)
+ , elementHeight(1.0f)
{
setFlag(Blending, true);
}
@@ -98,16 +153,6 @@ class SpriteMaterialData : public QSGMaterialShader
public:
SpriteMaterialData(const char *vertexFile = 0, const char *fragmentFile = 0)
{
- QFile vf(vertexFile ? QLatin1String(vertexFile) : QLatin1String(":defaultshaders/spriteimagevertex.shader"));
- vf.open(QFile::ReadOnly);
- m_vertex_code = vf.readAll();
-
- QFile ff(fragmentFile ? QLatin1String(fragmentFile) : QLatin1String(":defaultshaders/spriteimagefragment.shader"));
- ff.open(QFile::ReadOnly);
- m_fragment_code = ff.readAll();
-
- Q_ASSERT(!m_vertex_code.isNull());
- Q_ASSERT(!m_fragment_code.isNull());
}
void deactivate() {
@@ -125,52 +170,44 @@ public:
program()->setUniformValue(m_opacity_id, state.opacity());
program()->setUniformValue(m_timestamp_id, (float) m->timestamp);
- program()->setUniformValue(m_framecount_id, (float) m->framecount);
- program()->setUniformValue(m_animcount_id, (float) m->animcount);
- program()->setUniformValue(m_width_id, (float) m->width);
- program()->setUniformValue(m_height_id, (float) m->height);
+ program()->setUniformValue(m_animData_id, m->interpolate, m->frameDuration, m->frameCount, m->animT);
+ program()->setUniformValue(m_animPos_id, m->animX, m->animY, m->animWidth, m->animHeight);
+ program()->setUniformValue(m_animSheetSize_id, m->sheetWidth, m->sheetHeight, m->elementWidth, m->elementHeight);
if (state.isMatrixDirty())
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
}
virtual void initialize() {
- m_matrix_id = program()->uniformLocation("matrix");
- m_opacity_id = program()->uniformLocation("opacity");
+ m_matrix_id = program()->uniformLocation("qt_Matrix");
+ m_opacity_id = program()->uniformLocation("qt_Opacity");
m_timestamp_id = program()->uniformLocation("timestamp");
- m_framecount_id = program()->uniformLocation("framecount");
- m_animcount_id = program()->uniformLocation("animcount");
- m_width_id = program()->uniformLocation("width");
- m_height_id = program()->uniformLocation("height");
+ m_animData_id = program()->uniformLocation("animData");
+ m_animPos_id = program()->uniformLocation("animPos");
+ m_animSheetSize_id = program()->uniformLocation("animSheetSize");
}
- virtual const char *vertexShader() const { return m_vertex_code.constData(); }
- virtual const char *fragmentShader() const { return m_fragment_code.constData(); }
+ virtual const char *vertexShader() const { return vertexShaderCode; }
+ virtual const char *fragmentShader() const { return fragmentShaderCode; }
virtual char const *const *attributeNames() const {
static const char *attr[] = {
"vTex",
- "vAnimData",
0
};
return attr;
}
- virtual bool isColorTable() const { return false; }
-
int m_matrix_id;
int m_opacity_id;
int m_timestamp_id;
- int m_framecount_id;
- int m_animcount_id;
- int m_width_id;
- int m_height_id;
-
- QByteArray m_vertex_code;
- QByteArray m_fragment_code;
+ int m_animData_id;
+ int m_animPos_id;
+ int m_animSheetSize_id;
static float chunkOfBytes[1024];
};
+
float SpriteMaterialData::chunkOfBytes[1024];
QSGMaterialShader *QSGSpriteMaterial::createShader() const
@@ -181,10 +218,6 @@ QSGMaterialShader *QSGSpriteMaterial::createShader() const
struct SpriteVertex {
float tx;
float ty;
- float animIdx;
- float frameDuration;
- float frameCount;
- float animT;
};
struct SpriteVertices {
@@ -194,6 +227,35 @@ struct SpriteVertices {
SpriteVertex v4;
};
+/*!
+ \qmlclass SpriteImage QSGSpriteImage
+ \inqmlmodule QtQuick 2
+ \inherits Item
+ \brief The SpriteImage element draws a sprite animation
+
+*/
+/*!
+ \qmlproperty bool QtQuick2::SpriteImage::running
+
+ Whether the sprite is animating or not.
+
+ Default is true
+*/
+/*!
+ \qmlproperty bool QtQuick2::SpriteImage::interpolate
+
+ If true, interpolation will occur between sprite frames to make the
+ animation appear smoother.
+
+ Default is true.
+*/
+/*!
+ \qmlproperty list<Sprite> QtQuick2::SpriteImage::sprites
+
+ The sprite or sprites to draw. Sprites will be scaled to the size of this element.
+*/
+
+//TODO: Implicitly size element to size of first sprite?
QSGSpriteImage::QSGSpriteImage(QSGItem *parent) :
QSGItem(parent)
, m_node(0)
@@ -201,6 +263,7 @@ QSGSpriteImage::QSGSpriteImage(QSGItem *parent) :
, m_spriteEngine(0)
, m_pleaseReset(false)
, m_running(true)
+ , m_interpolate(true)
{
setFlag(ItemHasContents);
connect(this, SIGNAL(runningChanged(bool)),
@@ -226,13 +289,12 @@ void QSGSpriteImage::createEngine()
static QSGGeometry::Attribute SpriteImage_Attributes[] = {
QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex
- QSGGeometry::Attribute::create(1, 4, GL_FLOAT) // animData
};
static QSGGeometry::AttributeSet SpriteImage_AttributeSet =
{
- 2, // Attribute Count
- (4 + 2) * sizeof(float),
+ 1, // Attribute Count
+ 2 * sizeof(float),
SpriteImage_Attributes
};
@@ -243,11 +305,6 @@ QSGGeometryNode* QSGSpriteImage::buildNode()
return 0;
}
- if (m_material) {
- delete m_material;
- m_material = 0;
- }
-
m_material = new QSGSpriteMaterial();
QImage image = m_spriteEngine->assembledImage();
@@ -255,7 +312,19 @@ QSGGeometryNode* QSGSpriteImage::buildNode()
return 0;
m_material->texture = sceneGraphEngine()->createTextureFromImage(image);
m_material->texture->setFiltering(QSGTexture::Linear);
- m_material->framecount = m_spriteEngine->maxFrames();
+ m_spriteEngine->start(0);
+ m_material->interpolate = m_interpolate ? 1.0 : 0.0;
+ m_material->frameCount = m_spriteEngine->spriteFrames();
+ m_material->frameDuration = m_spriteEngine->spriteDuration();
+ m_material->animT = 0;
+ m_material->animX = m_spriteEngine->spriteX();
+ m_material->animY = m_spriteEngine->spriteY();
+ m_material->animWidth = m_spriteEngine->spriteWidth();
+ m_material->animHeight = m_spriteEngine->spriteHeight();
+ m_material->sheetWidth = image.width();
+ m_material->sheetHeight = image.height();
+ m_material->elementWidth = width();
+ m_material->elementHeight = height();
int vCount = 4;
int iCount = 6;
@@ -263,11 +332,6 @@ QSGGeometryNode* QSGSpriteImage::buildNode()
g->setDrawingMode(GL_TRIANGLES);
SpriteVertices *p = (SpriteVertices *) g->vertexData();
- m_spriteEngine->start(0);
- p->v1.animT = p->v2.animT = p->v3.animT = p->v4.animT = 0;
- p->v1.animIdx = p->v2.animIdx = p->v3.animIdx = p->v4.animIdx = 0;
- p->v1.frameCount = p->v2.frameCount = p->v3.frameCount = p->v4.frameCount = m_spriteEngine->spriteFrames();
- p->v1.frameDuration = p->v2.frameDuration = p->v3.frameDuration = p->v4.frameDuration = m_spriteEngine->spriteDuration();
p->v1.tx = 0;
p->v1.ty = 0;
@@ -294,6 +358,7 @@ QSGGeometryNode* QSGSpriteImage::buildNode()
m_node = new QSGGeometryNode();
m_node->setGeometry(g);
m_node->setMaterial(m_material);
+ m_node->setFlag(QSGGeometryNode::OwnsMaterial);
return m_node;
}
@@ -334,19 +399,22 @@ void QSGSpriteImage::prepareNextFrame()
uint timeInt = m_timestamp.elapsed();
qreal time = timeInt / 1000.;
m_material->timestamp = time;
- m_material->animcount = m_spriteEngine->spriteCount();
- m_material->height = height();
- m_material->width = width();
+ m_material->elementHeight = height();
+ m_material->elementWidth = width();
+ m_material->interpolate = m_interpolate;
//Advance State
SpriteVertices *p = (SpriteVertices *) m_node->geometry()->vertexData();
m_spriteEngine->updateSprites(timeInt);
- int curIdx = m_spriteEngine->spriteState();
- if(curIdx != p->v1.animIdx){
- p->v1.animIdx = p->v2.animIdx = p->v3.animIdx = p->v4.animIdx = curIdx;
- p->v1.animT = p->v2.animT = p->v3.animT = p->v4.animT = m_spriteEngine->spriteStart()/1000.0;
- p->v1.frameCount = p->v2.frameCount = p->v3.frameCount = p->v4.frameCount = m_spriteEngine->spriteFrames();
- p->v1.frameDuration = p->v2.frameDuration = p->v3.frameDuration = p->v4.frameDuration = m_spriteEngine->spriteDuration();
+ int curY = m_spriteEngine->spriteY();
+ if (curY != m_material->animY){
+ m_material->animT = m_spriteEngine->spriteStart()/1000.0;
+ m_material->frameCount = m_spriteEngine->spriteFrames();
+ m_material->frameDuration = m_spriteEngine->spriteDuration();
+ m_material->animX = m_spriteEngine->spriteX();
+ m_material->animY = m_spriteEngine->spriteY();
+ m_material->animWidth = m_spriteEngine->spriteWidth();
+ m_material->animHeight = m_spriteEngine->spriteHeight();
}
}
diff --git a/src/declarative/items/qsgspriteimage_p.h b/src/declarative/items/qsgspriteimage_p.h
index c2179cf121..84c5b50136 100644
--- a/src/declarative/items/qsgspriteimage_p.h
+++ b/src/declarative/items/qsgspriteimage_p.h
@@ -60,6 +60,7 @@ class QSGSpriteImage : public QSGItem
{
Q_OBJECT
Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged)
//###try to share similar spriteEngines for less overhead?
Q_PROPERTY(QDeclarativeListProperty<QSGSprite> sprites READ sprites)
Q_CLASSINFO("DefaultProperty", "sprites")
@@ -74,10 +75,15 @@ public:
return m_running;
}
-signals:
+ bool interpolate() const
+ {
+ return m_interpolate;
+ }
+signals:
void runningChanged(bool arg);
+ void interpolateChanged(bool arg);
public slots:
@@ -89,6 +95,14 @@ void setRunning(bool arg)
}
}
+void setInterpolate(bool arg)
+{
+ if (m_interpolate != arg) {
+ m_interpolate = arg;
+ emit interpolateChanged(arg);
+ }
+}
+
private slots:
void createEngine();
protected:
@@ -105,6 +119,7 @@ private:
int m_maxFrames;
bool m_pleaseReset;
bool m_running;
+ bool m_interpolate;
};
QT_END_NAMESPACE
diff --git a/src/declarative/particles/defaultshaders/coloredfragment.shader b/src/declarative/particles/defaultshaders/coloredfragment.shader
deleted file mode 100644
index 4ae2643598..0000000000
--- a/src/declarative/particles/defaultshaders/coloredfragment.shader
+++ /dev/null
@@ -1,9 +0,0 @@
-uniform sampler2D texture;
-uniform lowp float qt_Opacity;
-
-varying lowp vec4 fColor;
-
-void main() {
- gl_FragColor = (texture2D(texture, gl_PointCoord)) * fColor * qt_Opacity;
-}
-
diff --git a/src/declarative/particles/defaultshaders/coloredvertex.shader b/src/declarative/particles/defaultshaders/coloredvertex.shader
deleted file mode 100644
index 5b8339276c..0000000000
--- a/src/declarative/particles/defaultshaders/coloredvertex.shader
+++ /dev/null
@@ -1,44 +0,0 @@
-attribute highp vec2 vPos;
-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 qt_Matrix;
-uniform highp float timestamp;
-uniform highp float entry;
-
-varying lowp vec4 fColor;
-
-void main() {
- 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.;
-
- lowp float fFade = 1.;
-
- if (entry == 1.){
- highp float fadeIn = min(t * 10., 1.);
- highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
- fFade = fadeIn * fadeOut;
- }else if(entry == 2.){
- highp float sizeIn = min(t * 10., 1.);
- highp float sizeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
- currentSize = currentSize * sizeIn * sizeOut;
- }
-
- gl_PointSize = currentSize;
-
- highp vec2 pos = vPos
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
-
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
- fColor = vColor * (fFade);
-}
diff --git a/src/declarative/particles/defaultshaders/defaultFadeInOut.png b/src/declarative/particles/defaultshaders/defaultFadeInOut.png
deleted file mode 100644
index 89c04eaefe..0000000000
--- a/src/declarative/particles/defaultshaders/defaultFadeInOut.png
+++ /dev/null
Binary files differ
diff --git a/src/declarative/particles/defaultshaders/deformablefragment.shader b/src/declarative/particles/defaultshaders/deformablefragment.shader
deleted file mode 100644
index 1ac25ba208..0000000000
--- a/src/declarative/particles/defaultshaders/deformablefragment.shader
+++ /dev/null
@@ -1,9 +0,0 @@
-uniform sampler2D texture;
-uniform lowp float qt_Opacity;
-
-varying highp vec2 fTex;
-varying lowp vec4 fColor;
-
-void main() {
- gl_FragColor = (texture2D(texture, fTex)) * fColor * qt_Opacity;
-}
diff --git a/src/declarative/particles/defaultshaders/deformablevertex.shader b/src/declarative/particles/defaultshaders/deformablevertex.shader
deleted file mode 100644
index ab6acde36d..0000000000
--- a/src/declarative/particles/defaultshaders/deformablevertex.shader
+++ /dev/null
@@ -1,65 +0,0 @@
-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
-attribute lowp vec4 vColor;
-
-uniform highp mat4 qt_Matrix;
-uniform highp float timestamp;
-uniform highp float entry;
-
-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.;
-
- lowp float fFade = 1.;
-
- if (entry == 1.){
- highp float fadeIn = min(t * 10., 1.);
- highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
- fFade = fadeIn * fadeOut;
- }else if(entry == 2.){
- highp float sizeIn = min(t * 10., 1.);
- highp float sizeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
- currentSize = currentSize * sizeIn * sizeOut;
- }
-
- 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 = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
- fColor = vColor * fFade;
-}
diff --git a/src/declarative/particles/defaultshaders/identitytable.png b/src/declarative/particles/defaultshaders/identitytable.png
deleted file mode 100644
index 2cada1bfad..0000000000
--- a/src/declarative/particles/defaultshaders/identitytable.png
+++ /dev/null
Binary files differ
diff --git a/src/declarative/particles/defaultshaders/imagefragment.shader b/src/declarative/particles/defaultshaders/imagefragment.shader
deleted file mode 100644
index c2341fe6ff..0000000000
--- a/src/declarative/particles/defaultshaders/imagefragment.shader
+++ /dev/null
@@ -1,45 +0,0 @@
-uniform sampler2D texture;
-uniform lowp float qt_Opacity;
-
-#ifdef SPRITE
-varying highp vec4 fTexS;
-#else
-#ifdef DEFORM //First non-pointsprite
-varying highp vec2 fTex;
-#endif
-#endif
-#ifdef COLOR
-varying lowp vec4 fColor;
-#else
-varying lowp float fFade;
-#endif
-#ifdef TABLE
-varying lowp vec2 tt;
-uniform sampler2D colortable;
-#endif
-
-void main() {
-#ifdef SPRITE
- gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), tt.y)
- * fColor
- * texture2D(colortable, tt)
- * qt_Opacity;
-#else
-#ifdef TABLE
- gl_FragColor = texture2D(texture, fTex)
- * fColor
- * texture2D(colortable, tt)
- * qt_Opacity;
-#else
-#ifdef DEFORM
- gl_FragColor = (texture2D(texture, fTex)) * fColor * qt_Opacity;
-#else
-#ifdef COLOR
- gl_FragColor = (texture2D(texture, gl_PointCoord)) * fColor * qt_Opacity;
-#else
- gl_FragColor = texture2D(texture, gl_PointCoord) * (fFade * qt_Opacity);
-#endif //COLOR
-#endif //DEFORM
-#endif //TABLE
-#endif //SPRITE
-}
diff --git a/src/declarative/particles/defaultshaders/imagevertex.shader b/src/declarative/particles/defaultshaders/imagevertex.shader
deleted file mode 100644
index 132771a3a4..0000000000
--- a/src/declarative/particles/defaultshaders/imagevertex.shader
+++ /dev/null
@@ -1,131 +0,0 @@
-attribute highp vec2 vPos;
-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 float entry;
-#ifdef COLOR
-attribute lowp vec4 vColor;
-#endif
-#ifdef DEFORM
-attribute highp vec2 vTex;
-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
-#endif
-#ifdef SPRITE
-attribute highp vec4 vAnimData;// interpolate(bool), duration, frameCount (this anim), timestamp (this anim)
-attribute highp vec4 vAnimPos;//sheet x,y, width/height of this anim
-uniform highp vec2 animSheetSize; //width/height of whole sheet
-#endif
-
-uniform highp mat4 qt_Matrix;
-uniform highp float timestamp;
-#ifdef TABLE
-varying lowp vec2 tt;//y is progress if Sprite mode
-uniform highp float sizetable[64];
-uniform highp float opacitytable[64];
-#endif
-#ifdef SPRITE
-varying highp vec4 fTexS;
-#else
-#ifdef DEFORM
-varying highp vec2 fTex;
-#endif
-#endif
-#ifdef COLOR
-varying lowp vec4 fColor;
-#else
-varying lowp float fFade;
-#endif
-
-
-void main() {
-
- highp float t = (timestamp - vData.x) / vData.y;
- if (t < 0. || t > 1.){
-#ifdef DEFORM //Not point sprites
- gl_Position = qt_Matrix * vec4(vPos.x, vPos.y, 0., 1.);
-#else
- gl_PointSize = 0.;
-#endif
- return;
- }
-#ifdef SPRITE
- //Calculate frame location in texture
- highp float frameIndex = mod((((timestamp - vAnimData.w)*1000.)/vAnimData.y),vAnimData.z);
- tt.y = mod((timestamp - vAnimData.w)*1000., vAnimData.y) / vAnimData.y;
-
- frameIndex = floor(frameIndex);
- fTexS.xy = vec2(((frameIndex + vTex.x) * vAnimPos.z / animSheetSize.x), ((vAnimPos.y + vTex.y * vAnimPos.w) / animSheetSize.y));
-
- //Next frame is also passed, for interpolation
- //### Should the next anim be precalculated to allow for interpolation there?
- if(vAnimData.x == 1.0 && frameIndex != vAnimData.z - 1.)//Can't do it for the last frame though, this anim may not loop
- frameIndex = mod(frameIndex+1., vAnimData.z);
- fTexS.zw = vec2(((frameIndex + vTex.x) * vAnimPos.z / animSheetSize.x), ((vAnimPos.y + vTex.y * vAnimPos.w) / animSheetSize.y));
-#else
-#ifdef DEFORM
- fTex = vTex;
-#endif
-#endif
- highp float currentSize = mix(vData.z, vData.w, t * t);
- lowp float fade = 1.;
- highp float fadeIn = min(t * 10., 1.);
- highp float fadeOut = 1. - clamp((t - 0.75) * 4.,0., 1.);
-
-#ifdef TABLE
- currentSize = currentSize * sizetable[int(floor(t*64.))];
- fade = fade * opacitytable[int(floor(t*64.))];
-#endif
-
- if (entry == 1.)
- fade = fade * fadeIn * fadeOut;
- else if(entry == 2.)
- currentSize = currentSize * fadeIn * fadeOut;
-
- if(currentSize <= 0)//Sizes too small look jittery as they move
- currentSize = 0;
- else if(currentSize < 3)
- currentSize = 3;
-
- highp vec2 pos;
-#ifdef DEFORM
- 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 vec4 deform = vDeformVec * currentSize * (vTex.xxyy - 0.5);
- highp vec4 rotatedDeform = deform.xxzz * trigCalcs.xyxy;
- rotatedDeform = rotatedDeform + (deform.yyww * trigCalcs.yxyx * vec4(-1.,1.,-1.,1.));
- /* The readable version:
- 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
- + rotatedDeform.xy
- + rotatedDeform.zw
- + vVec.xy * t * vData.y // apply speed
- + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration
-#else
- pos = vPos
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
- gl_PointSize = currentSize;
-#endif
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
-#ifdef COLOR
- fColor = vColor * fade;
-#else
- fFade = fade;
-#endif
-#ifdef TABLE
- tt.x = t;
-#endif
-}
diff --git a/src/declarative/particles/defaultshaders/simplefragment.shader b/src/declarative/particles/defaultshaders/simplefragment.shader
deleted file mode 100644
index 9b445da52f..0000000000
--- a/src/declarative/particles/defaultshaders/simplefragment.shader
+++ /dev/null
@@ -1,8 +0,0 @@
-uniform sampler2D texture;
-uniform lowp float qt_Opacity;
-
-varying lowp float fFade;
-
-void main() {
- gl_FragColor = texture2D(texture, gl_PointCoord) * (fFade * qt_Opacity);
-}
diff --git a/src/declarative/particles/defaultshaders/simplevertex.shader b/src/declarative/particles/defaultshaders/simplevertex.shader
deleted file mode 100644
index c287e159a5..0000000000
--- a/src/declarative/particles/defaultshaders/simplevertex.shader
+++ /dev/null
@@ -1,39 +0,0 @@
-attribute highp vec2 vPos;
-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 qt_Matrix;
-uniform highp float timestamp;
-uniform highp float entry;
-
-varying lowp float fFade;
-
-void main() {
- highp float t = (timestamp - vData.x) / vData.y;
-
- highp float currentSize = mix(vData.z, vData.w, t * t);
-
- if (t < 0. || t > 1.)
- currentSize = 0.;
-
- fFade = 1.;
-
- if (entry == 1.){
- highp float fadeIn = min(t * 10., 1.);
- highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
- fFade = fadeIn * fadeOut;
- }else if(entry == 2.){
- highp float sizeIn = min(t * 10., 1.);
- highp float sizeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
- currentSize = currentSize * sizeIn * sizeOut;
- }
-
- gl_PointSize = currentSize;
-
- highp vec2 pos = vPos
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
-
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
-}
diff --git a/src/declarative/particles/defaultshaders/spritefragment.shader b/src/declarative/particles/defaultshaders/spritefragment.shader
deleted file mode 100644
index 86002f03fb..0000000000
--- a/src/declarative/particles/defaultshaders/spritefragment.shader
+++ /dev/null
@@ -1,17 +0,0 @@
-uniform sampler2D texture;
-uniform sampler2D colortable;
-uniform sampler2D opacitytable;
-uniform lowp float qt_Opacity;
-
-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 * qt_Opacity);
-}
diff --git a/src/declarative/particles/defaultshaders/spriteimagefragment.shader b/src/declarative/particles/defaultshaders/spriteimagefragment.shader
deleted file mode 100644
index ecd62cf390..0000000000
--- a/src/declarative/particles/defaultshaders/spriteimagefragment.shader
+++ /dev/null
@@ -1,9 +0,0 @@
-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/declarative/particles/defaultshaders/spriteimagevertex.shader b/src/declarative/particles/defaultshaders/spriteimagevertex.shader
deleted file mode 100644
index 27de2ada6a..0000000000
--- a/src/declarative/particles/defaultshaders/spriteimagevertex.shader
+++ /dev/null
@@ -1,52 +0,0 @@
-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/declarative/particles/defaultshaders/spritevertex.shader b/src/declarative/particles/defaultshaders/spritevertex.shader
deleted file mode 100644
index 96ce3454b8..0000000000
--- a/src/declarative/particles/defaultshaders/spritevertex.shader
+++ /dev/null
@@ -1,113 +0,0 @@
-attribute highp vec2 vPos;
-attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
-attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
-#ifdef COLOR
-attribute lowp vec4 vColor;
-#endif
-#ifdef DEFORM
-attribute highp vec2 vTex;
-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
-#endif
-#ifdef SPRITE
-attribute highp vec4 vAnimData;// idx, duration, frameCount (this anim), timestamp (this anim)
-uniform highp float framecount; //maximum of all anims
-uniform highp float animcount;
-#endif
-
-uniform highp mat4 qt_Matrix;
-uniform highp float timestamp;
-#ifdef TABLE
-varying lowp float tt;
-#endif
-#ifdef SPRITE
-varying lowp float progress;
-varying highp vec2 fTexA;
-varying highp vec2 fTexB;
-#elseif DEFORM
-varying highp vec2 fTex;
-#endif
-#ifdef COLOR
-varying lowp vec4 fColor;
-#endif
-
-
-void main() {
-
- highp float t = (timestamp - vData.x) / vData.y;
-#ifdef SPRITE
- //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;
-#endif
-
- highp float currentSize = mix(vData.z, vData.w, t * t);
-
- if (t < 0. || t > 1.)
- currentSize = 0.;
-
- highp vec2 pos;
-#ifdef DEFORM
- 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
-#else
- pos = vPos
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
-#endif
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
-#ifdef COLOR
- fColor = vColor;
-#endif
-#ifdef TABLE
- tt = t;
-#endif
-}
diff --git a/src/declarative/particles/defaultshaders/tabledfragment.shader b/src/declarative/particles/defaultshaders/tabledfragment.shader
deleted file mode 100644
index e92d8050eb..0000000000
--- a/src/declarative/particles/defaultshaders/tabledfragment.shader
+++ /dev/null
@@ -1,23 +0,0 @@
-uniform sampler2D texture;
-uniform sampler2D colortable;
-uniform sampler2D opacitytable;
-uniform sampler2D sizetable;
-uniform lowp float qt_Opacity;
-
-varying highp vec2 fTex;
-varying lowp vec4 fColor;
-varying lowp float tt;
-
-void main() {
- highp vec2 tex = (((fTex - 0.5) / texture2D(sizetable, vec2(tt, 0.5)).w) + 0.5);
- lowp vec4 color;
- if(tex.x < 1.0 && tex.x > 0.0 && tex.y < 1.0 && tex.y > 0.0){//No CLAMP_TO_BORDER in ES2, so have to do it ourselves
- color = texture2D(texture, tex);
- }else{
- color = vec4(0.,0.,0.,0.);
- }
- gl_FragColor = color
- * fColor
- * texture2D(colortable, vec2(tt, 0.5))
- * (texture2D(opacitytable, vec2(tt, 0.5)).w * qt_Opacity);
-}
diff --git a/src/declarative/particles/defaultshaders/tabledvertex.shader b/src/declarative/particles/defaultshaders/tabledvertex.shader
deleted file mode 100644
index ef3c35da82..0000000000
--- a/src/declarative/particles/defaultshaders/tabledvertex.shader
+++ /dev/null
@@ -1,56 +0,0 @@
-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 qt_Matrix;
-uniform highp float timestamp;
-
-varying lowp float tt;
-varying highp vec2 fTex;
-varying lowp float progress;
-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;
- 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 = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
- fColor = vColor;
- tt = t;
-
-}
diff --git a/src/declarative/particles/defaultshaders/noise.png b/src/declarative/particles/particleresources/noise.png
index 3c723e1a5a..3c723e1a5a 100644
--- a/src/declarative/particles/defaultshaders/noise.png
+++ b/src/declarative/particles/particleresources/noise.png
Binary files differ
diff --git a/src/declarative/particles/particles.qrc b/src/declarative/particles/particles.qrc
index db00a57453..344f9489a4 100644
--- a/src/declarative/particles/particles.qrc
+++ b/src/declarative/particles/particles.qrc
@@ -1,11 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>defaultshaders/imagefragment.shader</file>
- <file>defaultshaders/imagevertex.shader</file>
- <file>defaultshaders/spriteimagefragment.shader</file>
- <file>defaultshaders/spriteimagevertex.shader</file>
- <file>defaultshaders/identitytable.png</file>
- <file>defaultshaders/defaultFadeInOut.png</file>
- <file>defaultshaders/noise.png</file>
+ <file>particleresources/noise.png</file>
</qresource>
</RCC>
diff --git a/src/declarative/particles/qsgimageparticle.cpp b/src/declarative/particles/qsgimageparticle.cpp
index 3646506980..d219fc3df8 100644
--- a/src/declarative/particles/qsgimageparticle.cpp
+++ b/src/declarative/particles/qsgimageparticle.cpp
@@ -66,6 +66,186 @@ DEFINE_BOOL_CONFIG_OPTION(qmlParticlesDebug, QML_PARTICLES_DEBUG)
//TODO: Make it larger on desktop? Requires fixing up shader code with the same define
#define UNIFORM_ARRAY_SIZE 64
+static const char vertexShaderCode[] =
+ "attribute highp vec2 vPos;\n"
+ "attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize\n"
+ "attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration\n"
+ "uniform highp float entry;\n"
+ "#ifdef COLOR\n"
+ "attribute lowp vec4 vColor;\n"
+ "#endif\n"
+ "#ifdef DEFORM\n"
+ "attribute highp vec2 vTex;\n"
+ "attribute highp vec4 vDeformVec; //x,y x unit vector; z,w = y unit vector\n"
+ "attribute highp vec3 vRotation; //x = radians of rotation, y=rotation speed, z= bool autoRotate\n"
+ "#endif\n"
+ "#ifdef SPRITE\n"
+ "attribute highp vec4 vAnimData;// interpolate(bool), duration, frameCount (this anim), timestamp (this anim)\n"
+ "attribute highp vec4 vAnimPos;//sheet x,y, width/height of this anim\n"
+ "uniform highp vec2 animSheetSize; //width/height of whole sheet\n"
+ "#endif\n"
+ "\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "uniform highp float timestamp;\n"
+ "#ifdef TABLE\n"
+ "varying lowp vec2 tt;//y is progress if Sprite mode\n"
+ "uniform highp float sizetable[64];\n"
+ "uniform highp float opacitytable[64];\n"
+ "#endif\n"
+ "#ifdef SPRITE\n"
+ "varying highp vec4 fTexS;\n"
+ "#else\n"
+ "#ifdef DEFORM\n"
+ "varying highp vec2 fTex;\n"
+ "#endif\n"
+ "#endif\n"
+ "#ifdef COLOR\n"
+ "varying lowp vec4 fColor;\n"
+ "#else\n"
+ "varying lowp float fFade;\n"
+ "#endif\n"
+ "\n"
+ "\n"
+ "void main() {\n"
+ "\n"
+ " highp float t = (timestamp - vData.x) / vData.y;\n"
+ " if (t < 0. || t > 1.){\n"
+ "#ifdef DEFORM //Not point sprites\n"
+ " gl_Position = qt_Matrix * vec4(vPos.x, vPos.y, 0., 1.);\n"
+ "#else\n"
+ " gl_PointSize = 0.;\n"
+ "#endif\n"
+ " return;\n"
+ " }\n"
+ "#ifdef SPRITE\n"
+ " //Calculate frame location in texture\n"
+ " highp float frameIndex = mod((((timestamp - vAnimData.w)*1000.)/vAnimData.y),vAnimData.z);\n"
+ " tt.y = mod((timestamp - vAnimData.w)*1000., vAnimData.y) / vAnimData.y;\n"
+ "\n"
+ " frameIndex = floor(frameIndex);\n"
+ " fTexS.xy = vec2(((frameIndex + vTex.x) * vAnimPos.z / animSheetSize.x), ((vAnimPos.y + vTex.y * vAnimPos.w) / animSheetSize.y));\n"
+ "\n"
+ " //Next frame is also passed, for interpolation\n"
+ " //### Should the next anim be precalculated to allow for interpolation there?\n"
+ " if (vAnimData.x == 1.0 && frameIndex != vAnimData.z - 1.)//Can't do it for the last frame though, this anim may not loop\n"
+ " frameIndex = mod(frameIndex+1., vAnimData.z);\n"
+ " fTexS.zw = vec2(((frameIndex + vTex.x) * vAnimPos.z / animSheetSize.x), ((vAnimPos.y + vTex.y * vAnimPos.w) / animSheetSize.y));\n"
+ "#else\n"
+ "#ifdef DEFORM\n"
+ " fTex = vTex;\n"
+ "#endif\n"
+ "#endif\n"
+ " highp float currentSize = mix(vData.z, vData.w, t * t);\n"
+ " lowp float fade = 1.;\n"
+ " highp float fadeIn = min(t * 10., 1.);\n"
+ " highp float fadeOut = 1. - clamp((t - 0.75) * 4.,0., 1.);\n"
+ "\n"
+ "#ifdef TABLE\n"
+ " currentSize = currentSize * sizetable[int(floor(t*64.))];\n"
+ " fade = fade * opacitytable[int(floor(t*64.))];\n"
+ "#endif\n"
+ "\n"
+ " if (entry == 1.)\n"
+ " fade = fade * fadeIn * fadeOut;\n"
+ " else if (entry == 2.)\n"
+ " currentSize = currentSize * fadeIn * fadeOut;\n"
+ "\n"
+ " if (currentSize <= 0)//Sizes too small look jittery as they move\n"
+ " currentSize = 0;\n"
+ " else if (currentSize < 3)\n"
+ " currentSize = 3;\n"
+ "\n"
+ " highp vec2 pos;\n"
+ "#ifdef DEFORM\n"
+ " highp float rotation = vRotation.x + vRotation.y * t * vData.y;\n"
+ " if (vRotation.z == 1.0){\n"
+ " highp vec2 curVel = vVec.zw * t * vData.y + vVec.xy;\n"
+ " rotation += atan(curVel.y, curVel.x);\n"
+ " }\n"
+ " highp vec2 trigCalcs = vec2(cos(rotation), sin(rotation));\n"
+ " highp vec4 deform = vDeformVec * currentSize * (vTex.xxyy - 0.5);\n"
+ " highp vec4 rotatedDeform = deform.xxzz * trigCalcs.xyxy;\n"
+ " rotatedDeform = rotatedDeform + (deform.yyww * trigCalcs.yxyx * vec4(-1.,1.,-1.,1.));\n"
+ " /* The readable version:\n"
+ " highp vec2 xDeform = vDeformVec.xy * currentSize * (vTex.x-0.5);\n"
+ " highp vec2 yDeform = vDeformVec.zw * currentSize * (vTex.y-0.5);\n"
+ " highp vec2 xRotatedDeform;\n"
+ " xRotatedDeform.x = trigCalcs.x*xDeform.x - trigCalcs.y*xDeform.y;\n"
+ " xRotatedDeform.y = trigCalcs.y*xDeform.x + trigCalcs.x*xDeform.y;\n"
+ " highp vec2 yRotatedDeform;\n"
+ " yRotatedDeform.x = trigCalcs.x*yDeform.x - trigCalcs.y*yDeform.y;\n"
+ " yRotatedDeform.y = trigCalcs.y*yDeform.x + trigCalcs.x*yDeform.y;\n"
+ " */\n"
+ " pos = vPos\n"
+ " + rotatedDeform.xy\n"
+ " + rotatedDeform.zw\n"
+ " + vVec.xy * t * vData.y // apply speed\n"
+ " + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration\n"
+ "#else\n"
+ " pos = vPos\n"
+ " + vVec.xy * t * vData.y // apply speed vector..\n"
+ " + 0.5 * vVec.zw * pow(t * vData.y, 2.);\n"
+ " gl_PointSize = currentSize;\n"
+ "#endif\n"
+ " gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);\n"
+ "\n"
+ "#ifdef COLOR\n"
+ " fColor = vColor * fade;\n"
+ "#else\n"
+ " fFade = fade;\n"
+ "#endif\n"
+ "#ifdef TABLE\n"
+ " tt.x = t;\n"
+ "#endif\n"
+ "}\n";
+
+static const char fragmentShaderCode[] =
+ "uniform sampler2D texture;\n"
+ "uniform lowp float qt_Opacity;\n"
+ "\n"
+ "#ifdef SPRITE\n"
+ "varying highp vec4 fTexS;\n"
+ "#else\n"
+ "#ifdef DEFORM //First non-pointsprite\n"
+ "varying highp vec2 fTex;\n"
+ "#endif\n"
+ "#endif\n"
+ "#ifdef COLOR\n"
+ "varying lowp vec4 fColor;\n"
+ "#else\n"
+ "varying lowp float fFade;\n"
+ "#endif\n"
+ "#ifdef TABLE\n"
+ "varying lowp vec2 tt;\n"
+ "uniform sampler2D colortable;\n"
+ "#endif\n"
+ "\n"
+ "void main() {\n"
+ "#ifdef SPRITE\n"
+ " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), tt.y)\n"
+ " * fColor\n"
+ " * texture2D(colortable, tt)\n"
+ " * qt_Opacity;\n"
+ "#else\n"
+ "#ifdef TABLE\n"
+ " gl_FragColor = texture2D(texture, fTex)\n"
+ " * fColor\n"
+ " * texture2D(colortable, tt)\n"
+ " * qt_Opacity;\n"
+ "#else\n"
+ "#ifdef DEFORM\n"
+ " gl_FragColor = (texture2D(texture, fTex)) * fColor * qt_Opacity;\n"
+ "#else\n"
+ "#ifdef COLOR\n"
+ " gl_FragColor = (texture2D(texture, gl_PointCoord)) * fColor * qt_Opacity;\n"
+ "#else\n"
+ " gl_FragColor = texture2D(texture, gl_PointCoord) * (fFade * qt_Opacity);\n"
+ "#endif //COLOR\n"
+ "#endif //DEFORM\n"
+ "#endif //TABLE\n"
+ "#endif //SPRITE\n"
+ "}\n";
+
const qreal CONV = 0.017453292519943295;
class ImageMaterialData
{
@@ -89,7 +269,6 @@ class ImageMaterialData
QSizeF animSheetSize;
};
-//TODO: Move shaders inline once they've stablilized
class TabledMaterialData : public ImageMaterialData {};
class TabledMaterial : public QSGSimpleMaterialShader<TabledMaterialData>
{
@@ -98,17 +277,13 @@ class TabledMaterial : public QSGSimpleMaterialShader<TabledMaterialData>
public:
TabledMaterial()
{
- QFile vf(QStringLiteral(":defaultshaders/imagevertex.shader"));
- vf.open(QFile::ReadOnly);
m_vertex_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define TABLE\n#define DEFORM\n#define COLOR\n")
- + vf.readAll();
+ + vertexShaderCode;
- QFile ff(QStringLiteral(":defaultshaders/imagefragment.shader"));
- ff.open(QFile::ReadOnly);
m_fragment_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define TABLE\n#define DEFORM\n#define COLOR\n")
- + ff.readAll();
+ + fragmentShaderCode;
Q_ASSERT(!m_vertex_code.isNull());
Q_ASSERT(!m_fragment_code.isNull());
@@ -164,17 +339,13 @@ class DeformableMaterial : public QSGSimpleMaterialShader<DeformableMaterialData
public:
DeformableMaterial()
{
- QFile vf(QStringLiteral(":defaultshaders/imagevertex.shader"));
- vf.open(QFile::ReadOnly);
m_vertex_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define DEFORM\n#define COLOR\n")
- + vf.readAll();
+ + vertexShaderCode;
- QFile ff(QStringLiteral(":defaultshaders/imagefragment.shader"));
- ff.open(QFile::ReadOnly);
m_fragment_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define DEFORM\n#define COLOR\n")
- + ff.readAll();
+ + fragmentShaderCode;
Q_ASSERT(!m_vertex_code.isNull());
Q_ASSERT(!m_fragment_code.isNull());
@@ -220,17 +391,13 @@ class SpriteMaterial : public QSGSimpleMaterialShader<SpriteMaterialData>
public:
SpriteMaterial()
{
- QFile vf(QStringLiteral(":defaultshaders/imagevertex.shader"));
- vf.open(QFile::ReadOnly);
m_vertex_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define SPRITE\n#define TABLE\n#define DEFORM\n#define COLOR\n")
- + vf.readAll();
+ + vertexShaderCode;
- QFile ff(QStringLiteral(":defaultshaders/imagefragment.shader"));
- ff.open(QFile::ReadOnly);
m_fragment_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define SPRITE\n#define TABLE\n#define DEFORM\n#define COLOR\n")
- + ff.readAll();
+ + fragmentShaderCode;
Q_ASSERT(!m_vertex_code.isNull());
Q_ASSERT(!m_fragment_code.isNull());
@@ -290,17 +457,13 @@ class ColoredMaterial : public QSGSimpleMaterialShader<ColoredMaterialData>
public:
ColoredMaterial()
{
- QFile vf(QStringLiteral(":defaultshaders/imagevertex.shader"));
- vf.open(QFile::ReadOnly);
m_vertex_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define COLOR\n")
- + vf.readAll();
+ + vertexShaderCode;
- QFile ff(QStringLiteral(":defaultshaders/imagefragment.shader"));
- ff.open(QFile::ReadOnly);
m_fragment_code = QByteArray(SHADER_DEFINES)
+ QByteArray("#define COLOR\n")
- + ff.readAll();
+ + fragmentShaderCode;
Q_ASSERT(!m_vertex_code.isNull());
Q_ASSERT(!m_fragment_code.isNull());
@@ -361,15 +524,11 @@ class SimpleMaterial : public QSGSimpleMaterialShader<SimpleMaterialData>
public:
SimpleMaterial()
{
- QFile vf(QStringLiteral(":defaultshaders/imagevertex.shader"));
- vf.open(QFile::ReadOnly);
m_vertex_code = QByteArray(SHADER_DEFINES)
- + vf.readAll();
+ + vertexShaderCode;
- QFile ff(QStringLiteral(":defaultshaders/imagefragment.shader"));
- ff.open(QFile::ReadOnly);
m_fragment_code = QByteArray(SHADER_DEFINES)
- + ff.readAll();
+ + fragmentShaderCode;
Q_ASSERT(!m_vertex_code.isNull());
Q_ASSERT(!m_fragment_code.isNull());
@@ -473,6 +632,9 @@ void fillUniformArrayFromImage(float* array, const QImage& img, int size)
\qmlproperty list<Sprite> QtQuick.Particles2::ImageParticle::sprites
The sprite or sprites used to draw this particle.
+
+ Note that the sprite image will be scaled to a square based on the size of
+ the particle being rendered.
*/
/*!
\qmlproperty url QtQuick.Particles2::ImageParticle::colorTable
@@ -1135,8 +1297,10 @@ QSGGeometryNode* QSGImageParticle::buildParticleNodes()
colortable = QImage(m_colortable_name.toLocalFile());
sizetable = QImage(m_sizetable_name.toLocalFile());
opacitytable = QImage(m_opacitytable_name.toLocalFile());
- if (colortable.isNull())
- colortable = QImage(QStringLiteral(":defaultshaders/identitytable.png"));
+ if (colortable.isNull()){
+ colortable = QImage(1,1,QImage::Format_ARGB32);
+ colortable.fill(Qt::white);
+ }
Q_ASSERT(!colortable.isNull());
getState<ImageMaterialData>(m_material)->colorTable = QSGPlainTexture::fromImage(colortable);
fillUniformArrayFromImage(getState<ImageMaterialData>(m_material)->sizeTable, sizetable, UNIFORM_ARRAY_SIZE);
diff --git a/src/declarative/particles/qsgturbulence.cpp b/src/declarative/particles/qsgturbulence.cpp
index 1cac833170..30d36cccb9 100644
--- a/src/declarative/particles/qsgturbulence.cpp
+++ b/src/declarative/particles/qsgturbulence.cpp
@@ -140,7 +140,7 @@ void QSGTurbulenceAffector::initializeGrid()
if (!m_noiseSource.isEmpty())
image = QImage(m_noiseSource.toLocalFile()).scaled(QSize(m_gridSize, m_gridSize));
if (image.isNull())
- image = QImage(QStringLiteral(":defaultshaders/noise.png")).scaled(QSize(m_gridSize, m_gridSize));
+ image = QImage(QStringLiteral(":particleresources/noise.png")).scaled(QSize(m_gridSize, m_gridSize));
for (int i=0; i<m_gridSize; i++)
for (int j=0; j<m_gridSize; j++)