Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What's the best way to conditionally enable / disable subgraphs (most performance)

Discussion in 'Visual Effect Graph' started by sergiusz308, Mar 26, 2020.

  1. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    234
    Hi, so I created generic muzzle flash effect, which has three subgraphs: flash, sparks, smoke. All subgraphs are initialized by a single spawn event.

    What would be the most performant way to conditionally (via exposed parameter) enable / disable execution of the particular subgraphs? For example I want to have a weapon where only sparks and smoke will be executed, no flash. On another I’d like execute flash and smoke only, no sparks.

    I know that there are branching operators and I also know that branching in shaders can be expensive - so what would be the best way to do it in VFX graph?

    Thanks,

    S.
     
  2. hertz-rat

    hertz-rat

    Joined:
    Nov 3, 2019
    Posts:
    71
    If we are talking a muzzle flash, unless you have 2 dozen of them happening simultaneously, I would be surprised if you have to worry about performance. If performance is a concern, I wonder if just object pooling the effects might make a bigger difference than optimizing the vfxgs themselves?