Ordered POP Emission

Hello,

So while working on a larger project in Houdini, I ran into a problem where I had a large set of particles representing an event in time, each at a specific location with a specific duration.

I wanted each of those particles to pop into existence, at their location, in the chronological order of the events. I also needed the points to be on screen for as long as their duration.

I decided to work out the problem in a smaller project, as not to get bogged down by the elements and attributes in the original.

There are surely plenty of ways to do this, but the way I framed the problem was that I had a point cloud with an order to each point, and I wanted to cycle through each point in the order and have them be in the scene for the length of their duration and then die.

The duration and death part led me to use a POP Solver. You can pretty easily set the life of a particle before simulating it, by adding a float attribute called life. For my example I used a point wrangle but you can use any attribute creation method.

Just in case you need it, here is how I set the life attribute in a point wrangle.

// This would be if you have a duration attrib you want to use
f@life = f@durationAttribName;

// For this example I just used a constant
f@life = 4;

As a side note, I remember hearing in a tutorial somewhere that the attribute create node is faster than using a wrangle. I did not use one here out of habit, but it could be useful if you are making attributes with constant values or other simple things.

Anyway, now for the main problem. Getting the points to spawn in order.

For my example, I used the point number as the order, but you can use any attribute, as long as it is incremented by values of 1 so that there are no phantom particles the algorithm will wait for (unless that is what you are going for).

What I relied on was the Source Group option in the POP Source. This is used when using the Points Emission Type and limits the points used to emit particles to whichever are in the designated group.

With this, all I needed was a way to have the group cycle through each point in the order I wanted.

To do this I used another point wrangle:

// In my example this channel float is set to 3
float hold = chf("hold_frames")+1;

if (@ptnum == (((@Frame-1)/hold) % @numpt)-1) {
    i@e = 1;
}

The hold variable sets the number of frames between each particle spawn.

The important equation here is the @Frame % @numpt which will cycle through each point repeatedly. The hold variable adds substeps to this cycle, giving frames where the equation will yield a decimal value and will not satisfy the if conditional.

I would recommend using the Enumerate SOP to get an order starting at zero and counting up, this will get it to start at the first point and repeat back to the first point once it counts all the way through.

After this I used a group expression with the following expression:

i@e == 1

Also, a quick reminder to set the group type to Points. I often forget to do this and have a small heart attack trying to figure out why my expression is not working.

I then used that group in the Source Group section of the POP Source.

Everything else on the Pop Source is the same.

Here I have the example and the node tree, you can also download the scene file here

Previous
Previous

3D Wave Interference

Next
Next

About Me