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) {
  // No surface written, for the reason [SkyShader] gives: the GLSL this
  // mirrors no longer declares a second output.
  final map = b.textures['sky_texture'];
  // A stage bound no cube: black rather than a crash, and black rather than a
  // plausible sky, which is what makes it reportable.
  if (map == null) return Vector4(0.0, 0.0, 0.0, 1.0);

  final texel = map.sampleCube(v[0], v[1], v[2]);
  // Off the varyings, as the preset is — see [SkyVertexShader].
  final tint = Vector4(v[3], v[4], v[5], v[6]);

  return Vector4(
    toLinear(texel.x) * tint.x,
    toLinear(texel.y) * tint.y,
    toLinear(texel.z) * tint.z,
    1.0,
  );
}