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

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.

1 Like

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.

5 Likes

Thanks for taking the time to explain @andybak !

And how do you control the particle ID so that it matches an index position from map like in this case?

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?

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

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!

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

For that you need to create Point Cache. Worth reading about it as it’s pretty cool