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

GPUParticles2D Turbulence parameters are affected by the rectangular (box) emission shape and particle flags #74541

Open
Novark opened this issue Mar 7, 2023 · 14 comments

Comments

@Novark
Copy link

Novark commented Mar 7, 2023

Godot version

v4.0.stable.official [92bee43]

System information

Windows 11 [Vulkan]

Issue description

The turbulence influence min/max properties seem to apply across the emitter shape in a linearly increasing fashion instead of randomly on a per-particle basis as per the documentation:

The actual amount of turbulence influence on each particle is calculated as a random value between turbulence_influence_min and turbulence_influence_max and multiplied by the amount of turbulence influence from turbulence_influence_over_life.

IMPORTANT: This issue is resolved when the "Disable Z" Particle Flags checkbox is un-checked. This checkbox is enabled by default when the GPUParticles2D node is enabled.

P.S. the documentation for turbulence_influence_min and turbulence_influence max are incorrectly swapped.

image

Steps to reproduce

To reproduce this is fairly simple:

  1. Create a GPUParticles2D Node
  2. Emit a significant number of particles (I'm emitting 50,000) and set the emission shape to "Box" (X=500, Y=1, Z=1)
  3. Set the gravity to (X=0, Y=1000, Z=0), and enable turbulence
  4. Set the turbulence_influence_min property to 0.1 (default) and turbulence_influence_max to 1
  5. Observe how the turbulence influence applies the "min" value to the left of the emission shape, and linearly scales up to the "max" value to the right of the emission shape.

The expected behaviour would have the turbulence influence take a random value between [min, max] and apply a random value to each particle along the emission shape.

Un-check the "Disable Z" Particle Flag to see the intended behaviour. I'm unsure why this checkbox is affecting the way turbulence influence is distributed across the emission shape, but it may have something to do with the way VELOCITY is being calculated in the shader. Digging into the code a bit, it seems that there's some pretty large discrepancies with how the velocity spread is calculated for PARTICLE_FLAG_DISABLE_Z enabled vs. disabled. I'm not familiar enough with the code to say for certain where this might be occurring, however.

Minimal reproduction project

No sample project provided, as the reproduction is quite simple to replicate.

@Novark Novark changed the title GPUParticles2D Turbulence parameters apply to rectangular (box) emission shape GPUParticles2D Turbulence parameters are affected by the rectangular (box) emission shape and particle flags Mar 7, 2023
@clayjohn clayjohn added this to the 4.x milestone Mar 7, 2023
@clayjohn
Copy link
Member

clayjohn commented Mar 7, 2023

Might be fixed by #64606

@QbieShay
Copy link
Contributor

Hey, #64606 was superseded by #77154 . Can you test if the issue persists?

@Novark
Copy link
Author

Novark commented May 22, 2023

Hey, #64606 was superseded by #77154 . Can you test if the issue persists?

I don't have my environment set up at the moment to be able to build from source. Is there anywhere I can grab a compiled build of the master branch? If not, I'll be happy to test this in the next pre-release distribution.

@Novark
Copy link
Author

Novark commented May 25, 2023

Hey, #64606 was superseded by #77154 . Can you test if the issue persists?

I've just tested this in v4.1.dev3.official [a67d37f], and the issue still persists. Moreover, the new implementation doesn't seem very "turbulent" at all - I'm not sure why this is, but playing with the turbulence settings, I'm not able to get anywhere near the same behaviour as before. Particles just seem to wiggle around a little bit now, but the visual characteristics are completely different. Please let me know if there's something that I'm missing with the new implementation, and I can re-test.

Edit: I've filed a new bug report for the unexpected turbulence changes. See #77491 for details

image

@KdotJPG
Copy link
Contributor

KdotJPG commented May 30, 2023

It seems to have something to do with the distribution of the results of rand_from_seed(alt_seed) after certain numbers of calls. Adding one dummy call before the line here seems to fix it.

image

I'd like to better figure out what exactly is causing the issue to begin with, though.

@QbieShay
Copy link
Contributor

Hey @KdotJPG , did you figure it out in the end? Otherwise we can just add an extra random call and call it a day.

@QbieShay
Copy link
Contributor

@Novark could you test with #74541 ?

@Novark
Copy link
Author

Novark commented Jul 31, 2023

@Novark could you test with #74541 ?

Issue still persists in v4.2.dev2.official

@QbieShay
Copy link
Contributor

The PR isn't merged yet, it needs to be tested on a custom build. In the checks tab of the PR, there's an "artifacts" button. You can download the custom build from there:
image

Please test on an empty project with just one turbulence particle system, this is a WIP PR and may change existing particle systems (although it shuoldn't)

@Novark
Copy link
Author

Novark commented Jul 31, 2023

The PR isn't merged yet, it needs to be tested on a custom build. In the checks tab of the PR, there's an "artifacts" button. You can download the custom build from there: [Image])

Please test on an empty project with just one turbulence particle system, this is a WIP PR and may change existing particle systems (although it shuoldn't)

Alright, I've tested it with your PR and noticed the following things:

  • The original issue seems to be resolved (with the linear turbulance influence variation from left-to-right)
  • However, there are some other strange effects happening when I set up the same particle system parameters
  • There is some weird particle jitter going on when using the settings I outlined in my original bug report. Compare the following image with the other images in this thread (somewhat difficult to explain through text - recommend setting up a GPUParticles2D with the settings described in my original bug report above. Jitter appears to be introduced as turbulence_influence_max increases - increasingly noticeable at values > 0.75 or so ):
  • To really get a feel for this strange jitter - try changing the GPUParticles2D speed_scale (Under the "Time" parameters) value to 0.1 and observe the results. It's almost like every particle is constantly bouncing between (Y+0) and (Y+16) positions or something - like some Y-positional fighting for even / odd render frames. You can see each particle "doubling up" in the Y-direction. Additionally, the entire particle system also jitters. You'll randomly see the whole system "jump" for about a frame. This particle-system-wide-jitter seems to happen even when turbulence is disabled. I do not observe this jitter with CPUParticles2D.

image

  • Noise scale also has a strange effect on the resulting particle system. For values between around 0 - 8.5, there's almost zero effect. From 8.5 to 10, it has an effect, but as the value approaches 10, the effect breaks down. There's obviously an exponential effect taking place here, but it's very un-intuitive to have 85% of the parameterized range do nothing, and only the final 15% has any effect - with the effect breaking down entirely at the maximum value.

@QbieShay
Copy link
Contributor

QbieShay commented Aug 1, 2023

Does it happens also if you turn off interpolation?

@Novark
Copy link
Author

Novark commented Aug 1, 2023

Does it happens also if you turn off interpolation?

Disabling interpolation seemed to fix a lot of the system-wide jitter (the Y-position issue I described above). I'm assuming this behaviour is not intended. Let me know if you want me to open a new bug report for it.

The turbulence jitter that occurs when turbulence_influence_max is cranked up still persists, however.

@Calinou
Copy link
Member

Calinou commented Aug 1, 2023

Disabling interpolation seemed to fix a lot of the system-wide jitter (the Y-position issue I described above). I'm assuming this behaviour is not intended. Let me know if you want me to open a new bug report for it.

Interpolation issues are already being tracked in #51318.

@QbieShay
Copy link
Contributor

QbieShay commented Aug 1, 2023

Thank you @Novark ! I'll investigate the issue with max turbulence and try to address it with my PR. If I don't figure it out I'll address it in a subsequent PR.

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

5 participants