godotengine / godotengine/godot
Wierd particle state after reset the process material in GPUParticle2D
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Godot v4.3.dev (89cc635c0)
### System information
Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.4601) - 12th Gen Intel(R) Core(TM) i7-12700F (20 Threads)
### Issue description
When trying to debug https://github.com/godotengine/godot/issues/87123, I sometimes notice that after reset the process material, the particle will go crazy like below:

give it the shader for the first time might looks like this:

I admit the shader here is not that valid, but it does look like that some state is not inited well. And even the shader is not good, reset it is supposed to give the correct ( normal ) result.
```
shader_type particles;
void start() {
// Called when a particle is spawned.
USERDATA1 = vec4(1.0f,1.0,1.0f,1.0);
}
void process() {
// Called every frame on existing particles (according to the Fixed FPS property).
//TRANSFORM[3] = USERDATA1;
}
```
See the video below, sometimes I can get the wierd result at the first try:
https://github.com/godotengine/godot/assets/8315986/1c501e0a-329d-4fb3-88c8-bc6ca434c210
### Steps to reproduce
1. Make a GPUParticle2D
2. Give it a texture
3. Give it a Shader material and the related shader
4. reset and re-assign serveral times, observe
### Minimal reproduction project (MRP)
[GPUParticle2D.zip](https://github.com/godotengine/godot/files/13932158/GPUParticle2D.zip)
Contributor guide
Research direction
Start with the attached GPUParticle2D minimal reproduction project and follow the listed steps, repeatedly resetting and reassigning the process material. Compare the particle state after each reset and trace the particle shader/material reset path; done means resetting consistently restores the normal particle result without the corrupted state.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100