Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

VFX Logic operators with more than 2 inputs?

Discussion in 'Visual Effect Graph' started by eranhaas, May 29, 2020.

  1. eranhaas

    eranhaas

    Joined:
    May 30, 2013
    Posts:
    5
    I was wondering if there is an easy way to compare more than 2 bools using something like the "and" or operators. I ended up making myself a messy subgraph to deal with it, but I was wondering if I was missing a simpler way.

    Thanks.
     
  2. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    There is an And logic block that may do what you want.

    I think I have a related question which is how do I replicate if (blah) else if (blah) else() in vfxgraph?

    I want to link some compare blocks together, but seems awkward

    For example:
    • if X < 5, do a small effect
    • else if 5 < X < 10, do a medium effect
    • else X > 10, do a big effect
     
  3. pjbaron

    pjbaron

    Joined:
    Jan 12, 2017
    Posts:
    51
    eranhaas: the sub-graph shouldn't be too messy, just (N - 1) 'AND' operators per N inputs. Unless you're doing lots of them I'd happily go with sub-graphs for AND3, AND4, etc. Although some operators allow additional inputs, they're the ones with an unlabelled input at the bottom left of the node - the logic ones do not support this.

    AND3 subgraph operator
    upload_2020-7-1_21-34-56.png

    livealot: I came across a 'switch' block recently - depending on your logic that might work quite well (for your example do an integer divide by 5 then switch on the result for 0, 1, 2)

    In this example the switch controls the velocity of particles involved in the effect.
    upload_2020-7-1_21-40-52.png
     
    Last edited: Jul 1, 2020
    Livealot and florianhanke like this.
  4. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Thanks @pjbaron for the switch idea. That would be useful if the switch block could use expressions rather than static values.

    Here's what I meant by an awkward approach to if/else/then using a classic test of where an input is relative to two thresholds (lower, between, above)

    ifelsethen.JPG

    I'm hoping there is a much simpler way to do this