← Pixel Dreamer Studio

Hide particle effects far from the camera

Visibility Range End stops drawing them past a distance. The margin stops the blinking.

GPUParticles3D is a GeometryInstance3D, so it has visibility_range_end: past that distance from the camera it is not drawn. Set visibility_range_end_margin too. In our test, with an end of 30 m and a margin of 4 m, a torch went away past 34 m when the camera moved off and came back only inside 26 m, so a player standing near 30 m does not see it blink.

A row of six grey posts going into the distance. The three nearest have orange flames on top, the three far ones have none
The script below on six torches in a row, in Godot 4.7 with the Compatibility renderer. The three within 21 m of the camera are drawn. The three 37 m or more away are not: the grey posts show where they stand.

The code

Attach this to a GPUParticles3D for a looping torch flame. Put one on every torch in a level and only the ones near the camera are drawn. The two visibility lines are the fix.

extends GPUParticles3D
## A looping torch flame that is not drawn when the camera is far away.
## Put one on every torch in a level and only the near ones are drawn.


func _ready() -> void:
	visibility_range_end = 30.0  # the fix: not drawn when the camera is far away
	visibility_range_end_margin = 4.0  # gone past 34 m, back inside 26 m: no flicker at 30
	amount = 24
	lifetime = 0.8
	var m := ParticleProcessMaterial.new()
	m.direction = Vector3.UP
	m.spread = 12.0
	m.initial_velocity_min = 0.6
	m.initial_velocity_max = 1.0
	m.gravity = Vector3.ZERO
	m.scale_min = 0.6
	m.scale_max = 1.0
	process_material = m
	var mat := StandardMaterial3D.new()
	mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
	mat.billboard_mode = BaseMaterial3D.BILLBOARD_PARTICLES
	mat.albedo_color = Color(1.0, 0.55, 0.15)
	var q := QuadMesh.new()
	q.size = Vector2(0.3, 0.3)
	q.material = mat
	draw_pass_1 = q

What we measured

We moved the camera away from one torch and back, keeping the torch the same size on screen, and counted the lit points every second pixel. Two runs gave the same distances.

No fade in Compatibility

In the Compatibility renderer, which web exports use, visibility_range_fade_mode on Self did not fade the torch out. We could not test Forward+ on our machine, so the script leaves the fade off and uses the margin against blinking.

What to change

Particles that vanish while still close: GPUParticles3D not showing. A flame with smoke on top: fire and smoke with two emitters.

Tested in Godot 4.7 with the Compatibility renderer.

More how-tos: Play, stop and remove effects