2011-01-09 20:20:36 +00:00
|
|
|
uniform sampler2D sample;
|
2009-04-27 11:35:35 +00:00
|
|
|
uniform float textureWidth;
|
|
|
|
uniform float textureHeight;
|
2008-07-15 19:21:50 +00:00
|
|
|
uniform float opacity;
|
2009-04-20 11:07:47 +00:00
|
|
|
uniform float brightness;
|
|
|
|
uniform float saturation;
|
2011-01-09 20:20:36 +00:00
|
|
|
|
|
|
|
varying vec2 varyingTexCoords;
|
2008-07-15 19:21:50 +00:00
|
|
|
|
|
|
|
vec2 pix2tex(vec2 pix)
|
|
|
|
{
|
2009-04-27 11:35:35 +00:00
|
|
|
return vec2(pix.x / textureWidth, pix.y / textureHeight);
|
2008-07-15 19:21:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2011-01-09 20:20:36 +00:00
|
|
|
vec4 tex = texture2D(sample, pix2tex(varyingTexCoords));
|
|
|
|
if( saturation != 1.0 )
|
2009-02-22 10:58:26 +00:00
|
|
|
{
|
2011-01-09 20:20:36 +00:00
|
|
|
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
|
|
|
|
desaturated = vec3( dot( desaturated, tex.rgb ));
|
|
|
|
tex.rgb = tex.rgb * vec3( saturation ) + desaturated * vec3( 1.0 - saturation );
|
2009-02-22 10:58:26 +00:00
|
|
|
}
|
2011-01-09 20:20:36 +00:00
|
|
|
// tex.rgb = tex.rgb * opacity * brightness;
|
|
|
|
// tex.a = tex.a * opacity;
|
|
|
|
gl_FragColor = tex;
|
2008-07-15 19:21:50 +00:00
|
|
|
}
|