Gridwright Start for $1

Godot 2D Normal Map: Light Sprites with PointLight2D

Sprite flat, dark or lit from the wrong side under a PointLight2D? Set up a Godot 4 2D normal map: CanvasTexture, light height, green channel, Nearest.

Normal Maps at work
Normal Maps at work: Normal maps for 2D lighting.

You put a PointLight2D next to your knight and the whole sprite gets brighter, evenly, like a sticker under a lamp. Move the torch to the other side and nothing changes. So you make a normal map, plug it in, and now the knight is darker than before, or only a thin edge catches the light. Or the torch hangs above the knight and the light lands on his boots.

None of this is a bug. Each one comes from a default you can't see in the scene. We built a test project in Godot 4.7.2, rendered every case and measured the sprite's brightness from 0 to 255, where our grey test sprite sits at 127 with no light. Here is what each setting did, in the order you set them up.

How Godot 4 lights a 2D sprite

Without a normal map, a light adds brightness to everything inside its texture, and the only change across the sprite is the light's own fade. A plain sprite with the light 24 px to its left measured 236 on its left half and 221 on its right. With the light on the right, the numbers just swapped. There is no lit side and no shadow side.

Normal Maps in use
Normal Maps in use. Every tool runs in your browser, nothing to install.

With a normal map, Godot compares each pixel's direction with the direction to the light. We gave a sprite a map whose left half faces left and right half faces right. With the light on the left, the left half rose to 196 and the right half stayed at 127, unlit. Move the light and the shading follows it.

Step 1: Put the sprite and its normal map in a CanvasTexture

  1. Select the Sprite2D. In the Inspector, open Texture and pick New CanvasTexture.
  2. Set Diffuse > Texture to your sprite and Normal Map > Texture to its normal map, for example hero_n.png. In code these are diffuse_texture and normal_texture.
  3. For a sprite sheet, put the whole sheet in Diffuse and the whole normal sheet in Normal Map, then set Hframes and Vframes as usual. In our 2-frame test, frame 1 read its own normals, not frame 0's. More on frames in Godot Sprite Sheet Animation.

The Specular group holds an optional shine map with Color and Shininess. Shininess starts at 1.0, which makes the highlight so tight that our all-white specular map added nothing. At 0.1 the same sprite went from 192 to 220. Lower it until the highlight shows.

Normal Maps in use
Normal Maps in use. Every tool runs in your browser, nothing to install.

Step 2: Give the PointLight2D a texture and a height

Texture. A PointLight2D lights only inside its own texture, and a new one has none. With the texture empty, our sprite stayed at 127. A GradientTexture2D makes a quick light: set Fill to Radial, Fill From to (0.5, 0.5) and Fill To to (1, 0.5). A new Gradient runs from black at offset 0 to white at offset 1, so a radial light made from it is dark in the middle: our sprite under its centre measured 139 instead of 240. Swap the two colours so white sits at offset 0.

Normal Maps in use
Normal Maps in use. Every tool runs in your browser, nothing to install.

Height. This is the setting that turns sprites dark. Height is in pixels and starts at 0, which puts the light flat on the floor beside the sprite. A pixel that faces the camera then gets no light at all. Our sprite with a flat normal map, the light right on top of it:

  • Height 0: 127, the same as no light
  • Height 16: 219
  • Height 64: 240
  • Height 256: 242

Low heights give long, raking light where only the edges facing the light catch it. Higher values light the front of the sprite. In our test, 16 already lit the face of the sprite and above 64 little changed.

Energy multiplies the light and starts at 1.0. At 2.0 our grey sprite clipped to full white, 255. Texture Scale sizes the light: a 64 px light texture 60 px from the sprite missed it at 1.0 and reached it at 3.0.

CanvasModulate. Add one with a dark colour and the scene goes dark around your lights. At (0.2, 0.2, 0.3) our unlit sprite dropped to 25 and the lit one read 138.

Step 3: Light from the wrong side? Check the green channel

Godot reads green as "up on screen", the Y+ convention, also called OpenGL. We filled a normal map with full green, a surface that faces up. With the light 40 px above, the sprite measured 204. With the light 40 px below, 127, no light at all. A map made for Y- (DirectX, the convention Unreal uses) has green the other way round, so a light from above lands on the bottom edges.

2D Lights & Glow
2D Lights & Glow: Pixel and smooth 2D light textures: radial, cones, window shafts, god rays, animated flicker. One of the 150 packs in Gridwright.

There are two fixes:

  • Export the map again with Y+.
  • Or select the normal map in the FileSystem dock, tick Process > Normal Map Invert Y in the Import dock and press Reimport. With it on, our green-up map lit from below instead of above.

Mirrored and rotated sprites need nothing extra. With Flip H on, Godot mirrors the normals too: a map facing right, lit from the right, went dark when flipped, so a flipped walk cycle lights correctly with the same map. Rotating the sprite 180 degrees turned its normals with it.

Step 4: A DirectionalLight2D for sun and moon

A DirectionalLight2D needs no texture and lights everything in range from one direction. At Rotation 0 it shines down the screen, so the tops of things light up. At 90 degrees the light comes from the right. Its Height runs from 0 to 1 instead of pixels. On a flat normal map:

Screen Transitions
Screen Transitions: 55 screen transitions as masks: pixel art + smooth, a Godot 4 add-on, Ren'Py file and frames. One of the 150 packs in Gridwright.
  • 0: 127, unlit; the light skims the floor and only up-facing surfaces catch it.
  • 0.5: 217, a light at 45 degrees.
  • 1: 254, straight from the front.

Step 5: Keep the pixels sharp under the light

The project's default canvas filter is Linear, which smooths pixel art as soon as it is scaled. A 2 x 2 checker drawn 16 times larger came out in 65 shades of grey with the default and in 2 with Nearest. Set it once in Project Settings > Rendering > Textures > Canvas Textures > Default Texture Filter, or per node in the Sprite2D's Texture > Filter. The CanvasTexture's own Texture > Filter set to Nearest works too. More in Godot Pixel Perfect Settings.

The whole setup in GDScript

Attach this to a Node2D that has a Sprite2D and a PointLight2D as children. We ran it as printed in Godot 4.7.2. The light follows your mouse, so you can watch the shading move.

extends Node2D

@onready var sprite: Sprite2D = $Sprite2D
@onready var light: PointLight2D = $PointLight2D


func _ready() -> void:
	var tex := CanvasTexture.new()
	tex.diffuse_texture = preload("res://hero.png")
	tex.normal_texture = preload("res://hero_n.png")
	tex.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
	sprite.texture = tex

	var glow := Gradient.new()
	glow.colors = PackedColorArray([Color.WHITE, Color.BLACK])
	var dot := GradientTexture2D.new()
	dot.gradient = glow
	dot.fill = GradientTexture2D.FILL_RADIAL
	dot.fill_from = Vector2(0.5, 0.5)
	dot.fill_to = Vector2(1.0, 0.5)
	dot.width = 256
	dot.height = 256
	light.texture = dot
	light.height = 24.0


func _process(_delta: float) -> void:
	light.global_position = get_global_mouse_position()

Make the normal map in seconds

All of this needs a normal map that fits your art, and painting one by hand means shading every frame again from several sides. Normal Maps builds it from the sprite's outline and colours, in your browser (how it works):

  1. Drop your sprite or sheet. For a sheet, type one frame's size in Frame width and Frame height, so each frame gets its own edges.
  2. Set Bevel width (it starts at 3 px) and Detail strength. A light follows your mouse over the preview the whole time.
  3. Keep Pixel-art normals on. Each pixel snaps to a set of Directions (4, 8 or 16) and Tilt steps, so the light falls in clean bands instead of a soft gradient.
  4. Leave Y direction on Y+ (OpenGL: Unity, Godot), the default.
  5. Press Export this file. The map gets your sprite's name plus _n, so hero.png gives hero_n.png, ready for the Normal Map slot. Height, specular and occlusion maps are a tick away.

You can try it here, with no account. In the demo's own words: everything works; saving your own images is limited to 64×64 pixels (the sample saves at any size). The full version saves any size and whole batches.

Your game, looking finished

Every Gridwright asset pack, made to fit together, and all 44 tools for the fiddly work, with every new release, for $17 a month. Try it in your own game first: 3 days for $1 with every tool and up to 10 packs. Cancel any time.

Start: 3 days for $1 See everything it includes

FAQ

Why does my sprite go dark when I add a normal map in Godot?

The PointLight2D's Height starts at 0, where a pixel facing the camera gets no light. Raise it: in our test 16 px lit the sprite and 64 px lit it almost fully.

Does Godot 4 use OpenGL or DirectX normal maps in 2D?

OpenGL, Y+: green means up on screen. For a DirectX map, tick Normal Map Invert Y in the Import dock and reimport.

Why does my PointLight2D light nothing?

It has no texture. Give it one, such as a radial GradientTexture2D with white at offset 0.

Light your sprite in Godot

Open the Normal Maps demo, press Try the sample or drop in a sprite up to 64x64, and export its _n.png. Put both in a CanvasTexture, raise the light's Height and move it. The full tool is one of Gridwright's 44 tools, which come with 150 asset packs.

Your game, looking finished

Every Gridwright asset pack, made to fit together, and all 44 tools for the fiddly work, with every new release, for $17 a month. Try it in your own game first: 3 days for $1 with every tool and up to 10 packs. Cancel any time.

Start: 3 days for $1 See everything it includes