← Pixel Dreamer Studio

Particle texture shows a square box

The clear parts of the texture need a transparent material.

A new StandardMaterial3D has transparency off, so it ignores the alpha of your texture and draws the whole square. Set transparency to Alpha (Transparency in the Inspector) and the clear edges of a dot or puff stay clear. A texture with a black background and no alpha, such as a JPG glow, still shows a black box with Alpha: set blend_mode to Add instead.

Two fountains of white particles on a grey-blue background. The left ones are solid white squares. The right ones are soft round dots
The script below in Godot 4.7 with the Compatibility renderer. Left: Transparency left off. Right: the script as written.

The code

Attach this to a GPUParticles3D for soft white dots that drift up. The script draws the dot itself with a GradientTexture2D, so it runs as it is: put your own texture in its place. The transparency line is the fix. The commented line is for textures on a black background.

extends GPUParticles3D
## Soft glowing dots from a texture with clear edges, without a square box around each one.
## The texture goes into the draw material, and that material needs transparency on.


func _ready() -> void:
	amount = 20
	lifetime = 1.5
	var m := ParticleProcessMaterial.new()
	m.direction = Vector3.UP
	m.spread = 25.0
	m.initial_velocity_min = 0.6
	m.initial_velocity_max = 1.0
	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.albedo_texture = make_dot()  # or preload("res://your_dot.png")
	mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA  # the fix: clear parts of the texture stay clear
	# A texture on a black background with no alpha (a JPG glow) needs this instead:
	# mat.blend_mode = BaseMaterial3D.BLEND_MODE_ADD
	var q := QuadMesh.new()
	q.size = Vector2(0.3, 0.3)
	q.material = mat
	draw_pass_1 = q


func make_dot() -> Texture2D:
	# white in the middle, fading to fully clear at the edge
	var g := Gradient.new()
	g.set_color(0, Color(1, 1, 1, 1))
	g.set_color(1, Color(1, 1, 1, 0))
	var t := GradientTexture2D.new()
	t.gradient = g
	t.fill = GradientTexture2D.FILL_RADIAL
	t.fill_from = Vector2(0.5, 0.5)
	t.fill_to = Vector2(1.0, 0.5)
	return t

What we measured

One particle that does not move, 1 meter wide, on a grey-blue background (0.30/0.35/0.45). We read the color in the middle, in the corner of the square, and 30 cm out from the middle, on the soft edge of the dot. Two runs gave the same numbers.

Textures on a black background

We made a second texture, white in the middle going to black, with no clear parts at all, like a glow saved as a JPG.

What to change

Soft puffs drawn in the wrong order: particles drawing in the wrong order. A color ramp that also fades out needs transparency too: particle color ramp not working. Dots that glow: glowing particles.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: 12 Free VFX Textures is free and has 6 white-on-black shape masks (soft glow, ring, star, spark, slash arc, magic circle) made for blend_mode Add.

More how-tos: When particles do not show up