Table of Contents

Interface ILightingManager

Namespace
BSGameLib.Game
Assembly
BSGameLib.Game.dll

Sets the lighting for lit draws: the ambient colour, greyscale and point lights.

public interface ILightingManager

Properties

GlobalAmbientColor

The colour every lit pixel starts from, before point lights are added. Set it with SetGlobalAmbientColor(Color).

Color GlobalAmbientColor { get; }

Property Value

Color

Greyscale

How far lit draws are drained of colour before lights are applied: 0 (the default) leaves them alone, 1 makes them fully grey. Applied before lighting, so ambient and light colours still tint the grey picture.

float Greyscale { get; }

Property Value

float

PointLights

The lights added so far, in the order they were added. A draw uses only as many as the shader supports, from the first.

IReadOnlyList<PointLight> PointLights { get; }

Property Value

IReadOnlyList<PointLight>

Methods

AddPointLight(PointLight)

Adds a light for lit draws, after the ones already added, and returns a handle to update or remove it by. A game that rebuilds its lights every frame can ignore the handle.

PointLightHandle AddPointLight(PointLight light)

Parameters

light PointLight

Returns

PointLightHandle

ClearPointLights()

Removes every point light. Handles to them stop working.

void ClearPointLights()

ConfigureShader(IShaderProgram, double)

Sets the lighting uniforms on a shader: uGlobalAmbientColor, uGreyscale, uPointLights[i] and uNumPointLights. Lit and veil sprites get this automatically; call it once a frame on a custom material's shader to light that material. The uniform names are part of the API.

void ConfigureShader(IShaderProgram shader, double totalSeconds)

Parameters

shader IShaderProgram
totalSeconds double

The game's total time. Taken as a double so a pulse keeps its phase after hours.

RemovePointLight(PointLightHandle)

Removes the light handle names. False if it has already been removed or cleared.

bool RemovePointLight(PointLightHandle handle)

Parameters

handle PointLightHandle

Returns

bool

SetGlobalAmbientColor(Color)

Sets the ambient colour for lit draws.

void SetGlobalAmbientColor(Color color)

Parameters

color Color

SetGreyscale(float)

Sets how far lit draws are drained of colour, from 0 to 1. Values outside that range are clamped.

void SetGreyscale(float amount)

Parameters

amount float

UpdatePointLight(PointLightHandle, PointLight)

Replaces the light handle names, keeping its place in the order. False if it has been removed or cleared.

bool UpdatePointLight(PointLightHandle handle, PointLight light)

Parameters

handle PointLightHandle
light PointLight

Returns

bool