Aego Русский

Lighting Environment 2D

Lighting and output policy for a camera. An empty camera applies to the current output; overlapping environments are an error.

LightingEnvironment2D supplies ambient colour and intensity, exposure, Auto/LDR/HDR, mask resolution and the local-shadow budget. Set camera to target one Camera2D, or leave it empty to apply to the world's 2D outputs. Several matching environments produce a diagnostic; their order never chooses a winner. Without an environment, white ambient with intensity one preserves compatible Lit defaults.

LDR uses a linear RGBA8 scene target. HDR uses a verified renderable RGBA16F target and a display resolve. Auto chooses HDR when the output needs lighting and the device supports it. If the actual framebuffer cannot be used, the Inspector reports the LDR fallback reason. The UI and editor overlays stay outside scene tone mapping. A camera with an active Bloom pass filters the composed scene before this display transform.

Scene View has its own output, not the identity of a game camera. Select Preview in Scene View in an environment's Inspector to preview that environment explicitly. Changes to its fields become visible immediately. Use scene environment defaults clears the preview selection. The selection is per document and does not alter camera references, prefabs, Play state or Undo history. Deleting or disabling the selected environment preserves its preview ID and reports a diagnostic until it is restored or the selection is reset.

The Scene View toolbar can bypass lighting or display transformed normals and shadow visibility. These controls affect that view only. For a transparent HDR output, resolve preserves the premultiplied colour contract. Additive emission must first be composed into an opaque backdrop, or retained in a linear RGBA16F intermediate, before a display image is produced. Additive RGB preserves destination alpha.

component engine.LightingEnvironment2D
On this page

Usage

Add it with Create → Lighting → Lighting Environment.

Try it

Ambient illumination

The environment provides background light in addition to the local lights on the Lit surface.

Increase Ambient Intensity from 0.12 to 1 to brighten the scene; Reset restores the darker ambient.

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
CameraNodeRefnone

Optional Camera2D node. Empty applies to all 2D views of this world.

Ambient ColorColorrgba(1, 1, 1, 1)

Linear ambient surface illumination. Default white preserves unlit-looking Lit scenes with no lights.

Ambient Intensityfloat1

Nonnegative ambient energy multiplier.

≥ 0
Color Modeenumauto

Auto chooses supported HDR for Lit output; LDR uses RGBA8 and HDR requests RGBA16F.

one of: auto, ldr, hdr
Exposurefloat1

Positive display-resolve exposure, without changing UI or simulation.

≥ 0.001
Shadow Resolutionint256

Power-of-two mask dimension between 64 and 2048. Initial profile uses 256.

64 – 2048
Max Shadowed Lightsint8

Per-camera local-shadow budget from 0 through 16; actual performance depends on the GPU.

0 – 16