0 votes

Hi,

Just want to check if other people are experiencing the same issue. I have a Particle emitter that is not emitting by default. The amount is set to 100. The particles are sphere with standard ParticlesMaterial.

When I turn emitting on, the game freeze for some frame, I'm not sure how long exactly but it is quite noticeable. I'm on a 970M, the game usually run at around 400fps without v-sync (v-sync is on all the time).

in Engine by (1,044 points)

You can use built-in profiler to check which part/script spikes during freeze. Please let us know what it says.

All I see with the profiler is a spike in the idle time, therefore an increase of the frame time (almost double).

OK, then we are closer. Please stop profiler after such a spike, click on the spike and on the list of functions on the left scroll down to see what function takes the longest time and spikes alongside of Idle. Maybe you've got a Timer, that is processed on Idle time?

That's the weird thing, I don't see any other spike in all the of the measured functions.

I've got a Timer but it is a single shot that only set a boolean variable, and it is used at other moment without creating this spike.

If I find the time I will try to make a test project to try to replicate this specific issue.

If you will have a project, send a link, so I could see what's there :)

Yes I'll try, I cannot post the actual project, so I have to extract the faulty part to a test project first, I'll let you know, this is not a critical issue for me right now.

1 Answer

0 votes

Particles use material/shaders. In OpenGL any new shader that is loaded needs to be complied, hence the lag spike.

Godot 4.0 will supposedly cache them ahead of time. In the mean time you need to cache them yourself.

https://godotengine.org/qa/73069/how-to-make-sure-all-shaders-are-pre-cached-to-avoid-lag-spikes

https://travismaynard.com/writing/caching-particle-materials-in-godot

https://www.youtube.com/watch?v=Cg4ZT6X0ghs

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.