Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUParticles3D collide with their gizmo icon, which can make them appear to not move at all if using the Point emission mode #101750

Closed
Calinou opened this issue Jan 18, 2025 · 3 comments · Fixed by #101947

Comments

@Calinou
Copy link
Member

Calinou commented Jan 18, 2025

Tested versions

  • Reproducible in: 4.4.beta1, 4.4.beta 7b1ed52
  • Not reproducible in: 4.3.stable

System information

Godot v4.4.beta (7b1ed52) - Fedora Linux 41 (KDE Plasma) on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (nvidia; 565.77) - 13th Gen Intel(R) Core(TM) i9-13900K (32 threads)

Issue description

GPUParticles3D collide with their gizmo icon, which can make them appear to not move at all if using the Point emission mode.

I bisected the regression to #91174. This likely occurs because making the gizmo material use alpha scissor means it's now taken into account by the heightfield collision generator. We can probably fix this by changing the cull mask of the GPUParticlesCollisionHeightField3D to exclude the editor-only gizmo layers (Node3DEditorViewport::GIZMO_EDIT_LAYER).

This is further proven by the collision's shape matching the GPUParticles3D gizmo icon. You can see this by using a sphere emission shape and greatly increasing the particle count:

Image

Relevant code:

void EditorNode3DGizmo::set_hidden(bool p_hidden) {
hidden = p_hidden;
int layer = hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER;
for (int i = 0; i < instances.size(); ++i) {
RS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer);
}
}

https://github.com/godotengine/godot/blob/7b1ed520bdcca21d36e25e2094802b9b33dae2c6/scene/3d/gpu_particles_collision_3d.cpp

Steps to reproduce

  • Set up a scene with various meshes and particles that have collision enabled.
  • Add a GPUParticlesCollisionHeightField3D node.
  • Save the scene and use Scene > Reload Saved Scene.
  • Notice how particles no longer move due to colliding with their gizmo.

Minimal reproduction project (MRP)

test_particle_collision_gizmo.zip

@Calinou
Copy link
Member Author

Calinou commented Jan 20, 2025

I've tried playing around with the VisualInstance3D layers property (which determines what the GPUParticlesCollisionHeightField3D takes into account when generating its collision shape). However, all collisions still occur as soon as layers is not equal to 0. If it's equal to 0, then all collision is disabled.

Changing cull_mask doesn't impact the collisions in any way (it's used to make different particles collide with different shapes instead; here, we want to exclude specific objects from the generated collision). Note that since cull_mask defaults to 0xFFFFFFFF and only the first 20 layers are visible in the editor, you'll need to set cull_mask = 0 in a @tool script to actually disable all layers (including the editor-specific layers that are otherwise hidden).

@Rudolph-B
Copy link
Contributor

Also interesting to note is that this occurs with all nodes that inherit from Node3D and have an icon.

Here it also collides with the icon of a AudioListener3D node.

Image

@Calinou
Copy link
Member Author

Calinou commented Jan 25, 2025

For reference, this happens now because the alpha-scissor gizmos are written to the depth buffer. GPUParticlesCollisionHeightField3D works by having its own viewport from a top-down view and reads the depth buffer. This is why you see the gizmos in a fixed orientation in the particle collision: they are still billboarded, but they are facing the camera used for the depth buffer generation.

Adding icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED); to EditorNode3DGizmoPlugin::create_icon_material() fixes the issue, but it reintroduces the issues that #91174 resolved (such as gizmos not appearing behind refractive materials anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

2 participants