Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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:
    185
    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?