#version 330 core

uniform sampler2D texture;
uniform sampler2D shadow;

in struct
{
	vec2 uv0;
	vec2 uv1;
    vec2 sz;
	float blend;
	vec4 color;
}fInfo;

out vec4 fragColor;

void main()
{
    vec4 mv = texture2D(shadow, fInfo.uv0)-vec4(0.5);
    
    vec2 o0 = mv.rg*(1.0-fInfo.blend);
    o0 *= fInfo.sz/2;
    
    vec2 o1 = mv.ba*(fInfo.blend);
    o1 *= fInfo.sz/2;
    
    vec4 f0 = texture2D(texture, fInfo.uv0+o0);
    vec4 f1 = texture2D(texture, fInfo.uv1+o1);

    fragColor = mix(f1, f0, fInfo.blend*fInfo.blend) *fInfo.color;
}