Search Unity

Question feeding GPU Events into subgraph issue (w/ workflow explanation)

Discussion in 'Visual Effect Graph' started by XRA, Jun 26, 2021.

  1. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I sent this as a bug report last year I think, still occurring though so I'm asking about it again. It's an annoying limitation/bug.
    Also asking to see if there are any ideas people may have, maybe I'm overlooking something in VFX Graph.


    When dragging and dropping a VisualEffectAsset into another, it creates a SubGraph block with the Start Stop ports.

    That is great, as in theory it allows larger VisualEffectAssets to work as "systems" that control the activation of separate assets. The separate assets can be authored and tested independently by FX Artists.

    But when attempting to use a GPU Event to trigger the Start or Stop port (of the subgraph), it allows the connection, but once the graph recompiles you will get a null reference exception:


    GlobalImpactEffectSystem : Exception while compiling expression graph: System.InvalidCastException: Specified cast is not valid.
    at UnityEditor.VFX.VFXBasicUpdate+<>c.<get_attributes>b__20_0 (UnityEditor.VFX.VFXData d) [0x00000] in com.unity.visualeffectgraph@10.2.2\Editor\Models\Contexts\Implementations\VFXBasicUpdate.cs:163


    If instead, the GPU Event is wired directly into an Initialize Particle block then it compiles (But the initialize block is not available when using a subgraph...)


    The reason for wanting to use a GPUEvent is so that in the Update block of the main "system", it can use the various Trigger Event GPUEvents to spawn other effects at the particle's position.

    An example would be bullet impacts.

    One global VisualEffectAsset reads a Texture2DArray of impact positions and triggers GPU events for each system particle. (One particle = one pixel)

    The alpha channel acts as a lifetime flag, if zero it immediately sets the particle lifetime to zero.
    Another slice of the texture array holds the Effect ID and hit surface normal.

    The effect ID is used to determine which GPU event fires off. A Switch is used to map the effect ID to each Trigger Event block.



    With this null reference error still around, it means we have to copy/paste and maintain each impact effect within the main VisualEffectAsset used for the whole system when making updates.

    It works when doing that, but complicates workflow a bit, as only one person can be editing the graph at one time.

    Any ideas? Any technical reason why there is the null reference?
     
    rezuma and Ervo like this.
  2. Ervo

    Ervo

    Joined:
    May 26, 2016
    Posts:
    8
    Same problem here, did you find any solution?
     
  3. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    I had the same issue by now (for bullet's impact, impact is one separated VFX Graph) Have you got the solution yet?
     
    Ervo likes this.