 }
 
 Fragment brush_fs() {
-    vec4 Cs = texture(sColor0, vUv);
+    vec2 base_uv = vUv.xy * gl_FragCoord.w;
+    vec4 Cs = texture(sColor0, vec3(base_uv, vUv.z));
 
     if (Cs.a == 0.0) {
         return Fragment(vec4(0.0)); // could also `discard`

    vec2 uv = snap_device_pos(vi) +
        src_task.common_data.task_rect.p0 -
        src_task.content_origin;
    vUv = vec3(uv / texture_size, src_task.common_data.texture_layer_index);

    vec2 uv0 = src_task.common_data.task_rect.p0;
    vec2 uv1 = uv0 + src_task.common_data.task_rect.size;


    // Fail-safe to ensure that we don't sample outside the rendered
    // portion of a blend source.
    alpha *= point_inside_rect(base_uv, vUvClipBounds.xy, vUvClipBounds.zw);

    // Pre-multiply the alpha into the output value.
    return Fragment(alpha * vec4(color, 1.0));
