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

Particle shaders are 10x as slow as they could be #2176

Closed
tavurth opened this issue Jan 24, 2021 · 7 comments
Closed

Particle shaders are 10x as slow as they could be #2176

tavurth opened this issue Jan 24, 2021 · 7 comments

Comments

@tavurth
Copy link

tavurth commented Jan 24, 2021

Describe the project you are working on

A water depth & velocity simulation shader in 2D (from above).

Describe the problem or limitation you are having in your project

I've run into many issues while dealing with Godot's shader language, and I wanted to start this post as part of my documentation of such. When dealing with the current shader implementation I feel like my hands are tied many times, which leads me to believe that the current shader implementation keeps Godot far behind other engines.

Particle shaders are slow

When trying to create my water simulation in a particle shader (seems like a good idea), the simulation uses 10x more CPU time than a simple Canvas shader. Therefore I must work more strictly within the bounds of the Godot canvas shader.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

See above

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

See above

If this enhancement will not be used often, can it be worked around with a few lines of script?

This enhancement will affect anyone who has more than a passing interest in shaders.

Is there a reason why this should be core and not an add-on in the asset library?

Shader language improvements must be core.

@Calinou
Copy link
Member

Calinou commented Jan 24, 2021

Could you upload a minimal reproduction project, please?

Ideally, this should be compared with another engine that uses only OpenGL ES so we can understand whether the thing you're trying to achieve is actually feasible.

@tavurth tavurth changed the title Particle shaders are 10x as slow as they could be [Shaders] Particle shaders are 10x as slow as they could be Jan 24, 2021
@clayjohn
Copy link
Member

In 4.0 you already have access to computer shaders. So you won't have to rely on hacking your way through the particle shader, or a canvas item shader.

Keep in mind, the particle shader is not a flexible GPU shader and is deeply embedded into the particle API. So it's really not designed to do general purpose calculations.

@tavurth
Copy link
Author

tavurth commented Jan 24, 2021

An example project based on a canvas only shader can be found here

This project uses around 1/2 million particles and uses around 7% of my GPU. As soon as I add even the most basic ParticleShader instance with 500,000 particles my GPU use jumps to around 60-70%!

@tavurth
Copy link
Author

tavurth commented Jan 24, 2021

Keep in mind, the particle shader is not a flexible GPU shader and is deeply embedded into the particle API. So it's really not designed to do general purpose calculations.

Thanks for the feedback! Yes I'm aware of the particle shaders problems, I'm using a simple canvas shader to perform complex multi-stage algos :)

@Calinou Calinou changed the title [Shaders] Particle shaders are 10x as slow as they could be Particle shaders are 10x as slow as they could be Jan 24, 2021
@akien-mga
Copy link
Member

As I understand it this use case is fulfilled in the upcoming Godot 4.0 by Compute shaders, which are designed specifically for this.

The Godot 3.x renderers and shading language won't receive major changes, so unless we see low hanging fruits to improve the performance of particle shaders specifically, I suggest that this proposal could be closed as solved by Godot 4.0?
Or if not, what is the actual proposal for change in Godot 3.x?

@tavurth
Copy link
Author

tavurth commented Mar 31, 2021

@akien-mga I see, the particle shaders will use the new compute pipeline?

In that case I would like to test 500,000 particles in the new 4.x version and check the cpu/gpu usage.

Unfortunately I'm as of yet unable to do so as the 4.x nightly builds crash on my machine (MacBook pro 2019)

If it's significantly lower than currently that would be a huge win, and we can certainly close this.

@Calinou
Copy link
Member

Calinou commented Sep 26, 2021

Closing, as there is nothing actionable we can do from this proposal. In general, performance issues should be reported on the main Godot repository with reproducible benchmarks included. We have a performance label on the main Godot repository for this effect now.

"Make X run faster" is rarely a good proposal subject, as it's not actionable for contributors – especially when the proposal doesn't describe how to make X run faster.

You could test the master branch's GPUParticles3D implementation, but note that it has many bugs currently.

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

4 participants