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 surface = b.textures['surface_texture'];
  if (surface != null) {
    final target = b.vec4(_block, 'target', Vector4.zero());
    // `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;
  }
  final color = b.vec4(_block, 'color', Vector4.zero());
  return Vector4(color.x, color.y, color.z, 1.0);
}