2011-02-17 17:44:52 +00:00
|
|
|
uniform sampler2D sampler;
|
2007-04-29 17:35:43 +00:00
|
|
|
uniform sampler2D startOffsetTexture;
|
|
|
|
uniform sampler2D endOffsetTexture;
|
|
|
|
uniform float factor;
|
|
|
|
uniform float scale;
|
2011-06-17 17:37:19 +00:00
|
|
|
uniform vec2 windowSize;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
const float regionTexSize = 512.0;
|
|
|
|
|
2011-01-07 19:44:50 +00:00
|
|
|
varying vec2 varyingTexCoords;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
vec2 getOffset(sampler2D texture, vec2 pos)
|
|
|
|
{
|
|
|
|
return (texture2D(texture, pos / regionTexSize).xy - 0.5) / (5.0 / 256.0);
|
|
|
|
}
|
|
|
|
|
2011-01-07 19:44:50 +00:00
|
|
|
vec2 pix2tex( vec2 pix )
|
|
|
|
{
|
2011-06-17 17:37:19 +00:00
|
|
|
return pix/windowSize;
|
2011-01-07 19:44:50 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
// Original (unscaled) position in pixels
|
2011-02-10 19:15:23 +00:00
|
|
|
// ### FIXME: Use a custom vertex shader that outputs the untransformed texcoords
|
2011-06-17 17:37:19 +00:00
|
|
|
vec2 origpos = varyingTexCoords * windowSize;
|
2007-04-29 17:35:43 +00:00
|
|
|
// Position in pixels on the scaled window
|
|
|
|
vec2 pos = origpos * scale;
|
|
|
|
// Start/end position of current region
|
|
|
|
vec2 rstart = origpos + getOffset(startOffsetTexture, origpos);
|
|
|
|
vec2 rend = origpos + getOffset(endOffsetTexture, origpos);
|
|
|
|
float alpha = texture2D(startOffsetTexture, origpos / regionTexSize).b;
|
|
|
|
// Distance from the start of the region
|
|
|
|
vec2 dist = pos - rstart*scale;
|
2011-01-07 19:44:50 +00:00
|
|
|
#if 0
|
|
|
|
// crashes kwin on nouveau
|
2007-04-29 17:35:43 +00:00
|
|
|
if(any(greaterThan(dist, rend-rstart)))
|
|
|
|
discard;//alpha = 0.0;
|
2011-01-07 19:44:50 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-07 19:44:50 +00:00
|
|
|
vec2 transformedtexcoord = pix2tex(rstart + dist);
|
2011-02-17 17:44:52 +00:00
|
|
|
vec3 tex = texture2D(sampler, transformedtexcoord).rgb;
|
2007-04-29 17:35:43 +00:00
|
|
|
#if 0
|
|
|
|
// ATM we ignore custom opacity values because Fade effect fades out the
|
|
|
|
// window which results in the explosion being way too quick. Once there's
|
|
|
|
// a way to suppress Fade effect when ExplosionEffect is active, we can
|
|
|
|
// use the custom opacity again
|
|
|
|
gl_FragColor = vec4(tex, (1.0 - factor*factor) * alpha * opacity);
|
|
|
|
#else
|
|
|
|
gl_FragColor = vec4(tex, (1.0 - factor*factor) * alpha);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|