0
\$\begingroup\$

I am making an app to visualize data, I am new to Unity but have an extensive background with Blender.

I have written my script to read in data and plot those points. In this example its ~528k points. However, the performance is very bad, If I used distance based rendering I get an FPS of ~16 on a very beefy computer

enter image description here

I can get ~35FPS if I remove the distance rendering but then I get bleed through from particles behind those in front.

enter image description here

I've read about VFX Graph but my understanding is that this is not very C# based? But I'm not certain.

How can I increase the performance? Considering how well Blenders viewport handles 10 million particles I feel like there must be a trick I'm missing here to handle all of the particles. Is it related to materials? Is there a way to make the materials "dumber"?

\$\endgroup\$
7
  • \$\begingroup\$ what technique are you using now to render those points? \$\endgroup\$ Mar 22, 2023 at 13:00
  • \$\begingroup\$ It is just a particle system using the default particle as a material and billboard method. \$\endgroup\$
    – TheJeran
    Mar 22, 2023 at 13:02
  • \$\begingroup\$ If the columns of particles lie on a grid, you may be able to use the sorting technique Inigo Quilez describes here (2D version) to get correct ordering at high speed. Switching to an opaque, alpha tested rather than blended material for the particles or even drawing each as a full opaque quad rather than a circle could save you a lot too (and let you draw unsorted or even sorted front to back, so the depth buffer minimizes overdraw). \$\endgroup\$
    – DMGregory
    Mar 22, 2023 at 13:13
  • \$\begingroup\$ I know very little at the moment of Unity API and especially shaders. Where would I apply this code? Would this be a compute shader? \$\endgroup\$
    – TheJeran
    Mar 22, 2023 at 13:18
  • \$\begingroup\$ Does the data move or is it just a static point cloud? \$\endgroup\$
    – Philipp
    Mar 22, 2023 at 13:35

1 Answer 1

2
\$\begingroup\$

The classic Unity particle engine (aka "Shuriken") doesn't make a lot of use of GPU acceleration. The visual effect graph (VFX graph) is far better in that regard resulting in superior performance in many use-cases. There are some demos that demonstrate how it's able to handle millions of particles in real-time. And not just as a static point cloud, but with the particles actually doing stuff. So it might be suitable for your use-case.

If you want to create a VFX graph particle system based on a set of pre-computed particle positions and properties, then you might want to use a point cache. A point cache requires that you convert your data into a pCache file. I unfortunately can not help you with that because I have no idea about the format your data is currently in or what tools you have available to convert it. But the format is pretty straight-forward, so it shouldn't be too difficult to build an own conversion program.

You can then import that .pCache file into your Unity project as an asset. You can then integrate that point cache into a VFX graph by:

  1. Creating a Point Cache node
  2. Assigning your pCache asset to it
  3. Creating a "Single Burst" block to the "Spawn" node.
  4. Wiring up the "Point Count" property of your point cache to the "Count" property of the Single Burst block
  5. Creating a "Set Position from Map" block in the "Initialize Particles" node.
  6. Wiring the "position" property of the point cache node to the "Attribute Map" property of the "Set Position from Map" block.
  7. (optional) If you want to transform the data in your point cache based on some runtime property, then you can do that by putting a couple arithmetic operator nodes between the point cache node and the set position node (Operator>Math>Arithmetic).
  8. Repeating steps 5 to 7 for any other properties you have in your pCache file which you want to be represented in your visualization

For more information, please refer to the documentation about point caches in the VFX graph.

\$\endgroup\$
3
  • \$\begingroup\$ Would the positions after plotting via pcache be capable of changing via an slider? Or is it like the "initial state" of the VFX graph? \$\endgroup\$
    – TheJeran
    Mar 22, 2023 at 15:53
  • \$\begingroup\$ @TheJeran In this example it's the initial state. But the point cache is just a set of data. What you do with that data is up to the graph. I am not sure what exactly you mean by "changing positions via a slider". Depending on how that is to be interpreted, there are different solutions. If you want to move, rotate or scale the whole particle system, then you would do that via its transform component. Or you could pass the value of the slider to the particle system and then use that value somewhere in the VFX graph to do something. \$\endgroup\$
    – Philipp
    Mar 22, 2023 at 16:13
  • \$\begingroup\$ Alrighty, Ill look into this tomorrow \$\endgroup\$
    – TheJeran
    Mar 22, 2023 at 18:44

You must log in to answer this question.

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