godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.1k stars 21.16k forks source link

Converted Particle Shader corrupts GPUParticle Node under certain settings. #70737

Open peter-rocchio opened 1 year ago

peter-rocchio commented 1 year ago

Godot version

Godot4 Beta10 64-bit

System information

Windows 10, Vulkan

Issue description

A certain configuration of Particle Settings with a Particle Shader corrupts the scene with the particle node.

This only happens when the scene (or maybe project) is reloaded. Up until the point the scene or project need to be reloaded it seems to work fine. If the shader is saved before closing, then the shader itself can be opened properly but the process material field in the inspector will not recognize it as a valid shader.

I am not 100% certain which setting or configuration is causing it, or if it might be because it is a child node, but I kept creating new particles, changing some settings, and reloading the project until the cannot parse file error appeared. The settings I was changing when I encountered the bug were gravity, time, color ramp, texture, and I added a CanvasItemMaterial to set up an animation.

I was unable to narrow down exactly what is causing the issue, but I did manage to reproduce it with a clean project in Godot 4 Beta10 which is attached.

Steps to reproduce

  1. Create a Node2D scene
  2. Add a child GPUParticle
  3. Add a ParticleProcessMaterial
  4. Change the Settings (Add a Texture, Color Ramp, set up an animation with a CanvasItemMaterial, fiddle with other settings)
  5. Convert the ParticleProcessMaterial to a Shader
  6. Close the Project
  7. Reopen it
  8. Open the scene with the particle
  9. Observe "Error while parsing file" error
  10. If error does not appear go to step 3 and try again

Minimal reproduction project

ParticleShaderTest.zip

CBerry22 commented 1 year ago

I've just experienced what I believe to be the same issue, just with GPUParticle3D's.

When I try to convert the ParticleProcessMaterial to a shader, everything works until I reload the scene.

Also, if I save the shader script and try to apply that to a GPUParticle3D system without the conversion, the particles don't seem to spawn for some reason.

Godot version Godot 4.0.1 64-bit

System information Windows 11, Vulkan

TheRealOrangus commented 1 year ago

I believe I experience the same bug here (Godot 4.0.2 stable). Though for me it happens consistently.

When converting ParticleProcessMaterial -> ShaderMaterial, all the textures (CurveTexture etc) that the ParticleProcessMaterial uses, are reset to in the ShaderMaterial, at least if I look in the inspector.

I can't run any scene that contains that GPUParticle2D node, the game window would just close as soon as that GPUParticles2D exists (regardless whether by editor or through code), without throwing an error. Upon reloading project, I find that the scene that contained the original GPUParticles2D node, is now corrupted. Changing the renderer had no effect.

A workaround that worked for me was to go to the inspector of ParticleProcessMaterial, "save" all textures it uses into files, then after conversion, go to ShaderMaterial's shader parameters in its inspector, "quick-load" these files, then the scene file didn't get corrupted and this node didn't cause the game window to close.