Gridwright Store

28 Nov 2026 · By Gridwright Studio

Day and Night Cycle in Godot 4 for 2D Pixel Art Games

Gridwright pack artwork for Day and Night Cycle in Godot 4 for 2D Pixel Art Games

You add a CanvasModulate, set it to dark blue, and your farm finally looks like night. Then the problems start. The health bar turns navy too. The lamp by the barn is a flat grey smudge, or at noon it burns a white hole into the grass. The sky behind everything stays bright blue. And the change from day to night happens in one frame instead of sliding through a sunset.

Each has a simple cause. We built a test scene in Godot 4.7.2 at 320x180 and read back the pixels under each setup, so the numbers below are what Godot drew. The script near the end runs a whole day from one node.

What CanvasModulate really does

CanvasModulate multiplies every pixel on its canvas by one colour. Under a tint of (0.2, 0.25, 0.5), a white tile read 51, 64, 127 and a 50% grey tile read 25, 32, 63: exactly the tile times the tint. It darkens every sprite and tile in one place, and your art files stay as they are.

Three things in our test were not tinted, and each one explains a common bug:

  • The clear colour. The empty background stayed 127, 178, 255 under the night tint. If your sky is the clear colour, change it from the same clock with RenderingServer.set_default_clear_color(), or draw the sky as a sprite so the tint reaches it.
  • Anything on a CanvasLayer. A white sprite on a CanvasLayer stayed 255, 255, 255, while a white ColorRect on the main canvas went to 51, 64, 127. Put the HUD on a CanvasLayer and it stays readable at night.
  • Sprites with an unshaded material. A CanvasItemMaterial with Light Mode set to Unshaded kept a white sprite at full white under the night tint. That is how lit windows and fireflies keep glowing.

Godot's class reference says only one CanvasModulate can tint a canvas, but a CanvasLayer can have its own: one with a 0.6 grey CanvasModulate drew our white sprite at 153 while the main canvas kept its blue night.

2D Lights & Glow pack cover: Pixel and smooth 2D light textures: radial, cones, window shafts, god rays, animated flicker
2D Lights & Glow: Pixel and smooth 2D light textures: radial, cones, window shafts, god rays, animated flicker.

How lights add up under the tint

A PointLight2D in the default Add blend mode does not paint light on top of the dark picture. It adds its colour to the tint before the multiply. In every probe the result was the tile colour times (tint + light colour x energy), capped at 255:

  • 50% grey tile, night tint, white light at energy 1: 152, 159, 190, which is 0.5 x 1.2, 1.25 and 1.5.
  • White tile, night tint, white light at energy 0.5: 178, 191, 255.
  • 50% grey tile, night tint, warm light (1.0, 0.6, 0.3) at energy 1: 152, 108, 102. The lamp looks warm because the night tint is weakest in red.
  • The same grey tile at noon (a white tint) under the white light at energy 1: 254, 254, 254. At energy 2 it read 255 even at night.

The last line is the noon bug. A lamp left at full energy in daylight doubles everything under it, so the clock that darkens the world also has to fade the lamps out. Pixel-style light textures help the rest of the look: the pixel textures in 2D Lights & Glow (below) fall off in 6 flat bands instead of a smooth blur, and the older post on 2D lighting for pixel art in Godot 4 covers cones, window light and flicker.

Two settings decide what a light reaches. A light only affects items whose Light Mask shares a bit with its Item Cull Mask (under Range): a white tile on mask 2 under a light on mask 1 stayed at the plain night colour, 51, 64, 127. And lights on the main canvas did not reach a CanvasLayer: a 50% grey sprite there stayed 127 under a white light. A light in Mix mode ignores the tint instead: a 50% grey tile under a white Mix light at energy 1 read 127 at night and at noon.

A colour ramp for the whole day

Switching between two colours gives you the one-frame jump. A Gradient gives you a ramp you can edit in the Inspector: put a point at each time of day and sample it with the hour divided by 24. The docs say sample() expects 0 to 1 and returns the end colour outside that range, and in our check -0.2 and 1.3 returned the colours at 0 and 1. So give the first and last points the same night colour, or midnight will jump.

This is the ramp we tested. Each offset is the hour divided by 24:

  • 0.0 (0:00) and 0.208 (5:00): night, (0.18, 0.22, 0.45).
  • 0.271 (6:30): dawn, (0.85, 0.6, 0.55).
  • 0.333 (8:00) and 0.708 (17:00): white, so the art shows its own colours all day.
  • 0.771 (18:30): dusk, (0.95, 0.55, 0.4).
  • 0.833 (20:00) and 1.0 (24:00): night again.

Sampled by the clock below, 6:00 read 160, 121, 132 on its way to dawn, 12:00 read pure white, and 19:00 read 177, 112, 106 as dusk sank into night.

The ramp's Interpolation Color Space changes the sunset. Between night (0.10, 0.12, 0.30) and a sunset orange (1.0, 0.55, 0.25), the midpoint read 140, 85, 70 in sRGB (the default), 188, 104, 70 in Linear sRGB and 132, 88, 86 in Oklab. Linear sRGB makes dusk much brighter, and Oklab keeps more blue in it. Constant interpolation skips the blend (0.49 still returned the night colour), which suits a clock that moves in steps.

Screenshot 1 of 4 from the Farm RPG pack
From Farm RPG: 16x16 farming RPG kit: a working farmer in 4 directions, a character creator, seasons, animals.

The clock script

One script on the CanvasModulate runs the tint and every lamp. Put your PointLight2D nodes in a group called night_lights, your unshaded glow sprites (lit windows, fireflies) in night_glow, give the node a Gradient in the Inspector and set how many real seconds a day lasts. Each function is one line, so you can paste it as it is:

  • extends CanvasModulate
  • @export var sky: Gradient
  • @export var day_seconds := 600.0
  • @export var lamp_energy := 0.8
  • var hour := 8.0
  • func _process(delta: float) -> void: hour = fposmod(hour + delta * 24.0 / day_seconds, 24.0); apply()
  • func apply() -> void: color = sky.sample(hour / 24.0); get_tree().call_group("night_lights", "set", "energy", lamp_on() * lamp_energy); get_tree().call_group("night_glow", "set_indexed", "modulate:a", lamp_on())
  • func lamp_on() -> float: return smoothstep(18.0, 19.0, hour) + 1.0 - smoothstep(6.0, 7.0, hour)

We ran this exact script in Godot 4.7.2. The lamps sat at 0.8 through the night, 0.4 at 6:30 and 18:30, and 0 from 7:00 to 18:00, and the glow sprites faded with them. With day_seconds at 600, 60 frames moved the hour from 8.0 to 8.04, so one real second is 2.4 in-game minutes and one hour lasts 25 seconds. Starting at 23.9, it passed midnight to 0.006 with no jump, and pausing the SceneTree stopped the hour too, so a pause menu freezes the sun.

Weather fits into the same line. Godot multiplies two colours channel by channel, so color = sky.sample(hour / 24.0) * storm_tint darkens the ramp for a storm and leaves one CanvasModulate on the canvas. Save hour with the rest of your game, and loading puts the sun back where it was.

Night assets for the cycle

A tint alone makes a dark map. Night reads as night when light comes from things in the world:

  • 2D Lights & Glow: 54 light textures in a pixel and a smooth style, as alpha files for PointLight2D (white light in the alpha channel; tint it with the light's colour) and as additive sprites. It adds 11 looping animated lights (torch, campfire, candle, lantern, fireplace, fireflies and more), 4 colour sets and a Godot 4 demo tested in 4.7.2.
  • Farm RPG: the farm in four seasons with lights to switch on at dusk. Paper lanterns come in red and gold, unlit and lit with a 3-frame flicker, and there are string lights, a barn lantern whose flame flickers, a floor lamp, a nightstand lamp and a fireplace. For the meadow, a 64x64 tile of 12 fireflies drifts and blinks in a 16-frame loop and repeats without a seam.
  • Weather FX: 8 screen tints (night, dusk, dawn, storm, overcast, cold, heat, underwater), listed in its weather.json, so you can copy their colours into your gradient points. Its 33 seamless overlays add rain, fog and fireflies on top, and its 18 presets include a summer night and a foggy morning.

If your farm runs on a calendar too, how to make a farming RPG in pixel art covers the farmer, crops and seasons, and seamless weather in 2D games covers overlays that don't show their repeat.

A day and night checklist

  • One CanvasModulate per canvas, driven by a Gradient sampled at hour / 24, with the same colour at both ends.
  • Keep the ramp white through the day so the art shows as drawn.
  • HUD on a CanvasLayer; sky as a sprite, or set the clear colour from the clock.
  • Lamps in a group, faded with smoothstep at dawn and dusk; never full energy at noon.
  • Lit windows and fireflies with an unshaded material, faded in with the lamps.
  • Try Oklab for the colour space if dusk looks muddy, and Constant for a clock that moves hour by hour.

Gridwright packs can be used in commercial games, but you may not resell the files themselves; see can I use game assets in a commercial game. Packs released from October 28, 2026 ask for a credit, "Art by Gridwright", with a link, and each pack's LICENSE.txt says which applies. If your game needs night scenes or lights drawn for it, you can order a custom pack.

Found it useful? Share it

Get the art for your game

Our packs together in the $20 Megabundle, a custom pack drawn for your game, or the packs in this post from $9.99 each.

Best value

Gridwright Megabundle

Our packs and tools on itch.io in one bundle, for less than three of them one by one.

Get it for $20 (opens in a new tab)

Custom packs from $49

Not finding it? We draw it for your game, in 14 days or your money back.

Order a custom pack

Packs mentioned

Related guides