Normal mapping with a moving light
The left sprite uses a normal map generated from a height image; the right sprite uses the same albedo and a flat normal. The moving Point light evaluates each surface separately. Change Height, Intensity or Range in the live Inspector to see the difference. Height is measured above the 2D plane, while shadows remain planar.
The complete source project is modules/render2d/res/docs/try/lighting/NormalMapping.assets. Open its project.aego in the editor to edit the images, material and moving-light script together. A copied .aescene alone does not include those external assets. The browser receives prepared resources from that project through the ordinary asset loader. It does not run image importers or search for normal-map filenames.
surface_height.png.meta selects semantic=height, generate_normal=true, height_channel=r, height_strength=12 and normal_y=up. Import produces a linear normal texture. The Lit material's explicit NormalMap reference points to that stable asset ID. The albedo uses color semantics and has no implicit normal association, so the flat comparison remains flat. Renaming either file with its .meta preserves the link.
For an authored normal image, use semantic=normal; choose normal_y=up or down to match the source's green-channel convention. Do not import normal, cookie or height data as sRGB color. An independently packed normal atlas keeps its own region, source dimensions and trim mapping. Rotated atlas entries remain unsupported. A missing normal frame keeps its reference and renders with a flat fallback until repaired.
If the surface looks flat, check that the material is Lit, the light's receiver mask includes the sprite, Height is positive, the normal reference resolves and NormalStrength is nonzero. Excessive ambient can hide the direct-light response. Scene View's Surface normals mode helps inspect the transformed normal without exposure or tone mapping. The project examples/platformer demonstrates the same pipeline in the actual game.
Try it
Change the example parameters and compare the result. Reset restores the initial scene.
Scene5 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)
}
}