Lighting
Make normal maps and emission maps so 2D lights shade your sprites and glowing parts stay bright in the dark.
Two maps let a flat sprite take part in 2D lighting. A normal map stores which way each pixel faces, so a light from the left brightens the left side of a helmet and leaves the right in shadow. An emission map marks the pixels that give off their own light (eyes, visors, flames, magic), so they stay bright in a dark room. Mode 8 makes both from the art itself, on the CPU, in the palette's pixel grid.


Make a starter project to follow along:
mode8 init my-game --template platformer
cd my-gameMaps for a sprite#
mode8 maps takes sprites or folders of frames and writes <name>_n.png (normal) and <name>_e.png (emission) for each:
$ mode8 maps assets/hero/master.png --out-dir maps/hero --name hero
✓ Lighting maps for 1 sprite → maps/hero/
1 normal map, 1 emission map · glow covers 0.0%
relief 2A whole animation works the same way: point it at the frames folder and every frame gets its pair, named after the frame.
$ mode8 maps assets/hero/frames --out-dir maps/hero-frames
✓ Lighting maps for 15 sprites → maps/hero-frames/
15 normal maps, 15 emission maps · glow covers 0.1%
relief 2Maps in an export#
For a game, ask mode8 export for the normal and emission formats instead. You get each map as an atlas that lines up pixel for pixel with the color atlas, plus the Godot resources that use them:
$ mode8 export assets/hero/frames --out-dir godot/art/hero --name hero --formats godot,godot_scene,normal,emission --animations assets/hero/master.m8.json
✓ Exported hero (15 frames) → godot/art/hero/
godot, godot_scene, normal, emission · 10 files
animations attack, hurt, idle, jump, walk
Godot godot/art/hero/hero.tres
scene godot/art/hero/hero.tscn (CharacterBody2D, mode8_actor.gd)
lit SpriteFrames godot/art/hero/hero_lit_frames.tres · relief 2
palette nes_master_gothic from mode8.toml
Next:
mode8 verify --assets-dir godot/art/herohero_atlas_n.pngandhero_atlas_e.png, the two maps as atlases;hero_lit.tres, aCanvasTexturethat pairs the atlas with its normal map, andhero_lit_frames.tres, theSpriteFramesbuilt on it, soLight2Dnodes shade the sprite;hero_emission.gdshaderandhero_emission.tres, an additive, unshaded overlay that keeps the glowing pixels bright whatever the light. Thegodot_sceneadds it as anEmissionsprite that follows every frame.
In other engines, use hero_atlas_n.png wherever the engine takes a normal map for a texture; it shares the color atlas's layout and the atlas JSON. In Phaser 3, for example, load the atlas with both images, this.load.atlas("hero", ["hero_atlas.png", "hero_atlas_n.png"], "hero_phaser_atlas.json"), and give the sprite the Light2D pipeline.
Choose what glows#
By default (--emissive auto) the bright, saturated accents glow; greens glow only when they are acid-neon bright, so grass and leaves stay dark. On the knight that is its gold trim (the glow covers line above). Gold trim is not a light source, so leave its three colors out:
$ mode8 maps assets/hero/master.png --out-dir maps/hero --name hero --emissive-exclude '#fbd452,#f9a726,#e26847'
✓ Lighting maps for 1 sprite → maps/hero/
1 normal map, 1 emission map · glow covers 0.0%
relief 2--emissive takes a preset, colors, or both:
--emissive | Glows |
|---|---|
auto | bright saturated accents; greens only when acid-neon bright (the default) |
neon | the same without the warm hues: cyan, magenta, violet, acid green |
flame | warm fire, ember and gold hues, plus the white-hot core touching them |
none | nothing: the emission map stays empty |
#rrggbb,... | exactly these colors, alone or after a preset (neon,#ffcc00) |
Two thresholds tune the presets: --emissive-min-lightness (0 to 1, default 0.58) and --emissive-min-chroma (how saturated, default 0.13). Raising the lightness keeps only the hottest pixels. A torch is mostly flame, so with --emissive flame a quarter of it glows and Mode 8 warns; raise the threshold to keep the bright core:
$ mode8 maps assets/torch/frames --out-dir maps/torch --name torch --emissive flame
✓ Lighting maps for 2 sprites → maps/torch/
2 normal maps, 2 emission maps · glow covers 12.8%
relief 2
$ mode8 maps assets/torch/frames --out-dir maps/torch --name torch --emissive flame --emissive-min-lightness 0.7
✓ Lighting maps for 2 sprites → maps/torch/
2 normal maps, 2 emission maps · glow covers 7.3%
relief 2The warning is advice, not an error: the command succeeds either way.
Shape the normals#
The normal map is built from the silhouette (the rim bends away from the viewer, like a bevel) and from the art's own shading (light and dark bands become bumps and folds). Four options shape it:
| Option | Default | Effect |
|---|---|---|
--bevel PX | auto | Width of the rounded rim in pixels; auto scales it with the sprite size |
--relief R | 2.0 | How much the art's own shading becomes relief, 0 to 8; 0 gives a flat sprite with a bevel only |
--strength S | 2.0 | How steep every slope is |
--levels N | 8 | How many distinct directions the map uses; fewer gives a more posterized, pixel-art look |
$ mode8 maps assets/hero/master.png --out-dir maps/flat --name hero --relief 0 --bevel 2
✓ Lighting maps for 1 sprite → maps/flat/
1 normal map, 1 emission map · glow covers 0.0%
bevel 2 px · relief 0
With a part map (--parts, see Animation), limbs and weapons get their own rim, so an arm in front of the torso reads as a separate shape.
Pitfalls#
- Everything glows. A palette full of bright, saturated colors makes
autogreedy. Pick the preset that matches the light source, exclude the colors that are only paint, or raise--emissive-min-lightness. - The lit sprite looks embossed. Lower
--reliefor--strength. - Maps that do not line up. Make the maps from the same frames you export, or use the export formats, which pack the maps into the same atlas layout.
Next#
- Godot: the lit scene in Godot 4.
- Exporting: every export format.
- Engine formats reference: the files the
normalandemissionformats write.