← Pixel Dreamer Studio

Smoke particles leave a hard line on the ground

Proximity Fade turns the puff clear where it meets the floor.

A flat quad that goes into the floor is cut off in a straight line, and a soft smoke puff shows that line clearly. Turn on proximity_fade_enabled in the particles' StandardMaterial3D (Proximity Fade in the Inspector, off by default). The puff then fades where it comes close to what is behind it, such as the floor or a wall. proximity_fade_distance sets how wide that fade is, 1 meter by default. It works in the Compatibility renderer too.

Two groups of soft grey smoke puffs sitting on a brown floor. The left group ends in a straight bright line at the floor. The right group fades into the floor
The script below in Godot 4.7 with the Compatibility renderer. Left: Proximity Fade off. Right: the script as written.

The code

Attach this to a GPUParticles3D on the ground for slow smoke puffs. The puff is a GradientTexture2D, so there is no image file to import. The two proximity fade lines are the fix.

extends GPUParticles3D
## Smoke puffs that sit on the ground without a hard line where they cut into it.
## Proximity Fade makes each puff clear where it comes close to the floor or a wall.


func _ready() -> void:
	amount = 10
	lifetime = 4.0
	var m := ParticleProcessMaterial.new()
	m.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_BOX
	m.emission_box_extents = Vector3(1.2, 0.0, 0.4)
	m.direction = Vector3.UP
	m.spread = 10.0
	m.initial_velocity_min = 0.05
	m.initial_velocity_max = 0.15
	m.gravity = Vector3.ZERO
	process_material = m
	var dot := Gradient.new()  # a soft round puff without an image file
	dot.set_color(0, Color(1, 1, 1, 1))
	dot.set_color(1, Color(1, 1, 1, 0))
	var dt := GradientTexture2D.new()
	dt.gradient = dot
	dt.fill = GradientTexture2D.FILL_RADIAL
	dt.fill_from = Vector2(0.5, 0.5)
	dt.fill_to = Vector2(1.0, 0.5)
	var mat := StandardMaterial3D.new()
	mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
	mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
	mat.billboard_mode = BaseMaterial3D.BILLBOARD_PARTICLES
	mat.albedo_texture = dt
	mat.albedo_color = Color(0.75, 0.75, 0.8, 0.9)
	mat.proximity_fade_enabled = true  # the fix: fade out where the puff meets the floor
	mat.proximity_fade_distance = 0.5  # in meters: how far from the floor the fade starts
	var q := QuadMesh.new()
	q.size = Vector2(1.4, 1.4)
	q.material = mat
	draw_pass_1 = q

What we measured

One puff that does not move, with its middle on the floor, so the lower half is under it. The camera was 4 meters away and 0.8 meters up. We read the color on the puff 2, 5, 10, 20 and 40 cm above the floor (red/green/blue from 0 to 1). The floor itself was 0.22/0.20/0.18. Two runs gave the same numbers.

What to change

Smoke on top of a fire: fire and smoke with two emitters. Puffs that overlap in the wrong order: particles drawing in the wrong order. Particles that vanish behind water or glass: particles behind transparent water or glass.

Tested in Godot 4.7 with the Compatibility renderer.

More how-tos: Fire, smoke and explosions