/* RENDERTARGETS: 0 */

uniform sampler2D colortex0;  // Your main game scene
uniform sampler2D colortex11; // The horizontally smudged light
uniform float viewWidth;
uniform float viewHeight;

varying vec2 texcoord;

const float weights[5] = float[5](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);

void main() {
    vec2 texelSize = 1.0 / vec2(viewWidth, viewHeight);
    
    vec3 verticalBlur = texture2D(colortex11, texcoord).rgb * weights[0];
    
    // The Vertical Blur Loop
    for(int i = 1; i < 5; i++) {
        // Multiply by 3.0 to match the horizontal spread!
        vec2 offset = vec2(0.0, texelSize.y * float(i) * 3.0); 
        
        verticalBlur += texture2D(colortex11, texcoord + offset).rgb * weights[i];
        verticalBlur += texture2D(colortex11, texcoord - offset).rgb * weights[i];
    }
    
    vec3 sceneColor = texture2D(colortex0, texcoord).rgb;
    
    // Add the smooth light directly over the scene
    vec3 finalColor = sceneColor + verticalBlur;
    
    gl_FragData[0] = vec4(finalColor, 1.0);
}