run method
Returns linear RGBA for attachment zero. Null discards the fragment.
Implementation
@override
Vector4? run(Float32List v, ShaderBindings b, FragmentContext c) {
final src = bloomSource(b);
if (src == null) return Vector4(0.0, 0.0, 0.0, 1.0);
final u = v[0];
final w = v[1];
Vector3 at(double dx, double dy) {
final t = src.source.sample(u + dx * src.tx, w + dy * src.ty);
return Vector3(t.x, t.y, t.z);
}
final a = at(-2, 2), bb = at(0, 2), cc = at(2, 2);
final d = at(-2, 0), e = at(0, 0), f = at(2, 0);
final g = at(-2, -2), h = at(0, -2), i = at(2, -2);
final j = at(-1, 1), k = at(1, 1), l = at(-1, -1), m = at(1, -1);
// The inner four boxes carry half the weight between them; the five outer
// ones share the rest.
final result = (j + k + l + m) * (0.5 * 0.25);
result.add((a + bb + d + e) * (0.125 * 0.25));
result.add((bb + cc + e + f) * (0.125 * 0.25));
result.add((d + e + g + h) * (0.125 * 0.25));
result.add((e + f + h + i) * (0.125 * 0.25));
return Vector4(result.x, result.y, result.z, 1.0);
}