uniform float velocity;

const vec2 JITTER_OFFSETS[8] = vec2[](
                               vec2( 0.125, -0.375),
                               vec2(-0.125,  0.375),
                               vec2( 0.625,  0.125),
                               vec2( 0.375, -0.625),
                               vec2(-0.625,  0.625),
                               vec2(-0.875, -0.125),
                               vec2( 0.375, -0.875),
                               vec2( 0.875,  0.875)
);

vec2 TAAJitter(vec2 coord, float w) {
    vec2 offset = JITTER_OFFSETS[int(mod(frameCounter, 8))] * (w / vec2(viewWidth, viewHeight));
    float factor = Max0(1.0 - velocity * 400.0) * 0.125;
    offset *= factor;
    return coord + offset;
}