Changing object instance associated with a particle


#1

I am working on a simulation that involves particles changing shape as they cross a threshold. I am using an instancer to associate the initial geometry with the particles that are emitted, and I understand how to change what geometry is associated at creation, but I’m having difficulty finding information about changing the associated instance after emission/creation. I would like the particles to be able to maintain their trajectory, speed, etc, just change shape, e.g. when their x position is greater than a given value. Is this possible?

I am simulating something pretty abstract, but a “real-world” application would be something like an object in motion passing behind an x-ray screen and its appearance changing. Except I want to do this with thousands of (identical) objects.


#2

Hi

Since you mentioned “object passing behind a xray wall” can’t you do what you need just by changing the shading?

/risto


#3

Thanks, but I don’t think so… I actually want to change the shape, e.g. from a sphere to a cube.

After posting my question, I found out that you can change the object index after creation using an “after dynamics” expression, and that works pretty well. I created a per-particle attribute and defined its expression to set the attribute value based on particle position. Then I used that attribute as the value for the Instancer “Object Index” attribute. Solved.

But what I failed to consider in this process (or relate here) is that I’ve converted my particle node to polygons for a blobbing effect, and this doesn’t play very well with the Instancer, which I added after the fact. The instanced geometry doesn’t affect the polygon generation at all. Essentially what I want to happen is for my particles to stop being included in the polygon generation after they cross a threshold, which is probably not something that Maya is going to support very well.

The effect I’m after is a 3D pixelization of a liquid, a digitization of an analog form if you will. I guess it would be similar to how water behaved in the Lego movie, although the blocks wouldn’t have to be so purely discrete (they can overlap/interpenetrate). I can achieve that effect on its own, but I want to be able to show the analog and the digital side-by-side. To go back to the x-ray analogy, on one side you see the analog blob, but the part that’s behind the screen is all blocky. Same particle entities, different form depending on particle position. Any thoughts on how to do this?


#4

One possible solution could be creating a index per particle and create a runtime expression that queries the distance and changes the indexPP. Just don’t forget to change the object Index in the particleShape to the created indexPP.
Example:

float $pos[] = nParticleShape.position;

if ($pos[0] >= 5) {
nParticleShape.indexPP =1;
}
else {
nParticleShape.indexPP = 0;
}

In this example i store the position of the particle in the “$pos[]” array. In the if statement i query the x-position($pos[0]) and set the index to 1. The “else” part just sets the index for objects not passed the specified distance. Instead of writing the else you could just write the standard indexPP in the creation expression.

Hope that helps a little.
Dennis


#5

Sorry, didn’t see your post(probably wasn’t reviewed). The effect you are looking for is probably best solved in rendering. Create both effects, cache them and blend them with a hold out in comp.


#6

Thanks for the tips, Dennis! Could you explain what that process would look like? I’m an architecture student, and I’m definitely still a noob when it comes to shaders and compositing.


#7

i think vray could do the job: therenderblog.com - Vray booleans
Or you could try the same with mayas booleans…but they are not perfekt :smiley:
And the cliping plane might be an idea, although that depends on the position of the camera…

Perhaps i can come up with something better or different. But for now this should keep you going. Maybe someone else also has some ideas

Dennis


#8

I would also suggest what Dennis did, which is rendering twice and compositing them together, either with clipping planes or using a depth pass perhaps.

Another solution could be at the point when the particle crosses the threshold emit into a new particle system which isn’t being meshed. Using the ‘emit’ MEL command you could pass all the relevant attributes through to the new particle. Those being mainly position and velocity I guess in your case, possibly rotation also.

Cheers Jake.