#version 120
varying vec2 texCoord;
//varying vec4 vColor;
uniform sampler2D colorMap;

/*
void main (void)
{
	gl_FragColor = texture2D(colorMap, texCoord);
}
*/

void main (void)
{
    vec4 pixel;
    vec4 accum;
    pixel=texture2D(colorMap, texCoord);
    float i1=pixel.r*-150;
    float i2=pixel.r*150;
    float a1=pixel.r*300;
    for (float i=i1;i<i2;i++){
        vec2 offset=vec2(texCoord.x+i*1.0f/1980.0f,texCoord.y);
        offset.x=clamp(offset.x,0.0f,1.0f);
        pixel=texture2D(colorMap, offset);
        accum+=pixel;
    }
    accum/=a1;
//vec2 nutexcoord;
//	nutexcoord=texCoord;
//	nutexcoord.x=1.0-nutexcoord.x;

	//gl_FragColor = texture2D(colorMap, texCoord);
	gl_FragColor = accum;

	//gl_FragColor = texture2D(colorMap, texCoord)*vColor;
	//gl_FragColor = texture2D(colorMap, nutexcoord);
}
