Search Unity

Question Particles only initialize when camera looks

Discussion in 'Visual Effect Graph' started by Kimproductions, May 17, 2022.

  1. Kimproductions

    Kimproductions

    Joined:
    Feb 28, 2018
    Posts:
    6
    Hello, my current issue is that my VFX graph particles only intialize once I look at them. I understand that this is a performance optimization.
    But since I am using skinned mesh sampling and also instantiating my enemy prefabs during runtime, whenever the player first sees the enemy, you can catch some particles being spawned in a T-pose, which looks hilarious as you can see here:
    particlebug.gif

    I have tried increasing the bounds very high in initialize particle but to no avail.

    I've also tried adding a delay in the object's Start() method and then running visualEffect.play; but it has no effect. The t-pose particles can be seen any time the player first LOOKS at the particles, not when the prefab is first spawned.

    How do I have it so that the particles are not seen in the T-pose?

    Best,

    Isaac
     
  2. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    154
    Hello!

    When the Skinned Mesh Renderer become visible, the skinning is invoked just before the rendering but it's too late for the VisualEffect update which is fallbacking to the source mesh. That is why you can notice a T-Pose if the Skinned Mesh Renderer and VisualEffect are first displayed within the same frame. We registered an issue (link is not available yet) for this specific case.

    You have to be aware there is another issue, any sampling of skinned mesh renderer in Initialize and Update context will have a frame delay. The reason is the order of update between VFX and Skinned Mesh Renderer, you can follow this other issue.

    Back on your initial use case:
    Did you also try to increase the Bounds on the Skinned Mesh Renderer ? You should actually prevent the VisualEffect to be simulated before the Skinned Mesh Renderer visibility. If you have only increased the bounds of the VisualEffect, then, the simulation will sample incorrect data. Alternatively, you can enable Update When Offscreen to force the update of the Skinned Mesh Renderer whatever the culling state.

    Another workaround would be to add a delay inside the VisualEffect Spawn Context, it will skip the first frames (in inspector, switch the "Delay Mode" to "Before Loop").

    I hope that I was able to help.
     
    Last edited: May 17, 2022
    Qriva and Vita- like this.
  3. Kimproductions

    Kimproductions

    Joined:
    Feb 28, 2018
    Posts:
    6
    Switching the delay mode to before loop didn't work, but increasing the bounds on the skinned mesh renderer worked for me! I didn't realize that I had to keep track of the skinned mesh bounds. Good to know.

    Thank you again, Paul!