Search Unity

Resolved How can I connect a Texture2D to a Branch operator?

Discussion in 'Visual Effect Graph' started by ZeHgS, Jun 1, 2022.

  1. ZeHgS

    ZeHgS

    Joined:
    Jun 20, 2015
    Posts:
    117
    Hello!

    I am making a tornado effect. I am splitting a particle pool using branch conditions as described here so that I can fix this problem that I had where the tornado dust always rendered on top of the tornado itself. I have managed to do so for all parameters except the base color map (texture).

    I would like each effect to use a different texture but, since the dust effect already uses a flipbook while the tornado itself uses a regular texture, the solution given in the first link doesn't work, I believe, or I am too much of a newb to know how to do it.

    The "Texture2D" node won't connect to the Branch node, for some frustrating reason. The "Load Texture2D" and "Sample Texture2D" nodes won't connect to the "Base color map" slot.

    How can I change the texture based on a branch condition?

    Thanks a lot!
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    VFX graph is just shader, so you can't casually branch things like texture or mesh. All data is based on attributes of particles and graph properties. This is why there are attributes like meshIndex or texIndex. I recommend you to read docs, so you understand a bit better how vfx graph works.
     
  3. ZeHgS

    ZeHgS

    Joined:
    Jun 20, 2015
    Posts:
    117
    Thank you very much for replying!

    I did and it all means nothing to me, unfortunately. However, I have been able to make several beautiful-looking effects with what I do understand, thankfully. My tornado effect looks exactly the way I want it to look at this stage and all I need is a way to overcome this particular hurdle.

    Do you have any solutions to recommend?
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    If you want to use flipbook for every second particle and other texture for the rest of them, the only way would be to use single flipbook with all textures included, then you would need to animate flipbook for first type of particles, but only in some range (for example 1-8) and then other type of particles would have constant index in flipbook (9). In short you would kind of branch textureIndex.

    Or you can try to do some stuff with depth write and zTest, so particles are rendered based on that, but I had no chance to test it yet and it depends on shape and opacity of your particles.
     
    ZeHgS likes this.
  5. ZeHgS

    ZeHgS

    Joined:
    Jun 20, 2015
    Posts:
    117
    Ok, thank you so much for your help!!