#version 130

uniform sampler2D image;

uniform sampler2D uvs0;
uniform sampler2D uvs1;
uniform sampler2D uvs2;

uniform float w0;
uniform float w1;
uniform float w2;

uniform vec2 size;

out vec4 fragColor;

void main()
{
  vec2 p = gl_FragCoord.xy-vec2(0.5,0.5);
  fragColor = (w0*texture2D(image,texture2D(uvs0,p/size).rg/size).rgba+
               w1*texture2D(image,texture2D(uvs1,p/size).rg/size).rgba+
               w2*texture2D(image,texture2D(uvs2,p/size).rg/size).rgba); //XXX: half-pixel offset!
}
