Search Unity

VFX Performance tanks when camera is within the particles

Discussion in 'Visual Effect Graph' started by Donion, Nov 10, 2021.

  1. Donion

    Donion

    Joined:
    Jun 7, 2017
    Posts:
    35
    Hi Im working on a vr game and wanted to add some bullet impact. Performance is great when the bullets collide far away from the player but when VFX is close to the player performance tanks hard. I tried using additive particles but nothing helps wondering if I'm missing something.

    Here is what it looks like when performance is great
    Screenshot 2021-11-10 120259.png

    When it tanks
    Screenshot 2021-11-10 120517.png

    Here is my shader
    Screenshot 2021-11-10 120719.png

    And the particle system
    Screenshot 2021-11-10 120640.png

    Thanks for the help!
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hey @Donion,

    I believe this is expected and not necessarily VFX Graph specific, but a general rendering consideration. Even if you were to add a few transparent quads and zoom in on them, you will probably get a similar performance drop.

    When you zoom in, you are rendering a big portfolio/all of your screen multiple times; once for the opaque level itself, and once for each transparent particle. If your shader is more complex, that will add further strain to your rendering.

    To make sure effects like this don't tank your performance, you should control the particle size so they become smaller when you get closer to them. This forum post has a few examples of how you can control your VFX particle sizes relative to the camera.

    Hope this helps!

    p.s. another note, unless you need the smoke to dynamically animate, it would probably be faster to just bake the noise into a texture rather than using the noise functions. If you want some animation, take a look at using flipbooks, it will also save you some performance :)
     
  3. Donion

    Donion

    Joined:
    Jun 7, 2017
    Posts:
    35
    Thanks for the help! But I cant manage to get the implementation working the distance seems to be off.

    Screenshot 2021-11-10 215558.png

    I added the main camera position and took the distance from the particles. Then clamped it between 0 and 1 and multiplied it to my size over lifetime curve. I figured if the players is 1 meter from the particle it would have a size of 0 but it doesnt seem to do that.
     
  4. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Check to see that your main camera in the Scene is tagged 'MainCamera':


    Alternatively, you can also expose a Vector3 in Blackboard (PlayerPos in this example), add a Position Property Binder script to your VFX object, and link it to the exposed Vector3 and your player Transform and then use that PlayerPos instead of your Main Camera position in the graph to check the distance:
     

    Attached Files:

  5. Donion

    Donion

    Joined:
    Jun 7, 2017
    Posts:
    35
    Thanks @VladVNeykov I got it to work. When I was trying out the bindings I found that it worked if I set a origin position for the particles. So the particles positions where in local space not in world space. Thanks for the help! For anyone else here is my graph for sizing.

    Screenshot 2021-11-11 112108.png
     
    PutridEx, VladVNeykov and Qriva like this.