aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/particles/defaultshaders
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-08-23 18:20:58 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-24 10:11:29 +0200
commit017265b9383cbd616aaa2f5fee17dae8e28a161b (patch)
tree49e45cd13a00f0ccf2c3641b1256dd3d2904842b /src/declarative/particles/defaultshaders
parente6c0633a9c386817017a97dac9e541a45f42fd7f (diff)
Switch from textures to uniform arrays for size/opacity tables
Change-Id: Iafc5eaa80f68345cc3b14fe0b2d997c1af435419 Reviewed-on: http://codereview.qt.nokia.com/3388 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/declarative/particles/defaultshaders')
-rw-r--r--src/declarative/particles/defaultshaders/imagefragment.shader15
-rw-r--r--src/declarative/particles/defaultshaders/imagevertex.shader6
2 files changed, 9 insertions, 12 deletions
diff --git a/src/declarative/particles/defaultshaders/imagefragment.shader b/src/declarative/particles/defaultshaders/imagefragment.shader
index 5286c8519a..c2341fe6ff 100644
--- a/src/declarative/particles/defaultshaders/imagefragment.shader
+++ b/src/declarative/particles/defaultshaders/imagefragment.shader
@@ -16,8 +16,6 @@ varying lowp float fFade;
#ifdef TABLE
varying lowp vec2 tt;
uniform sampler2D colortable;
-uniform sampler2D opacitytable;
-uniform sampler2D sizetable;
#endif
void main() {
@@ -25,20 +23,13 @@ void main() {
gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), tt.y)
* fColor
* texture2D(colortable, tt)
- * (texture2D(opacitytable, tt).w * qt_Opacity);
+ * qt_Opacity;
#else
#ifdef TABLE
- highp vec2 tex = (((fTex - 0.5) / texture2D(sizetable, tt).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);//TODO: Replace with uniform array in vertex shader
- }else{
- color = vec4(0.,0.,0.,0.);
- }
- gl_FragColor = color
+ gl_FragColor = texture2D(texture, fTex)
* fColor
* texture2D(colortable, tt)
- * (texture2D(opacitytable,tt).w * qt_Opacity);
+ * qt_Opacity;
#else
#ifdef DEFORM
gl_FragColor = (texture2D(texture, fTex)) * fColor * qt_Opacity;
diff --git a/src/declarative/particles/defaultshaders/imagevertex.shader b/src/declarative/particles/defaultshaders/imagevertex.shader
index a572d73050..e1033c9165 100644
--- a/src/declarative/particles/defaultshaders/imagevertex.shader
+++ b/src/declarative/particles/defaultshaders/imagevertex.shader
@@ -20,6 +20,8 @@ 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;
@@ -69,6 +71,10 @@ void main() {
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 = fadeIn * fadeOut;
else if(entry == 2.)