Search Unity

About Swtich operator

Discussion in 'Visual Effect Graph' started by tomBuzz, Feb 19, 2020.

  1. tomBuzz

    tomBuzz

    Joined:
    Feb 4, 2020
    Posts:
    1
    I want to change textures of the atlas map assigned from the particle ID.
    Although there is a "Switch" node in VFX graph, I think that it returns only RGBA value.
    Is there a good node to output textures for each input value?

    How do I create custom nodes in VFX graph?
    -----------------------
    Unity: 2019.3.0f6
    Visual Effect Graph: 7.1.9
     

    Attached Files:

  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @tomBuzz ,
    I'm afraid using different textures per particle is currently not supported.

    You could try creating a VFX shader graph shader and expose multiple textures and switch between them within the shader itself. The VFX Shader Graph integration is still experimental, but you can enable it in Preferences / Visual Effects / Experimental Operators/Blocks.

    As another workaround, you can also have multiple outputs from the same effect. In your example you can duplicate the quad output a couple of times, connect all instances to Update, and have each quad output render with a different texture. Then you can add a Set Alive block in each output and control the True/False value via your switch. (This is not the most optimized workaround as you'll still be paying the cost for the culled particles.)
     
  3. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    Another way to do it would be to pack all your textures in a single flipbook texture and then use the texIndex attribute to choose which texture to use per particle