Manual Ship

On this page
  1. Maps for a sprite
  2. Maps in an export
  3. Choose what glows
  4. Shape the normals
  5. Pitfalls
  6. Next

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.

The starter knight, its normal map and its emission map side by side
master.png, hero_n.png and hero_e.png at 4x
The knight and a torch in a dark Godot scene, lit by the torch's Light2D
The same sprites under one Light2D in Godot 4

Make a starter project to follow along:

bash
mode8 init my-game --template platformer
cd my-game

Maps for a sprite#

mode8 maps takes sprites or folders of frames and writes <name>_n.png (normal) and <name>_e.png (emission) for each:

terminal
$ 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 2

A whole animation works the same way: point it at the frames folder and every frame gets its pair, named after the frame.

terminal
$ 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 2

Maps 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:

terminal
$ 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/hero
  • hero_atlas_n.png and hero_atlas_e.png, the two maps as atlases;
  • hero_lit.tres, a CanvasTexture that pairs the atlas with its normal map, and hero_lit_frames.tres, the SpriteFrames built on it, so Light2D nodes shade the sprite;
  • hero_emission.gdshader and hero_emission.tres, an additive, unshaded overlay that keeps the glowing pixels bright whatever the light. The godot_scene adds it as an Emission sprite 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:

terminal
$ 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:

--emissiveGlows
autobright saturated accents; greens only when acid-neon bright (the default)
neonthe same without the warm hues: cyan, magenta, violet, acid green
flamewarm fire, ember and gold hues, plus the white-hot core touching them
nonenothing: 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:

terminal
$ 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 2

The 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:

OptionDefaultEffect
--bevel PXautoWidth of the rounded rim in pixels; auto scales it with the sprite size
--relief R2.0How much the art's own shading becomes relief, 0 to 8; 0 gives a flat sprite with a bevel only
--strength S2.0How steep every slope is
--levels N8How many distinct directions the map uses; fewer gives a more posterized, pixel-art look
terminal
$ 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
Normal maps of the knight with relief 0, 2 and 4
--relief 0, 2 (default) and 4

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 auto greedy. 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 --relief or --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#