Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What exactly is the particle ID operator and what can you do with it?

Discussion in 'Graphics Experimental Previews' started by JackDDeane, Jun 10, 2019.

  1. JackDDeane

    JackDDeane

    Joined:
    Aug 6, 2018
    Posts:
    26
    Looking on the Unity manual for the VFX graph there isn't any mention of the particle ID operator. I've seen it used in a lot of publicly available projects but I'm trying to figure out how to use it properly. From what I can guess it outputs the individual ID of every spawned particle, but in what form? A vector 3, float value or something else?

    Take for example one of Keijiro's projects demonstrating how to input animated skinned meshes in VFX graph:



    Here he plugs the particle ID into a modulo int and gets the remainder of 300 (which through other node calculations eventually end up setting the position, target position and colour). What is the use of such a calculation, it is obviously an important part of the graph setup, but changing the values in the modulo operator or the multiply operator don't make any visual difference so it is hard to tell exactly what is going on.
     
    sivrikaya likes this.
  2. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    It's an int used to tag each particle.

    When used in conjunction with modulo you're basically sequentially assigning each particle to a bucket that you want to handle in a particular way.

    For example. Particle ID modulo 10 will create 10 buckets with the first particle in bucket 0, the second in bucket 1 and so on until you get to the 10th particle which goes in bucket 0 again.

    If you take this value and use it for the x position you've got the particles appearing in regular points along a line. If you feed the result of this into sine you've got them appearing in a circle.

    Use id+mod for input into other blocks or nodes such as a position map you generate from an external data source and you can start drawing patterns and shapes. Use line particles (or quads with the "connect target" which are like lines with thickness) and you can start passing in pairs of start/end coordinates and you've got yourself a vector renderer.
     
    Last edited: Jun 11, 2019
  3. JackDDeane

    JackDDeane

    Joined:
    Aug 6, 2018
    Posts:
    26
    Thanks for taking the time to explain @andybak !
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,223
    And how do you control the particle ID so that it matches an index position from map like in this case?
    upload_2020-12-13_18-6-11.png
     
  5. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Not sure I understand your question?

    You don't control the particle ID - it's an immutable index assigned to each particle.

    What effect are you trying to achieve?
     
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,223
    I'm trying to set the position of particles off a position texture that's laid on top of xz world and with another texture that's also laid in the same manner control whether the texture shows up or not
     
  7. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I might be thick but I don't entirely follow.

    Can you explain a bit more fully? I was mostly with you until that "and" in the middle. It feels like there are several sentences there smushed into one!
     
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,223
    yeah not the best use of boolean mid-sentence.
    think of two control maps: one called position which is RGBA and one called gameplay with only R. Particles should only appear at position where position.a=1 and gameplay.r=0
     
  9. Potakowski

    Potakowski

    Joined:
    Dec 2, 2017
    Posts:
    2
    For that you need to create Point Cache. Worth reading about it as it's pretty cool :)