1 uniform sampler2D winTexture;
2 uniform sampler2D startOffsetTexture;
3 uniform sampler2D endOffsetTexture;
7 const float regionTexSize = 512.0;
10 vec2 getOffset(sampler2D texture, vec2 pos)
12 return (texture2D(texture, pos / regionTexSize).xy - 0.5) / (5.0 / 256.0);
17 // Original (unscaled) position in pixels
18 vec2 origpos = gl_TexCoord[0].xy;
19 // Position in pixels on the scaled window
20 vec2 pos = origpos * scale;
21 // Start/end position of current region
22 vec2 rstart = origpos + getOffset(startOffsetTexture, origpos);
23 vec2 rend = origpos + getOffset(endOffsetTexture, origpos);
24 float alpha = texture2D(startOffsetTexture, origpos / regionTexSize).b;
25 // Distance from the start of the region
26 vec2 dist = pos - rstart*scale;
27 if(any(greaterThan(dist, rend-rstart)))
28 discard;//alpha = 0.0;
30 vec4 transformedtexcoord = vec4(rstart + dist, vec2(1.0)) * gl_TextureMatrix[0];
31 vec3 tex = texture2D(winTexture, transformedtexcoord.xy).rgb;
33 // ATM we ignore custom opacity values because Fade effect fades out the
34 // window which results in the explosion being way too quick. Once there's
35 // a way to suppress Fade effect when ExplosionEffect is active, we can
36 // use the custom opacity again
37 gl_FragColor = vec4(tex, (1.0 - factor*factor) * alpha * opacity);
39 gl_FragColor = vec4(tex, (1.0 - factor*factor) * alpha);