Search Unity

Swapping or sequencing particle behavior/shader.

Discussion in 'Visual Effect Graph' started by koirat, Apr 14, 2021.

  1. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    I need my particles to behave differently depending on some external variable.
    But I need it to be continuous, my particles must be in place where last behavior left them, and not initialized from the beginning.

    Now as I understand it when I create all this behaviors in one graph and will use branching condition to select one of them it will be very performance inefficient since shader branching is not very good.

    Is there a better way like disabling enabling the whole systems or swapping shader graphs ?
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    What exactly do you need? You want to swap shaders to get completely different looks?
    From what I know there is no way to change shader, so I would add two outputs to single system and change particle size to 0 in one of them. This will not affect other output size, because output attributes are temporary, but the best solution would be to disable whole output, but its not possible yet. Still, I don't know if this will give you better performence than single master shader with parameters, maybe it depends how complex it is.

    // EDIT: I am dumb, forget about setting size, you can do SetAlive = fasle. See this post.
     
    Last edited: Apr 15, 2021
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    I want to swap behavior so my particle will circle around or float to particular position depending on condition.
    But my particles are indefinitely alive I don't want to destroy them.
    So I cannot just have two particle systems, well I could have it if It was possible to inherit positions/rotations from other system back and forth.

    Thanks for SetAlive I will take a look at it. But it will probably not solve my problem.
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    Why would you need two particle systems? You can have two or more outputs in single system and just swap the way the particles are rendered. Also setting alive to false in output does not kill them.

    If you need different behaviour, then it should be possible by using Update block, not sure how hard it is to get effect you want, but definitely it should be possible.
     
  5. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    I don't need to change how my particles look but how they behave.

    If I got two separate system when I swap one with other there will be blinking of one of my particles disappear and the second appearing because particles are in different positions.

    Now problem with Update System is that you cannot have multiple Update Systems and just switch one to another you cannot disable blocks and there are no nodes alternatives for blocks.

    For example I have got turbulence on my update, my second behavior will not use it, now I'm forced to do some hacks like storing position before turbulence and restoring it after.

    Now when I have got few different behaviors for the same particles the special cases will explode.
     
  6. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    Eh, I agree - disabling blocks is very missing feature.
    I guess you want your particles to continue previous movement and then change behaviour, so isn't enough to just disable e.g. drag param in turbulence? For sure this is not convenient solution, but it should be possible to fake disabled state in most of these nodes, unless your case requires something more complicated.