J-02

Normal-mapped sprite lighting

Painted sprites catch the light: each one is drawn with its normal map, so lanterns, a passing wisp and the low dusk sun light the side that faces them, put a glint on curved edges and a cool rim on the far side, while the art stays as painted where it faces you. Bitmaps use their L-05 maps; shapes drawn with canvas calls get normals derived from the shape. One I-08 pass; it reads the J-01 lights when they are there. Without WebGL or without a map, every sprite draws exactly as before.

FLAT SPRITESNORMAL LIGHTING
Arrows / WASD or tap: walk · click anywhere: flash of light · Space: spell
WebGL2 frame - -
Bitmaps with L-05 mapsThe keeper, herbalist, lampposts and well are drawn with drawSprite(img, map, ...). Nothing that carries a lantern is mirrored: the keeper only walks to the right, the herbalist looks at him from the left. The slimes are (a symmetric blob): when one hops left its map is mirrored and negated, so the light still falls on the side that faces it.
No map, derivedThe oak has no normal map: 'derive' builds one from its alpha and shading. Canvas paths wrapped in shape() get normals from the drawn shape the same way. The moss slimes are painted sprites whose map was derived offline by the L-05 tool.
Shares J-01's lightsThe dusk darkness, lantern pools and shadows are J-01. J-02 reads the same light list and adds the relief, glints and rim on the sprites. Switch J-01 off: J-02 lights its own copy of the lights.