← Pixel Dreamer Studio

A torch light that flickers the same on every screen

Read a smooth noise by time, with one layer, and start each torch at its own place in the noise.

Setting light_energy = randf_range(0.6, 1.4) every frame changes the light once per frame, so the flicker speed is the frame rate: in our Godot 4.7 test it flickered 10 times a second at 30 fps and 47 at 144. Read a FastNoiseLite by time instead, and set its fractal_type to FRACTAL_NONE: the default extra layers add tiny wiggles that only a fast screen shows, 7 flickers a second at 30 fps but 24 at 144. With one layer the script below flickered 5.6 to 5.8 times a second at 30, 60 and 144 fps, between the same 0.62 and 1.34, and two torches started at random places moved independently.

The code

Put this script on the OmniLight3D of your torch or campfire. base_energy is the light's normal brightness, amount how far it dips and flares, speed how fast. Leave offset at -1 and every torch picks its own place in the noise, so a row of torches does not pulse together.

extends OmniLight3D
## Torch or campfire light that flickers at the same speed at any frame rate,
## and never in step with the torch next to it. Put it on the fire's OmniLight3D.

@export var base_energy := 1.0
@export var amount := 0.4  # how hard it dips and flares
@export var speed := 6.0  # bigger = faster flicker
@export var offset := -1.0  # where in the noise this torch starts, -1 = random

var _noise := FastNoiseLite.new()
var _time := 0.0


func _ready() -> void:
	_noise.frequency = 1.0
	_noise.fractal_type = FastNoiseLite.FRACTAL_NONE  # one smooth layer: the default extra layers add tiny wiggles only fast screens show
	if offset < 0.0:
		offset = randf() * 1000.0
	light_energy = base_energy


func _process(delta: float) -> void:
	_time += delta  # by time, not by frame
	var n := _noise.get_noise_1d(offset + _time * speed)  # smooth, -1 to 1
	light_energy = maxf(base_energy * (1.0 + amount * n), 0.0)

What we measured

10 seconds of light energy at 30, 60 and 144 frames a second, with the same random seed each time, counting how many times a second the light turns from brighter to dimmer. Then two torches side by side, and one real OmniLight3D in the scene running its own frames. Two runs gave the same numbers.

Why it happens

A new random number every frame is a new flicker every frame, so a 144 Hz screen gets almost five times as many as a 30 Hz one. Noise is a smooth curve you read by position: move along it by time and every screen sees the same curve, only drawn with more or fewer frames. The default noise, FRACTAL_FBM, stacks smaller and faster layers on top. A slow frame rate steps over their little bumps, a fast one catches them all, so it still looks busier on a fast screen. One layer has no bumps smaller than the ones you asked for.

What to change

Ready-made pixel fire: Pixel Art 3D VFX for Godot 4 has a Torch Flame in orange and green with a flickering light, Campfires, and 36 more crisp pixel art effects with 4-color palettes and dithering, plus PixelView to render your 3D world at low resolution.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: Pixel Art 3D VFX for Godot 4 has a Torch Flame in orange and green with a flickering light, Campfires and 36 more crisp pixel art effects with 4-color palettes and dithering.

More how-tos for Pixel Art 3D VFX for Godot 4: Pickups that fly to the player in the same time at any frame rate · Keep a smooth follow camera, but jump with the player when they teleport

More how-tos: Fire, smoke and explosions