Skip to main content

AndroidLightsController

A class in Root.Township, Alta.Lighting.

Client lights controller on Android: packs up to 8 lights into a global shader array, and uses baked fake light meshes for lights beyond the nearest 8.

Constructors​

MemberWhat it is
AndroidLightsController()Creates an AndroidLightsController with default values.

Fields​

5 private and internal fields
MemberWhat it is
private static readonly int _CustomLightShader property ID of the global light array.
private HashSet<PlatformLight> bufferLights that didn't make the nearest 8, which get fake lights.
private Vector4 emptyColour used for unused slots.
private Vector4[] shaderArrayThe 16 vectors sent to the shader: positions, attenuation and colours for 8 lights.
private LightSorter<AndroidLightsController.SortedLight> sorterSorts lights by distance from the head.

Methods​

MemberWhat it is
protected override void OnDisabled()Clears the shader array when no lights are left.
protected override void Update()Fills the _CustomLight shader array with the lights, or the 8 nearest to the player's head, and toggles fake lights and the EIGHT_LIGHTS keyword.
1 private and internal method
MemberWhat it is
private void PopulateArray(int offset)Writes 4 sorted lights into the shader array from an offset and turns their fake lights off.