godotengine / godotengine/godot

Particles do not appear when spawning on the edge of a GPUParticlesAttractor with zero attenuation

Open Beginner friendly
#108,293 0 comments 0 reactions 0 assignees View on GitHub
bug topic:particles
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.5.beta2, 4.4.1.stable, 4.3.stable, 4.2.2.stable, 4.1.4.stable, 4.0.4.stable.

### System information

Godot v4.4.1.stable - Windows 10 (build 19045) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 (NVIDIA; 32.0.15.7296) - 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz (16 threads)

### Issue description

Particles fail to spawn on the exact edge of geometric GPU particles attractors with attenuation set to exactly zero (`GPUParticlesAttractorBox3D`, `GPUParticlesAttractorSphere3D`, have not tested but shouldn't affect `GPUParticlesAttractorVectorField3D`)

The attenuation being barely higher, or the edge barely not intersecting will avoid this issue.

The bug occurs because of [this section](https://github.com/godotengine/godot/blob/53be3b78d1634406f1fb29e3802c608a5f5104a1/servers/rendering/renderer_rd/shaders/particles.glsl#L489) of the particle shader, where the math works out to `pow(0.0, 0.0)` which is [undefined in GLSL](https://registry.khronos.org/OpenGL-Refpages/gl4/html/pow.xhtml). To avoid any extra instructions in the shader for this edge case, maybe the attenuation parameter should be clamped with an extremely small epsilon before being sent off to the GPU?

https://github.com/user-attachments/assets/d1ad1a50-0d5c-497b-be2a-efcde783cfca

Admittedly not a very high priority bug with how easily it's worked around, but it had me confused for a good minute while setting up some VFX since I missed when it stopped emitting and couldn't figure out what was causing it.

### Steps to reproduce

1. Add a `GPUParticles3D` and give it a default `ParticleProcessMaterial` and `QuadMesh` draw pass
2. Add a `GPUParticlesAttractorBox3D` to the scene and position it so that one of its faces intersects the position of the particle system
3. Right click the attractor's attenuation property and set it to zero through the dropdown

### Minimal reproduction project (MRP)

[mrp-particle-attractor-zero-attenuation.zip](https://github.com/user-attachments/files/21066445/mrp-particle-attractor-zero-attenuation.zip)

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior with the linked MRP, then inspect servers/rendering/renderer_rd/shaders/particles.glsl around the referenced particle-attractor calculation. Verify the result at an attractor edge with attenuation set to zero, and confirm that particles spawn there without changing normal attractor behavior.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.