xxxxxxxxxx
24
precision mediump float;
// Pixel position
varying vec2 pos;
// Uniforms set by filterShader
uniform sampler2D filter_background; // contains the image being filtered
uniform vec2 filter_res; // contains the image resolution in pixels
void main() {
// Read colour from image
vec4 col = texture2D(filter_background, pos);
// Average the rgb channels
float avg = (col.r + col.g + col.b)/3.;
// Output the average for rgb, with original alpha
gl_FragColor = vec4(avg, avg, avg, col.a);
}