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

Wierd particle state after reset the process material in GPUParticle2D #87178

Open
Tracked by #61067
jsjtxietian opened this issue Jan 14, 2024 · 1 comment
Open
Tracked by #61067

Comments

@jsjtxietian
Copy link
Contributor

Tested versions

Godot v4.3.dev (89cc635)

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 #87123, I sometimes notice that after reset the process material, the particle will go crazy like below:

image

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

image

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:

Test.tscn.-.min-repro-11-25-23.-.Godot.Engine.2024-01-14.23-57-08.mp4

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

@robbertzzz
Copy link

robbertzzz commented Jun 13, 2024

I'm seeing the same thing after testing #87123 as well. It looks like (un)commenting the USERDATA1 variable will constantly trigger a different glitch. It also happens with the other USERDATA variables for me.

Closing and reopening the project seems to fix the issue, so I don't think the repro project in the OP will be of much use (also similar to #87123). My guess would be that memory isn't being allocated for USERDATA variables until the initial shader compilation if it does contain that variable, and USERDATA overwrites other particle variables in memory in all other cases.

[edit]

Changing the amount parameter also seems to fix the issue

Also of note, each line you see in the screenshot in OP is a separate particle, as can be determined by the updated draw order. So it seems different portions of memory are being written to for each separate particle.

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

No branches or pull requests

3 participants