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 n = Vector3(v[kVNormal], v[kVNormal + 1], v[kVNormal + 2])
    ..normalize();
  final display = Vector3(n.x * 0.5 + 0.5, n.y * 0.5 + 0.5, n.z * 0.5 + 0.5);
  // The surface buffer gets the normal turned to face the eye, as
  // `WriteSurfaceGeometry` writes it; the colour stays the raw attribute.
  writeSurface(c, v, b, c.frontFacing ? n : -n, 1.0);
  return Vector4(
    toLinear(display.x),
    toLinear(display.y),
    toLinear(display.z),
    1.0,
  );
}