1
\$\begingroup\$

I'm using particle systems to create stars in my space sim project. The star is made off 2 particle systems: star surface (max particles: 500) and corona (max particles: 250), both use the Mobile/Particles/Additive shader, and a sphere mesh with Standard material. And it works fine and looks pretty nice:
enter image description here enter image description here But there's one problem: When I get close to the star so it occupies the most part of the screen, fps drops significantly (from 60 to 30-40). This happens in editor and mobile (Samsung A8 2018), didn't test PC standalone build yet but I'm pretty sure the result will be the same. Disabling the sphere mesh doesn't affect the performance. Disabling of one of the particle systems does improve performance. When the camera is relatively far away from the particles, performance is fine. Changing the scale doesn't seem to matter, whether it's a big star with real size radius 10 million units or a small star with radius 1 unit. The problem occurs when the particles occupy the most part of the screen space. Changing the shaders to other available ones does change the result FPS but whatever shader I use the performance drop is still there.

So, the question is: are there some tips, workarounds or something? Or do I have to write a custom shader? Or changing shaders won't help anyway? I'm using built-in render pipeline, by the way. Tried URP and while fps is a bit higher in general, there's still a big drop (to 40-45 fps).

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Sounds like you're fill-rate bound. A GPU has a maximum throughput for how many pixels it can write to in a frame. If you have a lot of particles filling your whole screen, then every pixel in your screen is getting written to many times in the frame, chewing up that fill rate until the GPU can't keep up. Reducing the overdraw by moving some of the effect to a single-pass shader instead of many layered particles can help - if you want to explore this route, you should show us pictures of what your stars look like (or what you want them to look like) so we can help achieve that look cheaper. \$\endgroup\$
    – DMGregory
    Jun 3, 2021 at 12:02
  • \$\begingroup\$ Didn't know about the fill rate limits. Thanks for the explanation. Looks like this is it. I followed this video tutorial: youtu.be/qJEBAPRt8AA and this is how it currently looks like in my project: youtu.be/r49Pz5_R4RE (Sorry for the video framerate and ugly implementation of the effect))). So, I got it that I could make corona effect with less particles, I can do that. But the surface effect that has a bright smoke texture that imitates burning and boiling look, how could this be done with less particles? (And I already have only 500 for the surface effect). \$\endgroup\$
    – Ermiq
    Jun 3, 2021 at 17:48

2 Answers 2

6
\$\begingroup\$

DMGregory already gave some quick guidance in his comment, but to expand on his comment in more detail:

Overdraw refers to situations where the GPU has to draw to the same pixel multiple times in one frame, a problem typically caused overlapping transparent textures (often sprites) on top of each other.

Overdraw can have a major impact if there are many layers of overdraw or they cover a significant portion of the screen. It's very easy to cause overdraw with a particle system that uses large, overlapping particles. This is why many games suffer from framerate issues when the screen is filled with smoke or other complex particle effects.

Unity has a feature to help you spot overdraw issues: In the scene window, there is a render-mode dropdown just below the word "Scene" which has "Shaded" selected by default. If you expand the dropdown, you can select the "Overdraw" mode.

Overdraw mode

In this mode, Unity renders objects using a transparent orange material that turns yellow where objects overlap. The way Unity has implemented this is a little gimmicky and sometimes misleading, but it's still a good tool for getting an idea of places where you have particle systems with too many overlapping sprites.

One trick I sometimes use to create complex-looking effects without a huge number of overdrawn particles is with rotating sprites:

Example sun

In this example, there are just three layers of clouds, one rotating clockwise and two rotating counter-clockwise. Using additive blending, the rotating layers create the illusion of more complex eddies. It tends to look better when the layers rotate at different speeds; e.g. you might have one layer rotating clockwise at 49°/minute and another rotating counter-clockwise at 62°/minute. However, this trick might be difficult to adapt to a 3D star.

\$\endgroup\$
0
\$\begingroup\$

An alternative could be to have multiple transparent spheres on each other and similar to Kevin's answer, each one rotating with different speeds.

and for the atmosphere you can sill use particle systems. but maybe you should try fewer but larger particles.

maybe also activate culling, so that particles from the other side of your planet does not need to be rendered. making sure that culling is activated often can helps against overdraw.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .