contributorLightCount function

int contributorLightCount(
  1. ShaderBindings bindings,
  2. Vector3 world
)

ContributorLightCount from lib/contributor_lights.glsl — N6: the slots a contributor's draw holds, and the list's tail or the cell's.

Implementation

int contributorLightCount(ShaderBindings bindings, Vector3 world) {
  final slots = bindings.vec4('ContributorLightInfo', 'slots', Vector4.zero());
  final list = bindings.vec4('LightListInfo', 'list', Vector4.zero());
  final tail = list.y > 0.0 && clustered(bindings)
      ? clusterAt(bindings, world).count
      : list.x;
  return (slots.x + 0.5).floor().clamp(0, kMaxLights) +
      (tail + 0.5).floor().clamp(0, kExtraLights);
}