Light 2D
Forward 2D diffuse light. Local +X defines Spot and Directional azimuth; presentation transforms also drive shadows.
Light2D affects SpriteRenderer with Lit and Mesh2D with LitMesh2D. Unlit materials keep their original colour. Add a light from the Create palette, set its intensity and range in the Inspector, then drag its range and direction handles in Scene View. A handle gesture creates one Undo command.
Point lights illuminate a circle. Spot lights face local +X; innerAngle and outerAngle are full cone widths in radians, so an outer angle of π/2 spans 90°. Sprite lights apply the cookie texture as a mask using that texture's own region. Directional lights use node rotation for azimuth and elevation for the component toward the surface. Directional shadows are unavailable; enabling them produces a diagnostic.
height gives a local light a direction toward the receiver's normal. With a flat normal and a light exactly in the sprite plane, the diffuse dot product can be zero. Height changes shading, while occluders remain planar. Range uses world units and does not scale with the light node.
layers selects receiver visibility layers. shadowCasterMask separately selects occluder layers; neither replaces collision filtering. Eight lights can contribute to one receiver set. Priority, estimated influence and stable ID decide which lights remain when a set exceeds that budget. Scene View highlights excluded source markers and the Profiler counts exclusions and lighting batch splits. Transparent Sprite/Mesh2D order is preserved.
The Try scene places a warm light beside a cool spotlight. Change the warm light's intensity to compare its contribution, then use Reset to restore it. The lights remain still so the effect of each edit is easy to see.
component engine.Light2D
On this page
Art Studio
Try it
Light intensity
A warm point light and a cool spotlight illuminate a Lit surface and an occluder.
Set the warm light's Intensity to 0 and watch its contribution disappear. Reset restores it.
Scene6 nodes
Scriptmain.aes
package demo
import "aego/math"
// A deterministic presentation-only motion makes the shadow response visible.
script MovingLight {
@export var Speed float = 0.8
@export var Distance float = 1.3
var elapsed float
var origin Vec2
func Ready() {
origin = node.Transform2D().Position
}
func Update(dt float) {
elapsed += dt
transform := node.Transform2D()
transform.Position = origin + Vec2{math.Cos(elapsed * Speed) * Distance, math.Sin(elapsed * Speed) * 0.8}
node.SetTransform2D(transform)
}
}
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Type | enum | point | Point, Spot, Directional or Sprite/cookie. Directional shadows are not supported. one of: point, spot, directional, sprite |
| Color | Color | rgba(1, 1, 1, 1) | Linear light color; the color picker handles display conversion. |
| Intensity | float | 1 | Nonnegative energy multiplier; zero disables this light's contribution. ≥ 0 |
| Range | float | 5 | Local light radius in world units, independent of node scale. ≥ 0.001 |
| Height | float | 1 | Virtual distance above the sprite surface for diffuse normal mapping; shadows remain planar. ≥ 0 |
| Inner Angle | float | 0.392699 | Full Spot inner cone angle in radians, centered on local +X. 0 – 3.14159 |
| Outer Angle | float | 0.785398 | Full Spot outer cone angle in radians, no smaller than innerAngle. 0 – 3.14159 |
| Elevation | float | 0.785398 | Directional elevation above the surface in radians, greater than zero. 0.001 – 1.5708 |
| Falloff | float | 2 | Nonnegative falloff exponent over normalized local-light distance. ≥ 0 |
| Cookie | Texture | none | Sprite light mask texture. Its own region and trim map to the light square. |
| Layers | int | -1 | 64-bit receiver visibility mask. -1 means all bits; zero receives no objects. |
| Shadow Caster Mask | int | -1 | 64-bit shadow-occluder mask, independent of visibility and collision masks. |
| Shadows | bool | false | Enable cached local-light shadow masks for Point, Spot and Sprite lights. |
| Shadow Softness | float | 0 | Bounded mask filtering radius; this is not a physical area-light penumbra. ≥ 0 |
| Priority | int | 0 | Higher priority is selected first when the per-draw light budget is exceeded. |
Related guides
- Art Studio: drawing, frames and source files Create a drawing, edit layers and frames, then distinguish saving its source from publishing game assets.
- Cameras Camera2D renders an orthographic view from the node's 2D transform.
- Materials and shaders A material is a shared asset.