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.
  2. Dismiss Notice

Question how do you turn off a particle's display once it's emitted ? (without killing it)

Discussion in 'Visual Effect Graph' started by laurentlavigne, Dec 10, 2020.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    I'd like to spawn permanent meshes with vfx graph and then, dynamically with a render texture, control their scale and turn off their display when the render texture alpha is below a certain value.
    Scale off the render texture seems ok as long as the particles/meshes are spawned in sequential order matching the render texture and all of them are spawned but I can't find a way to just turn off their render without killing them.
    How do I do that?
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    what I've got so far
    upload_2020-12-10_3-17-28.png
    vfx graph doesn't seem to have conditional nodes to exclude the output
    maybe the culling is done within vfxgraph? any optimization?
     
  3. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    You can use SetAlive in an Output to toggle the rendering of your particles. Doing so in Output does not kill particles, but just disables their rendering. You can also do this on a per-particle basis if you'd like to only turn some of them off.

     

    Attached Files:

    laurentlavigne likes this.
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    genius! thanks @VladVNeykov
    might want to call it "?Set Active" instead as alive is connected with kill which is connected with lifetime
     
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    by the way, I see there is a set alive from map, what's the texture format for that? and can the heuristic be easily changed so for example alpha=0 to 0.5 alive, otherwise dead
    or is this way proper and fast? (use of compare can be slow in shaders under certain conditions... which I never remember)
    upload_2020-12-10_3-45-1.png
     
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    oh and alive is for the entire particle system or can it be done for just specific particleID?
     
  7. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    It's changing the actual Alive per-particle attribute, so naming it Set Something-else can be confusing, but yes, I agree it is not very discoverable.

    Any format really, just check if you are applying any sRGB to the texture import settings which might skew the values. And yes, you can scale and add a bias to control what value will yield true or false.

    Per particle.
     
    laurentlavigne likes this.
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    true is >=1 ?

    Since I got you, how do you do vfx graph have global properties like shaders?
     
  9. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,992
    I tried this and it's not showing up particle where the alpha is = 1
    upload_2020-12-16_13-46-15.png
    upload_2020-12-16_13-46-44.png
    it seem that scaling by 0,0,0,1 would do
     
  10. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    145
    I was a little bit confused as I tried to disable some particles too. But setting "Alive" did not work for me as it could not be reset after setting to false once.
    Turns out renabling it only works if its done in the render context (like in your image).
    In the Update context (which I used first) a dead particle will stay dead forever.

    Is this intended behavior?
     
  11. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    peaj_metric likes this.