Search Unity

Question Is it possible to branch the computation of a group of operators

Discussion in 'Visual Effect Graph' started by YuriyPopov, Jun 9, 2022.

  1. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    I have a what I would describe as a rather complex sequence of operators. However their computation is not needed for the entire duration of the effect. Can I somehow branch them with a if so that the actual computation does not happen unless a bool is true? Here are the operator blocks in question. vfx_graph_example1.png
     
  2. Peplm

    Peplm

    Joined:
    Aug 2, 2019
    Posts:
    19
    Hello ! I don't know exactly what your sequence is doing but maybe something like this should work :
    In true you put your computation, and in false your default value. You can have more complex condition with the logic operators.
    upload_2022-6-9_14-39-26.png
     
  3. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    Hey thanks for replying. I'm aware of the branch operator, but as far as I know this wont stop the computation from happening. It will still compute both values for true and false and just pass one down the line depending on the bool. What I want is more like what we would do in code like :

    Code (CSharp):
    1. if(condition)
    2. {
    3.   //Do computation
    4. }
    5. else
    6. {
    7. //Do something else
    8. }
     
  4. Peplm

    Peplm

    Joined:
    Aug 2, 2019
    Posts:
    19
    Oh so it's only for optimisation purpose ? in this case i don't know. The only thing that come to my mind is doing all your computation via script and returning the value you need through an exposed property.
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Unless there is anything special I have no clue about, as all of these are shaders it's up to compiler if it's branch or not. If there is huge block of computations it might end up as branch.