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

GPU usage increases considerably only enabling 2D particles turbulence #76501

Closed
canepazzo77 opened this issue Apr 27, 2023 · 20 comments · Fixed by #76598
Closed

GPU usage increases considerably only enabling 2D particles turbulence #76501

canepazzo77 opened this issue Apr 27, 2023 · 20 comments · Fixed by #76598

Comments

@canepazzo77
Copy link

canepazzo77 commented Apr 27, 2023

Godot version

4.x

System information

Windows 10, RTX 3070

Issue description

Using 2D particles when enabling turbulence GPU usage increases dramatically.

Without Turbulence:
ParticlesNoTurbulence

With Turbulence:
ParticlesWithTurbulence

Steps to reproduce

Add GPUParticles2D, add particle process material and enable turbulence

Minimal reproduction project

see steps

@and-rad
Copy link
Contributor

and-rad commented Apr 27, 2023

By how much is it increasing, exactly? This looks like less than a millisecond, which isn't great but sounds about right to me.

@canepazzo77
Copy link
Author

By how much is it increasing, exactly? This looks like less than a millisecond, which isn't great but sounds about right to me.

Every Particles node increase it about 0.4ms

@Zireael07
Copy link
Contributor

IIRC turbulence uses noise, and IIRC 3d noise at that, which isn't free - 0.4ms sounds just about in the right ballpark

@canepazzo77
Copy link
Author

ah, ok, I thouht an increase of 0,4ms for each node was much

@and-rad
Copy link
Contributor

and-rad commented Apr 27, 2023

So, should this be closed? We can always argue whether 0.4ms is a "considerable" increase for adding a bunch of noise lookups in a shader, but I'm inclined to file this under "works as expected". Texture lookups aren't cheap.

@canepazzo77
Copy link
Author

Yes

@Calinou
Copy link
Member

Calinou commented Apr 27, 2023

I remember seeing this being reported elsewhere, but I can't find it right now. Either way, 0.4 mspf on a RTX 3070 isn't a huge increase for something that you'll probably use with a few particle systems at once on screen at most. (Turbulence is not something you should enable on every particle system after all.)

This may be improved by #64606, although its main focus is making it more flexible. Feel free to test that PR locally 🙂

@canepazzo77
Copy link
Author

0.4 mspf on a RTX 3070 isn't a huge increase

But on mobile is that high? Because I wanted to use them in a mobile game

This may be improved by #64606, although its main focus is making it more flexible. Feel free to test that PR locally 🙂

I will try it

@and-rad
Copy link
Contributor

and-rad commented Apr 27, 2023

On mobile everything is high. Turbulence might not even work on mobile platforms at all, at least not in the Compatibility renderer. Have you ever exported and tested your project on a mobile device yet?

@canepazzo77
Copy link
Author

canepazzo77 commented Apr 27, 2023

Nevermind, I tried, it make the game crash

@QbieShay
Copy link
Contributor

QbieShay commented Apr 29, 2023

Both the generation of the 3D noise and the calculation of the gradient (curl formula?) of the noise are known to be expensive operations.
There's alternatives such as baking the noise on a 2D texture and using this texture for the particle motion (since this is about 2D).

If you can tell a bit more about the effects you want to achieve, we can think about solutions together.

I think overall this is a documentation issue. Perhaps the engine can warn when enabling turbulence that it's an expensive feature.

@canepazzo77
Copy link
Author

I want to make a fire effect, like this

2023-04-30.11-22-25.mp4

@Calinou
Copy link
Member

Calinou commented Apr 30, 2023

I want to make a fire effect, like this

Turbulence sounds like a bad fit here. Using linear/angular velocity/acceleration and perhaps some damping should get you a convincing effect already.

At a small scale like this, you could also simulate a turbulence effect by rotating the particles node using an AnimationPlayer, as long as Local Coords is disabled.

@canepazzo77
Copy link
Author

I think overall this is a documentation issue. Perhaps the engine can warn when enabling turbulence that it's an expensive feature.

I checked several times and there does not seem to be, I think there should be also written in the documentation that does not work on mobile (at least it doesn’t work on phones where i tried it)

@canepazzo77
Copy link
Author

perhaps some damping should get you a convincing effect already.

thanks, damping made it look very similar, it was the setting I was missing

@QbieShay
Copy link
Contributor

Slowdown's been documented, OP seem to have achieved the effect they were looking for. Good work everyone!

@RPicster
Copy link
Contributor

RPicster commented Oct 22, 2023

One thing about this Issue brought up a thought.
I would love to see if the original 4.0 version of the turbulence calculation (the old one using only a "panning" noise instead of 4D noise) would have a compareable impact on performance.

Is there some way of testing this?
@QbieShay @clayjohn

I reopened the issue - if that is something we should put in another issue or discuss somewhere else - feel free to close it ;)

@clayjohn
Copy link
Member

One thing about this Issue brought up a thought. I would love to see if the original 4.0 version of the turbulence calculation (the old one using only a "panning" noise instead of 4D noise) would have a compareable impact on performance.

Is there some way of testing this? @QbieShay @clayjohn

I reopened the issue - if that is something we should put in another issue or discuss somewhere else - feel free to close it ;)

You could copy the shader from an older project and then you could compare them side-by-side (i.e. by creating a ParticlesProcessMaterial and converting to a shader material)

@QbieShay
Copy link
Contributor

@RPicster we did perf test at the times when K made the new turbulence and there wasn't any perf impact that we could see

@RPicster
Copy link
Contributor

RPicster commented Oct 22, 2023

Perfect, I remembered it. Just though I'd bring it up again in case it was related.

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

Successfully merging a pull request may close this issue.

7 participants