Aego Русский

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

Emission and normal channels Art Studio lessons

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.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene6 nodes
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat54viewportRect[0, 0, 1, 1]maskint-1orderint0clearbooltrueclearColorColor#0d1420ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Lit surface
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")materialAssetRef<material>asset("ae900000000000000000000000000c06")layerint0orderint0tintColor#a8bacffforiginVec2[0.5, 0.5]sizeVec2[12, 6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
Lighting environment
Transform
position[0, 0]rotation0scale[1, 1]
Warm point light
Transform
position[-2, -1]rotation0scale[1, 1]
Light 2D
typeenumpointcolorColor#ffbd75ffintensityfloat3.8rangefloat8heightfloat2fallofffloat1.3layersint1shadowCasterMaskint1shadowsbooltrueshadowSoftnessfloat1priorityint2
Cool spotlight
Transform
position[4, 1.2]rotation3.1415927scale[1, 1]
Light 2D
typeenumspotcolorColor#779effffintensityfloat3rangefloat9heightfloat2innerAnglefloat0.9outerAnglefloat1.6fallofffloat1.2layersint1shadowCasterMaskint1shadowsboolfalsepriorityint1
Manual occluder
Transform
position[0.7, 0]rotation0scale[1, 1]
Light Occluder 2D
sourceenumpolygonpolygon[]Vec2[[-0.18, -1.1], [0.18, -1.1], [0.18, 1.1], [-0.18, 1.1]]closedbooltruecullModeenumnonelayersint1
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint2tintColor#e3e8effforiginVec2[0.5, 0.5]sizeVec2[0.36, 2.2]blendenumpremultipliedfilterenumnearest
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

NameTypeDefaultDescription
Typeenumpoint

Point, Spot, Directional or Sprite/cookie. Directional shadows are not supported.

one of: point, spot, directional, sprite
ColorColorrgba(1, 1, 1, 1)

Linear light color; the color picker handles display conversion.

Intensityfloat1

Nonnegative energy multiplier; zero disables this light's contribution.

≥ 0
Rangefloat5

Local light radius in world units, independent of node scale.

≥ 0.001
Heightfloat1

Virtual distance above the sprite surface for diffuse normal mapping; shadows remain planar.

≥ 0
Inner Anglefloat0.392699

Full Spot inner cone angle in radians, centered on local +X.

0 – 3.14159
Outer Anglefloat0.785398

Full Spot outer cone angle in radians, no smaller than innerAngle.

0 – 3.14159
Elevationfloat0.785398

Directional elevation above the surface in radians, greater than zero.

0.001 – 1.5708
Fallofffloat2

Nonnegative falloff exponent over normalized local-light distance.

≥ 0
CookieTexturenone

Sprite light mask texture. Its own region and trim map to the light square.

Layersint-1

64-bit receiver visibility mask. -1 means all bits; zero receives no objects.

Shadow Caster Maskint-1

64-bit shadow-occluder mask, independent of visibility and collision masks.

Shadowsboolfalse

Enable cached local-light shadow masks for Point, Spot and Sprite lights.

Shadow Softnessfloat0

Bounded mask filtering radius; this is not a physical area-light penumbra.

≥ 0
Priorityint0

Higher priority is selected first when the per-draw light budget is exceeded.