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.
randf_range(0.6, 1.4)every frame: 10.0, 19.4 and 46.8 flickers a second at 30, 60 and 144 fps, jumping by up to 0.78 between two frames.lerpf(light_energy, randf_range(0.6, 1.4), 0.2)every frame: smoother, but still 7.5, 15.3 and 37.5 flickers a second, and it only moved between about 0.8 and 1.2.FastNoiseLiteread by time with its defaultFRACTAL_FBM: 7.0 flickers a second at 30 fps and 23.9 at 144. Its values only reached -0.73 to 0.70.- The script,
FRACTAL_NONE: 5.6, 5.7 and 5.8 flickers a second, energy 0.62 to 1.34 at all three frame rates, 0.13 from the base on average. The noise itself went from -0.97 to 1.00. - Two torches with random start places: their brightness had a correlation of 0.01, so they flicker on their own. With the same start place: 1.00, the same flicker.
- A real OmniLight3D in the scene for 60 frames: 56 different brightness values, between 0.70 and 1.32, and it picked its own start place.
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
speed: about 6 for a torch, slower, like 3, for a big campfire, faster for a candle in a draft.amount: 0.4 swings the light by about 40% each way. Keep it under 1 so the light never goes out.- Flicker the flame's color too: use the same noise value to blend
light_colorbetween two warm colors. - The same by-time idea for movement: a pickup magnet at the same speed at any frame rate. Shaking the camera with noise: 3D camera shake. NPCs that should not move in step either: spread idle emotes across a crowd.
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
- Make the explosion as big as its damage
- Fire that turns to smoke in a cone
- Bright fire with dark smoke
- Smoke particles leave a hard line on the ground
- Particles drawing in the wrong order
- Explosion effect in one burst
- 3D debris particles not rotating
- Particles all disappear at once
- Muzzle flash with a real light
- Glowing particles in Godot 4
- Glowing particles cast dark shadows
- Particles from the surface of a mesh, at runtime
- Fireworks without sub-emitters
- Effects on the beat that stay on the beat
- Make a firework rocket burst at the top of its arc at any launch speed
- Fire or dust over a whole building
- Steam that turns to black smoke when the food burns