tModLoader v2024.11
A mod to make and play Terraria mods
Lighting Class Reference

This class manages lighting in the game world. Lighting is calculated and tracked at tile coordinates within the users game view. The most common use of this class is to use GetColor methods to retrieve the light values at a location for drawing a specific entity. Another common usage is adding light to the game world using the AddLight methods. More...

Static Public Member Functions

static void AddLight (int i, int j, float r, float g, float b)
 Adds light to the world at the specified coordinates.This overload takes in tile coordinates and float values typically ranging from 0 to 1. Values greater than 1 will cause the light to propagate farther. More...
 
static void AddLight (int i, int j, int torchID, float lightAmount)
 
static void AddLight (Vector2 position, float r, float g, float b)
 
static void AddLight (Vector2 position, int torchID)
 
static void AddLight (Vector2 position, Vector3 rgb)
 Adds light to the world at the specified coordinates.This overload takes in world coordinates and a Vector3 containing float values typically ranging from 0 to 1. Values greater than 1 will cause the light to propagate farther. A Vector3 is used for this method instead of Color to allow these overflow values. More...
 
static float Brightness (int x, int y)
 
static void Clear ()
 
static Color GetColor (int x, int y)
 Gets the lighting color at the specified Tile coordinate location.
 
static Color GetColor (int x, int y, Color oldColor)
 
static Color GetColor (Point tileCoords)
 
static Color GetColor (Point tileCoords, Color originalColor)
 Gets the lighting color at the specified Tile coordinate location, then multiplies it by the provided Color.
 
static void GetColor4Slice (int centerX, int centerY, ref Color[] slices)
 
static void GetColor4Slice (int x, int y, ref Vector3[] slices)
 
static void GetColor9Slice (int centerX, int centerY, ref Color[] slices)
 
static void GetColor9Slice (int x, int y, ref Vector3[] slices)
 
static Color GetColorClamped (int x, int y, Color oldColor)
 
static void GetCornerColors (int centerX, int centerY, out VertexColors vertices, float scale=1f)
 
static Vector3 GetSubLight (Vector2 position)
 Gets the lighting color at the specified World coordinate location. The value is calculated through bilinear interpolation of the nearby tile coordinates.
 
static void Initialize ()
 
static void LightTiles (int firstX, int lastX, int firstY, int lastY)
 
static void NextLightMode ()
 

Static Public Attributes

static readonly LegacyLighting LegacyEngine = new LegacyLighting(Main.Camera)
 
static int OffScreenTiles = 45
 

Properties

static float GlobalBrightness [get, set]
 
static LightMode Mode [get, set]
 
static bool NotRetro [get]
 
static bool UpdateEveryFrame [get]
 
static bool UsingNewLighting [get]
 

Detailed Description

This class manages lighting in the game world. Lighting is calculated and tracked at tile coordinates within the users game view. The most common use of this class is to use GetColor methods to retrieve the light values at a location for drawing a specific entity. Another common usage is adding light to the game world using the AddLight methods.

Member Function Documentation

◆ AddLight() [1/3]

static void Lighting.AddLight ( int  i,
int  j,
float  r,
float  g,
float  b 
)
static

Adds light to the world at the specified coordinates.This overload takes in tile coordinates and float values typically ranging from 0 to 1. Values greater than 1 will cause the light to propagate farther.

Parameters
i
j
r
g
b

◆ AddLight() [2/3]

static void Lighting.AddLight ( Vector2  position,
float  r,
float  g,
float  b 
)
static

Adds light to the world at the specified coordinates.

This overload takes in world coordinates and float values typically ranging from 0 to 1. Values greater than 1 will cause the light to propagate farther.

Parameters
position
r
g
b

◆ AddLight() [3/3]

static void Lighting.AddLight ( Vector2  position,
Vector3  rgb 
)
static

Adds light to the world at the specified coordinates.This overload takes in world coordinates and a Vector3 containing float values typically ranging from 0 to 1. Values greater than 1 will cause the light to propagate farther. A Vector3 is used for this method instead of Color to allow these overflow values.

Parameters
position
rgb