View Full Version : Color transfer on particle collision

 CarlRiver04 April 2008, 12:17 AMHey guys, I hope you can help me out on this one. I am looking for a way for particles to pick up the color of the surface which they have collided with. Essentially I need to sample the color of a 2D texture map at a given UV position and write this into the rgbPP attribute. How do I go about this? I know how to get the UV coordinates of the collision through the collisionU and collisionV attributes, I even found a way for textures to only output the color at a certain UV coordinate. Still I can't figure out a way how to use this information to drive my rgbPP's. Maybe this would be easier to solve using software particles and a simple shader, but I would very much prefer to use HW particles instead. thx in advance
CarlRiver
04 April 2008, 07:40 PM
Figured out a way to do it. There is a MEL command called colorAtPoint which does exactly what I needed - get the color value of a certain texture node at a certain point in UV space.

Aikiman
04 April 2008, 08:59 PM
Hey Carl, I been playing around with the same node also, did you have any luck getting the ColorAtPoint info into the rgbPP? If so can you share, I have this so far but stuck as to how to get the array info into the rgbPP. Any help would be great cheers. :)

float \$colU = particleShape1.collisionU;
float \$colV = particleShape1.collisionV;
float \$custRGB[ ] = `colorAtPoint -o RGB -u \$colU -v \$colV ramp1`;

rgbPP=\$custRGB; <<<<<this line of code does not work.

CarlRiver
04 April 2008, 09:09 PM
Sure, no problem.

You have to convert the \$custRGB which is an array into a vector. This is the way I did this:

vector \$custColor = <<\$custRGB[0],\$custRGB[1],\$custRGB[2]>>;
rgbPP = \$custColor;

That's it.

Aikiman
04 April 2008, 09:43 PM
arrrr thats how, lol, thanks :)

Aikiman
04 April 2008, 10:12 PM
Not meaning to hijack the thread but its better than starting a new one and you may have the answer anyway so best to use the expertise available if you dont mind, hehehe.

When my particles fall from a surface emitter on the second frame and thereafter until they collide, they are red. I have setup an if statement saying if the particle position is higher than zero then rgbPP = <<1,1,1>> but this wont force it to white. In creation it is working fine since frame one they are white but after that they change to red. Any ideas as to how I can change that?

I also added a collisionGeometryIndex but nothing seems to force it to white.

CGTalk Moderation
04 April 2008, 10:12 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.

1