Search Unity

Synchronize VFX Graph over network

Discussion in 'Visual Effect Graph' started by jeroenvdv, Sep 8, 2020.

  1. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Posts:
    52
    We've got a Unity setup with multiple computers rendering the same (or different) scenes. We made a solid time sync mechanism for our own animation engine to synchronize animation between computers.

    However, I would also like to synchronize particle (VFX graph) behaviour between systems. Is there any way to let VFX Graph use an external timebase to calculate the effect? Then we can use that and synchronize the VisuaEffect.Seed.
     
  2. DannyWoo

    DannyWoo

    Joined:
    Oct 25, 2012
    Posts:
    24
    I really curious about this subject.

    have you been try this? and did you get any result as your expected?
     
  3. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Posts:
    52
    Couldn't solve this myself yet. Still looking for a way to be able to inject external timebase to an effect instead of DeltaTime/Time/...
     
    Dessix-Machina likes this.
  4. Dessix-Machina

    Dessix-Machina

    Joined:
    Aug 5, 2013
    Posts:
    6
    Total Time is a delta of time at playRate since start, and a near-sum of deltaTime values.
    It may be possible to do this from outside through use of several key APIs on VisualEffect- namely, either modulate VisualEffect.playRate for catch-up / trail-along behavior or set VisualEffect.pause on targets which are ahead and call VisualEffect.Simulate on those which are behind in order to resynchronize.

    It won't cover scenarios where a collider or such disrupted the system, but most particle systems have a short event memory, and you'll maintain overall fire-rate sync via a model of this sort. Think of it like syncing video players, but the videos can have a few keyframes corrupted if they diverge too far; if you reconverge the inputs, the next keyframes (emit events) will behave correctly despite prior divergence.
     
  5. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @jeroenvdv ,

    Would a custom deltaTime work for you? First a bit of context: when you select the Update context, you can see a few checkboxes (on by default) which drive the various time-based simulations:

    • Update position - if you are using any velocity attributes
    • Update Rotation - if you are using any angular velocity attributes
    • Age Particles - if you are using any lifetime attributes
    You can disable any of the ones you'd like to drive by your own custom time:


    Then expose a float value in Blackboard (myCustomTime in this example) and recreate any of the updates you want, like this:


    Basically you are doing the same thing the VFX Graph was doing before under the curtain, but instead of using the deltaTime supplied by the VFX Graph, you are using your own value which is now exposed in the inspector.

    From here you can just set the exposed value in blackboard via script (vfx.SetFloat("myCustomTime", myDeltaTime)) to whatever you need it to be.

    Would this work?
     

    Attached Files:

  6. Dessix-Machina

    Dessix-Machina

    Joined:
    Aug 5, 2013
    Posts:
    6
    If you're going to substitute time calculations through manual invocation, it'd be simpler to `pause` it and call `Simulate(myDeltaTime, 1)` instead of modifying the graph; this also alleviates the need to tailor every VFX graph to the purpose of being networked.


    Seeing as you're at Unity, it would be nice if this API supported something akin to VideoTimeSource or VideoTimeReference; note that the former is unsupported on VideoPlayer but would facilitate much-more-efficient automation of video synchronization- and the same mechanisms could be applied to VFX graphs.
     
    Last edited: Jan 11, 2022
  7. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Posts:
    52
    Thanks for the suggestions - Will have a look at both ideas! Need to get my head around converting our known custom ‘totalTime’ to usable deltaTime for the init. The call to Simulate(myDeltaTime, 1); could work for this initial ‘seeking’ to the correct time as well.