← Pixel Dreamer Studio

Particle color over lifetime not working

The ramp goes into the vertex color. The draw material has to use it.

The color_ramp of a ParticleProcessMaterial sets each particle's vertex color. A StandardMaterial3D ignores vertex color unless vertex_color_use_as_albedo is on (Vertex Color, Use as Albedo in the Inspector), so the particles stay white. If the ramp also fades out, set transparency to Alpha too, or the fade is ignored. The same checkbox makes color and Hue Variation in the process material work.

Two rising streams of small squares: white on the left, yellow turning orange, red and dark on the right
The script below in Godot 4.7 with the Compatibility renderer. Left: Use as Albedo turned off. Right: the script as written.

The code

Attach this to a GPUParticles3D for embers that go from yellow to red and fade out. The two commented lines in the material are the fix.

extends GPUParticles3D
## Embers that go from yellow to red and fade out over their life.
## The color comes from color_ramp in the process material. Two material settings
## below decide whether you see it at all.


func _ready() -> void:
	amount = 30
	lifetime = 2.0
	var ramp := Gradient.new()
	ramp.offsets = PackedFloat32Array([0.0, 0.5, 1.0])
	ramp.colors = PackedColorArray([Color(1.0, 0.9, 0.3, 1.0), Color(1.0, 0.25, 0.05, 1.0), Color(0.3, 0.05, 0.0, 0.0)])
	var rt := GradientTexture1D.new()
	rt.gradient = ramp
	var m := ParticleProcessMaterial.new()
	m.color_ramp = rt
	m.direction = Vector3.UP
	m.spread = 20.0
	m.initial_velocity_min = 0.8
	m.initial_velocity_max = 1.2
	m.gravity = Vector3.ZERO
	process_material = m
	var mat := StandardMaterial3D.new()
	mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
	mat.billboard_mode = BaseMaterial3D.BILLBOARD_PARTICLES
	mat.vertex_color_use_as_albedo = true  # without this, color_ramp is ignored
	mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA  # without this, the alpha in the ramp is ignored
	var q := QuadMesh.new()
	q.size = Vector2(0.15, 0.15)
	q.material = mat
	draw_pass_1 = q

What we measured

We let out one particle that does not move, in the middle of the screen, with a lifetime of 2 seconds, and read the pixel color (red/green/blue from 0 to 1) at three points of its life. Two runs gave the same picture.

Color and Hue Variation need it too

color, hue_variation_min and hue_variation_max in the ParticleProcessMaterial also reach the particle as vertex color. We took the script above, removed the ramp and tried each setting in two runs.

What to change

A flame that turns into smoke with two emitters: fire and smoke. Particles that do not show at all: GPUParticles3D not showing. Your own ShaderMaterial instead: custom particle shader ignores the color ramp. Recoloring one copy of an effect recolors them all: change the color of one particle effect.

Tested in Godot 4.7 with the Compatibility renderer.

More how-tos: When particles do not show up