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

Not emitted particles affects performance #19507

Closed
kubecz3k opened this issue Jun 11, 2018 · 7 comments · Fixed by #19764
Closed

Not emitted particles affects performance #19507

kubecz3k opened this issue Jun 11, 2018 · 7 comments · Fixed by #19764
Assignees
Milestone

Comments

@kubecz3k
Copy link
Contributor

Godot version:
257d3c3

OS/device including version:
nvidia gtx 1060, Ubuntu 18.04

Issue description:
I recently tried to find out why I have such performance problems in my game and I have found an interesting thing. Particle 3D node seems to be processing/rendering even if it's not emitting any particles. It can affect performance heavily especially in the scenario when you have a lot of nodes on the screen which are holding some 'visibly rich' particle effects, that are meant to be used rarely (like hit/death effect)

Steps to reproduce:
Full:

  1. Create new scene, add Particle node and camera
  2. Add cylinder as a particle model in Draw Passes
  3. Add Particles material as process material
  4. Turn off Emitting property
  5. Set amount of particles to 100000
  6. Run scene and check number of fps
  7. Hide Particle node
  8. Run scene again and notice a lot higher number of fps

Quick:

  1. Download project with reproduction scene
  2. Run it, notice number of fps
  3. Hide particle node
  4. Run scene again, notice number of fps

Minimal reproduction project:
NonEmittedParticlesPerformance.zip

@akien-mga akien-mga added this to the 3.1 milestone Jun 11, 2018
@malbach
Copy link
Contributor

malbach commented Jun 14, 2018

Hi,
It looks like it is because the particules are still computed by the CPU and the GPU, even if not rendered (the small dot running in circle in the top right corner of the editor is spinning constantly as soon as you add particles in a scene, be it 2D or 3D), and when adding big particles emitter the rest of my windows are slow to move around (GPU is busy).
I know it's a dirty hack but my GPU being a low-end one (NVidia Quadro K1100M), adding 2 particles3D with 10000 particles each makes my laptop feeling like a 486, so I added
if (particles->inactive) break;
at line 1647 of drivers/gles3/rasterizer_scene_gles3.cpp and my GPU is happy again :)

Note that the particles are still computed by the CPU (dot is still spinning) but not sent to the GPU, and on my i5 4200M Godot uses less than 3% CPU with the 2 particles3D not emitting and less than 1% when emitting, so there still is something "not wrong but not good" somewhere...

[EDIT]
I'm using the Mono version of Godot compiled with VS2017 from master branch download as ZIP on 8th of june
[/EDIT]

@akien-mga
Copy link
Member

akien-mga commented Jun 14, 2018

Asked @reduz about this on IRC, some comments:

<reduz> Akien: actually, Godot already stops processing particles when none of them is any longer active, so this may be a bug in that code
<Akien> reduz: If you can point me where I can try to debug and train my OpenGL skills :D
<reduz> rasterizer_storage_gles3.cpp:5829
<reduz> if (particles->inactive && !particles->emitting) {
<reduz> its probably not very opengl related, also only checking if emitting is false is not enough, you have to wait until all emitted particles completed their cycle to turn them off
<reduz> the code waits a full lifetime cycle *1.2 just to make sure
<reduz> where particles where inactive, then turns them off

@malbach
Copy link
Contributor

malbach commented Jun 14, 2018

@akien-mga : Tried that at first, in fact I completely cut the update_particles call (line 7403) but no result...
It's not OpenGL related, and I can't figure from where it comes (I'm missing knowledge for that :)

undo EDIT

@KeyboardDanni
Copy link
Contributor

KeyboardDanni commented Jun 23, 2018

+1. I noticed this issue as well recently. I had added an explosion particle effect (with delayed activation) to an object with a couple dozen instances in the scene and was wondering why the FPS had dropped a bit and stayed that way even after rebooting my system.

In this case it's less about the total number of particles, as simply having about a hundred Particles nodes with only, say, 20 particles each, can potentially halve the FPS.

dormant_particle_lag.zip

Workaround is to make the particle nodes invisible inside the editor, and then come time to emit, run code similar to the following:

particles.show()
particles.emitting = true

@mhilbrunner
Copy link
Member

#19682 should have fixed this for Particles2D, if somebody wants to confirm; something similar likely needs to be done for 3D?

@malbach
Copy link
Contributor

malbach commented Jul 4, 2018

Hi,

Unfortunately yes, something else has to be done for 3D.
Just tested and compiled master 0b7df80 and still slowing down when adding Particles3D with a lot of particles, even when not emitting.

It's like @kubecz3k wrote :

  • create a project
  • add a Particles3D
  • set Process Material to New Particles Material
  • set Draw Passes to Cylinder Mesh (to have a lot of computation, Cube Mesh is too easy)
  • set Amount to a big number (for me it's 10000, but my GPU is low end, try more or add another Particles3D)
  • move your 3D scene around while keeping the Particles3D on screen, it should be a bit laggy
  • untick Emitting and wait for the last particle to disappear
  • move your 3D scene around while keeping the Particles3D on screen, it's still a bit laggy

So yes 10000 or 100000 particles in 3D is not a common thing, but just imagine a final scene in a 3D game with 10 Particles3D emitting 500 particles each, and you have lag even before starting to emit...

mhilbrunner added a commit that referenced this issue Jul 17, 2018
Fix #19507 Not emitted particles affects performance
mhilbrunner added a commit that referenced this issue Jul 17, 2018
Revert "Fix #19507 Not emitted particles affects performance"
@akien-mga
Copy link
Member

Reopening as #19764 was reverted.

malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
malbach added a commit to malbach/godot that referenced this issue Aug 24, 2018
@reduz reduz self-assigned this Sep 7, 2018
@reduz reduz closed this as completed in d304228 Nov 19, 2018
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.

6 participants