2010-12-31 09:34:29 +00:00
|
|
|
uniform sampler2D sample;
|
|
|
|
uniform vec4 u_capColor;
|
|
|
|
uniform float u_opacity;
|
2010-12-31 09:53:12 +00:00
|
|
|
uniform int u_mirror;
|
2010-12-31 09:34:29 +00:00
|
|
|
|
|
|
|
varying vec2 varyingTexCoords;
|
|
|
|
|
2010-12-31 09:53:12 +00:00
|
|
|
vec2 mirrorTex(vec2 coords) {
|
|
|
|
vec2 mirrored = coords;
|
|
|
|
if (u_mirror != 0) {
|
|
|
|
mirrored.t = mirrored.t * (-1.0) + 1.0;
|
|
|
|
}
|
|
|
|
return mirrored;
|
|
|
|
}
|
|
|
|
|
2010-12-31 09:34:29 +00:00
|
|
|
void main() {
|
|
|
|
vec4 color = u_capColor;
|
2010-12-31 09:53:12 +00:00
|
|
|
vec2 texCoord = mirrorTex(varyingTexCoords);
|
|
|
|
vec4 tex = texture2D(sample, texCoord);
|
|
|
|
if (texCoord.s < 0.0 || texCoord.s > 1.0 ||
|
|
|
|
texCoord.t < 0.0 || texCoord.t > 1.0) {
|
2010-12-31 09:34:29 +00:00
|
|
|
tex = u_capColor;
|
|
|
|
}
|
|
|
|
color.rgb = tex.rgb*tex.a + color.rgb*(1.0-tex.a);
|
|
|
|
color.a = u_opacity;
|
|
|
|
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|