← Pixel Dreamer Studio

Snow that stays on roofs

Rigid collisions with no bounce and full friction: the flakes land and stay until their lifetime runs out.

Put a GPUParticlesCollisionBox3D on each roof, set the snow's collision_mode to COLLISION_RIGID, collision_bounce to 0 and collision_friction to 1. The flakes land on the roof and stay there until their lifetime runs out. In our Godot 4.7 test, a band just above the roof held 445 lit points after 6 seconds. With COLLISION_HIDE_ON_CONTACT, the usual setting for rain, it held 44 to 45, about the same as with collisions off: only flakes still in the air.

Two brown roofs in falling snow. The left roof is bare, the right one is covered with white flakes
Godot 4.7 with the Compatibility renderer, 6 seconds in, enlarged 2 times. Left: collision_mode Hide On Contact, the flakes vanish on the roof. Right: the script.

The code

Attach this to a GPUParticles3D above the roofs. Every roof needs its own GPUParticlesCollisionBox3D the size of the roof. The three collision lines are the fix. lifetime sets how long a flake can stay: it disappears 8 seconds after it was born, landed or not.

extends GPUParticles3D
## Snow that lands on roofs and stays there, instead of vanishing, falling through or sliding off.
## The roofs need particle colliders, such as a GPUParticlesCollisionBox3D on each one.


func _ready() -> void:
	amount = 600
	lifetime = 8.0  # a flake disappears 8 s after it was born, landed or not
	visibility_aabb = AABB(Vector3(-5, -6, -3), Vector3(10, 8, 6))
	var m := ParticleProcessMaterial.new()
	m.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_BOX
	m.emission_box_extents = Vector3(4, 0.1, 2)
	m.direction = Vector3.DOWN
	m.spread = 25.0
	m.initial_velocity_min = 0.5
	m.initial_velocity_max = 1.0
	m.gravity = Vector3(0, -1.5, 0)
	m.collision_mode = ParticleProcessMaterial.COLLISION_RIGID  # land on colliders
	m.collision_bounce = 0.0  # no bounce
	m.collision_friction = 1.0  # stop sliding at once
	process_material = m
	collision_base_size = 0.05
	var mat := StandardMaterial3D.new()
	mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
	mat.billboard_mode = BaseMaterial3D.BILLBOARD_PARTICLES
	var q := QuadMesh.new()
	q.size = Vector2(0.08, 0.08)
	q.material = mat
	draw_pass_1 = q

What we measured

A 3 by 2 m roof with a collision box the same size, and snow starting about 3 m above it. We counted lit points in a band just above the roof, 3 and 6 seconds after the snow started. Two runs of each.

A thicker layer

Each flake still disappears when its lifetime ends, so the roof holds at most what amount and lifetime allow. For a thicker layer, raise both.

What to change

Rain that should vanish on the roof instead: rain falling through a roof. Snow that hangs in the air: snow particles not falling.

Tested in Godot 4.7 with the Compatibility renderer.

More how-tos: Auras, rings, beams and weather