Search Unity

One System instance for all particles

Discussion in 'Visual Effect Graph' started by JmprDev, Jan 24, 2021.

  1. JmprDev

    JmprDev

    Joined:
    Apr 26, 2018
    Posts:
    16
  2. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    It is possible but requires a bit of planning and code depending on intended use. With some VFX Graph bugs fixed it could be better.

    Technically you could have multiple Initialize / Update / Output bocks, driven by GPU Events from a master spawning system. The multiple other blocks would act as types of effects, in my case I was using it to drive impact/surface effects from a bunch of objects based on the type of material applied.

    It needs a way to drive what to spawn, I feed the spawn system a texture2d array that contains spawn positions, active state, surface type, etc... ParticleID is used to lookup the pixel to read in the master spawn system (the tex2d array allows indexing the slices consistently if more data storage is needed).

    The spawn texture is written in a compute shader and pulls in other game-data (positions of objects, impact/contacts, surface types etc)
    So it ends up that 1 particle spawned in the master system has the potential for sending a GPU Event to create a bunch of some other types of particles (or simply being immediately killed if the ParticleID reads an pixel marked inactive)

    One issue that is reported is creating a sub-graph would be ideal for this workflow (a sub-graph for each type of effect, self-contained) But initializing the sub graph via GPU Event doesn't work & was throwing errors when the graph compiles.

    So the downside is the graph gets very huge and without GPU Events being able to be fed into a sub-graph's Initialize block, it's hard to scale for a large project.
    If that was fixed it would be really good, as individual FX artists could work on specific effects in isolation, and still have the sub-graphs referenced in the main VFX system.

    Another issue is sometimes it seems like GPU Events don't fire consistently if there is poor framerate, but it might also be dependent on how the vfx graph is setup.

    There is also the other types of events in VFX Graph but I didn't experiment with it much as that comes from the C# side and I was skeptical if it scales well.
    I like the simplicity of just updating a GraphicsBuffer with the range of values that need updating from the CPU side then dispatching a compute shader which outputs it to the tex2D array.
     
  3. JmprDev

    JmprDev

    Joined:
    Apr 26, 2018
    Posts:
    16
    Thank you for your detailed explanation. I hope those issues can be addressed soon.