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 source = b.textures['source_texture'];
  if (source == null) return Vector4(0.0, 0.0, 0.0, 1.0);
  final params = b.vec4('RenderTextureInfo', 'params', Vector4.zero());
  final exposure = params.x;
  // Turned over where the backend draws its first row at the bottom; this
  // one draws it at the top and never is.
  final light = source.sample(v[0], params.y > 0.5 ? 1.0 - v[1] : v[1]);
  double encode(double channel) =>
      toSrgb(math.min(math.max(channel * exposure, 0.0), 1.0));
  return Vector4(encode(light.x), encode(light.y), encode(light.z), 1.0);
}