Utilizing VFX Graph 12.1 for Projectiles

Hello,

I could please use a sanity check on how to best approach utilizing VFX Graph in a performant way for projectiles and hopefully without compromising authoring workflow. I’m still learning the ropes on VFX Graph and understanding GPU performance.

My game is a tower defense with a worst case scenario of ~400 active projectiles at any given moment. They are currently setup as pooled game objects with homing behavior which is processed and applied by an IJobParallelForTransform. Each has some combination of Shuriken particle systems attached for their visuals, and there are different types (visuals) of projectiles.

I’d like to transition over to VFX Graph since I find the workflow more expressive and powerful, and hopefully get some performance gains along the way since Shuriken particle system processing currently eats a decent amount of CPU frame time on low spec machines.

It is worth noting that I am currently stuck on 2021.3 LTS (VFX Graph 12.1) and upgrading is not an option. If I understand correctly, batching via instancing is only available in 2022+ and I need to try to get all VFX of the same type running through a single system (VisualEffect component) since multiple VisualEffects sharing the same asset won’t be batched.

Given the above, my plan is to have one Visual Effect Asset and Visual Effect component per projectile type and feed projectile position data to the particle system via a graphics buffer. From there I should be able to side-chain multiple outputs in the graph (projectile body, trail, etc) to compose the visuals of each projectile. With this I may also be able to further optimize by replacing projectile game objects with plain data sent through the job system.

So my questions are:

  1. Will this approach even work as expected/is my understanding accurate?
  2. Is this a performant approach given the version of tech available to me?
  3. Any other gotchas I should be aware of?

Thank you

No, VFX instancing combines updates of instances with the same asset (if possible). You could run everything inside one system obviously, but then if there are transparent elements there might be problem with transparency. If you meant projectiles with different effects, then yes it can’t be batched (or you can make everything inside one asset xD), but I would not worry so much unless every single tower has different VFX.

What is your target PC only? Potato laptops?
You need to test things, but speaking for myself I made projectile system for my game - it has pooling system and it uses standard gameobjects with components and I can use both shuriken or VFX graph, or none. So far the simulation part worked very fast with jobs, rendering could be more heavy with a lot of effects, but I don’t have 100 different types of projectile on screen, but like 2-10, so as far as I remember, with vfx batching I had no big performence problems.

BTW - to update projectile game object I used transform job.

For reference some quick performance tests. Sadly from editor, but I hope it gives a bit of insight.
My PC has Intel i7 + GTX970.

This is idle state (or almost, not 100% sure if all projectiles died off screen)

So the first test - I think there are ~368 projectiles.
Each with mesh renderer and one VFX instance of trail.


As expected most of CPU is spent on rendering VFX, mesh renderer is very fast.

Another test, this one with around ~1000 projectiles:

1 Like