 
         vec2 offset = vOffsetScale * (float(i) + gauss_ratio);
 
-        vec2 st0 = max(vUv - offset, vUvRect.xy);
-        vec2 st1 = min(vUv + offset, vUvRect.zw);
-        avg_color += (SAMPLE_TEXTURE(st0) + SAMPLE_TEXTURE(st1)) *
-                     gauss_coefficient_subtotal;
+        vec2 st0 = clamp(vUv.xy - offset, vUvRect.xy, vUvRect.zw);
+        avg_color += SAMPLE_TEXTURE(vec3(st0, vUv.z)) * gauss_coefficient_subtotal;
+
+        vec2 st1 = clamp(vUv.xy + offset, vUvRect.xy, vUvRect.zw);
+        avg_color += SAMPLE_TEXTURE(vec3(st1, vUv.z)) * gauss_coefficient_subtotal;
+
+        gauss_coefficient_total += 2.0 * gauss_coefficient_subtotal;
+        gauss_coefficient.xy *= gauss_coefficient.yz;
     }
 
-    oFragColor = vec4(avg_color);
+    oFragColor = vec4(avg_color) / gauss_coefficient_total;
 }
 #endif

    // Equation 1 with a single texture lookup.

    for (int i = 1; i <= vSupport; i += 2) {
        gauss_coefficient.xy *= gauss_coefficient.yz;

        float gauss_coefficient_subtotal = gauss_coefficient.x;
        gauss_coefficient.xy *= gauss_coefficient.yz;
        gauss_coefficient_subtotal += gauss_coefficient.x;

    return task;
}

void main(void) {
    BlurTask blur_task = fetch_blur_task(aBlurRenderTaskAddress);
    RenderTaskCommonData src_task = fetch_render_task_common_data(aBlurSourceTaskAddress);
