run method

  1. @override
Vector4? run(
  1. Float32List v,
  2. ShaderBindings b,
  3. FragmentContext c
)
override

Returns linear RGBA for attachment zero. Null discards the fragment.

Implementation

@override
Vector4? run(Float32List v, ShaderBindings b, FragmentContext c) {
  final cx = v[4] * 2.0 - 1.0;
  final cy = v[5] * 2.0 - 1.0;
  final radius = math.sqrt(cx * cx + cy * cy);
  final falloff = 1.0 - smoothstep(0.0, 1.0, radius);
  final intensity =
      falloff *
      falloff *
      (soft ? softParticleFade(b, c, v[6], v[7], v[8]) : 1.0);

  final fogged = fogTransmittance(b, v[6], v[7], v[8]);

  final scale = v[3] * intensity * fogged;
  // Alpha one with the colour premultiplied: these draw additively, so the
  // alpha channel is not what decides how much of them lands.
  return Vector4(v[0] * scale, v[1] * scale, v[2] * scale, 1.0);
}