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

When both Collision and Turbulence are enabled, GPUParticles2D and GPUParticles3D will freeze and spam error messages #83858

Closed
golddotasksquestions opened this issue Oct 23, 2023 · 2 comments · Fixed by #83881

Comments

@golddotasksquestions
Copy link

golddotasksquestions commented Oct 23, 2023

Godot version

4.2 Beta2

System information

Win 10, Nvidea 765M

Issue description

When both Collision and Turbulence is enabled, GPUParticles2D and GPUParticles3D will freeze and spam error messages.
Both Collision and Turbulence work fine when the other is not enabled.

Error message:

No compute pipeline was set before attempting to draw.
drivers/vulkan/rendering_device_vulkan.cpp:7892 - Parameter "pipeline" is null.
This compute pipeline requires (0) bytes of push constant data, supplied: (32)

Steps to reproduce

  1. Add GPUParticles2D or GPUParticles3D node
  2. Add texture/draw mesh and ParticleProcessMaterial
  3. Enable Collision by setting it to "Rigid" in the ParticleProcessMaterial
  4. Enable Turbulence
  5. Observe the freeze and error spam

Minimal reproduction project

N/A
easier to follow the steps.

@golddotasksquestions golddotasksquestions changed the title When both Collision and Turbulence is enabled, GPUParticles2D and GPUParticles3D will freeze and spam error messages When both Collision and Turbulence are enabled, GPUParticles2D and GPUParticles3D will freeze and spam error messages Oct 23, 2023
@clayjohn clayjohn added this to the 4.x milestone Oct 23, 2023
@clayjohn clayjohn modified the milestones: 4.x, 4.2 Oct 23, 2023
@clayjohn
Copy link
Member

Looks like when using turbulence with collisions the noise_direction variable is used before it is initialized

code += " noise_direction = vec3(1.0, 0.0, 0.0);\n";

code += " vec3 noise_direction = get_noise_direction(TRANSFORM[3].xyz);\n";

The respective functions will need to be re-ordered a bit closer to what they were in 4.1.

@jsjtxietian
Copy link
Contributor

Final output shader:

  406 | 	if (COLLIDED) {
  407 | 		if (length(VELOCITY) > 3.0) {
  408 | 			TRANSFORM[3].xyz += COLLISION_NORMAL * COLLISION_DEPTH;
  409 | 			VELOCITY -= COLLISION_NORMAL * dot(COLLISION_NORMAL, VELOCITY) * (1.0 + collision_bounce);
  410 | 			VELOCITY = mix(VELOCITY,vec3(0.0),clamp(collision_friction, 0.0, 1.0));
  411 | 		} else {
  412 | 			VELOCITY = vec3(0.0);
E 413-> 			noise_direction = vec3(1.0, 0.0, 0.0);
  414 | 		}
  415 | 	}
  416 | 	vec3 final_velocity = controlled_displacement + VELOCITY;
  417 | 	
  418 | 	// turbulence before limiting
  419 |    float turbulence_influence = 1.0;
  420 | 		
  421 | 	vec3 noise_direction = get_noise_direction(TRANSFORM[3].xyz);
  422 | 	if (!COLLIDED) {
  423 | 	
  424 | 		float vel_mag = length(final_velocity);
  425 | 		float vel_infl = clamp(dynamic_params.turb_influence * turbulence_influence, 0.0,1.0);
  426 | 		final_velocity = mix(final_velocity, normalize(noise_direction) * vel_mag * (1.0 + (1.0 - vel_infl) * 0.2), vel_infl);
  427 | 	}

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