run method
Returns linear RGBA for attachment zero. Null discards the fragment.
Implementation
@override
Vector4? run(Float32List v, ShaderBindings b, FragmentContext c) {
final target = b.vec4('VelocityInfo', 'target', Vector4.zero());
final surface = b.textures['surface_texture'];
if (surface == null) return null;
// `FragCoordFromTop`.
final y = target.z > 0.0 ? target.z - c.coord.y : c.coord.y;
final stored = surface.sample(c.coord.x * target.x, y * target.y).w;
if (stored <= 0.0 || v[8] > stored * (1.0 + target.w) + 1e-3) return null;
if (v[7] <= 0.0) return Vector4(0.0, 0.0, 0.0, 1.0);
final nowU = v[0] / v[3] * 0.5 + 0.5;
final nowV = 0.5 - v[1] / v[3] * 0.5;
final thenU = v[4] / v[7] * 0.5 + 0.5;
final thenV = 0.5 - v[5] / v[7] * 0.5;
return Vector4(nowU - thenU, nowV - thenV, 0.0, 1.0);
}