PDA

View Full Version : particle displacement??!?!


olcho
03-31-2005, 12:17 AM
Hi, I was wondering if someone knows how to make something like particle displacement.
Suppose I have a plane that shoots particles up. As the particles travel, I want them to take the shape of a head and when they reach the top of the head to continue to travel strait up (if you remember "The Mummy", the effect with the sand wall). Any ideas?
I could model a plane, add goal to the particles and animate the goal to change from 0 to 1, but I really would like to use textures...

olcho
04-01-2005, 12:37 AM
ok, solved it! if anyone's interested, I'll post the solution

ashishdantu
04-01-2005, 02:43 AM
hi olcho,

good that u solved it..:D and now tell us ur approach..

cheers,,

joss3D
04-01-2005, 07:15 AM
i'm interesting to know it too ;)


the only way i know to make a displacement on particle is this script.
http://www.worldofmaya.com/d_scripts.html#particleDisplacement
and the tutorial:
http://www.worldofmaya.com/d_displace.html
as well as i remember, it make a particle grid and it's displace the particles by a y translation
but it's don't work for particles emit from a surface (and goal the surface) for exemple

i tried a few times ago to make a particles displacement on "nonplane" object (spherical by exemple) but i wasn't able to get a correct normal vector at the goalPoint of the particles (neither for a correct vertex normal :shrug:)

so i'm very interesting to know haw you did your effect.

cheer

olcho
04-01-2005, 09:55 AM
I also found that script with the particle grid and looked into it to try to figure a way to do it, but it wasn't very helpful...
Anyway, the approach still involves the usage of a goal to a Nurbs surface. I did it using a plane. With a more complex surface the displacement won't work correctly since I influenced the particles only in one axis. I'll try to find a way to use the normal direction.
So I made surface emiter and a NURBS plane to be the goal.
For the goalU i used a rand(0,1) to distribute them randomly on the surface and then animated the goalV to go from 0 to 1. This tells the particles to go to the top of the plane.
When the particles reach 1, that is when goalV becomes 1, I kill them using lifaspanPP, but that's only if you want it this way.
I assigned a texture to the plane and then used colorAtPoint -u goalU -v goalV <the name of the texture>, wich returns an array with the RGB values of the texture. In my example I needed to displace the patricles in the Z direction, so I used goalOffset = <<0, 0, (colorAtPoint value)>>. That's the basic setup.
I added some more controls on the particleShape, like the displacement ammount, which is just a multiplier to the offset and some variation control in the goalV.
Also I control the opacity of the non-displaced particles, because I wanted to make particles sliding along a face and I wanted to see only them.
And a ramp to control when I realease the particles from the surface in case I want to add some forces.
Here's the scene, hope it helps and I hope you'll understand what I did. I added notes in the expressions.

joss3D
04-01-2005, 10:55 AM
here is what i try:

a nurbs sphere (with a checker) emit particles with needParentUV on
the same surface is the goal too.
add perParticles attribut colorPP, goalU ,goalV and goalOffset
change the lifespan mode to lifespanPP

and i put this script in creation :

//get UV parameter
$u = particleShape1.goalU = particleShape1.parentU;
$v = particleShape1.goalV = particleShape1.parentV;

//get the color at point
float $colorAtPoint[] = `colorAtPoint -o A -u $u -v $v checker1`;

//shade the particle with the color
particleShape1.rgbPP = $colorAtPoint[0];

//kill not displaced particle
if ($colorAtPoint[0] < 0.9)
particleShape1.lifespanPP = 0;

///////////////////////////////

//in runtime:


//get UV parameter
float $u = particleShape1.goalU;
float $v = particleShape1.goalV;

//get color at point (displace value)
float $colorAtPoint[] = `colorAtPoint -o A -u $u -v $v checker1`;

//get normal at point
float $normal[] = `pointOnSurface -u $u -v $v -n nurbsSphere1`;

particleShape1.rgbPP = $colorAtPoint[0];

//offset the particle goal by the normal value and the displace value
particleShape1.goalOffset = << ($normal[0]*$colorAtPoint[0]), ($normal[1]*$colorAtPoint[0]) ,($normal[2]*$colorAtPoint[0])>>;

//kill not displaced particle
if ($colorAtPoint[0] < 0.9)
particleShape1.lifespanPP = 0;

//////////////////////////////


what i do to know if the normal are correct, i put the emition rate to 500000 and make the max count to 300, so all particles born in the same time
next i increment the goalOffset

//increment goalOffset
particleShape1.goalOffset += << ($normal[0]*$colorAtPoint[0]), ($normal[1]*$colorAtPoint[0]) ,($normal[2]*$colorAtPoint[0])>>;


then emit particle from the displaced particle (with a speed of 0)
so i have a feedback of the normal at point to evaluate if it's correct or not



I don't know if I get a correct normal or if I drive correctly the goalOffset vector:shrug:

need more experimentation for me.....

olcho
04-01-2005, 07:21 PM
I'll definitely try your example but a little later.

But I think that animating the goalOffset is wrong. Because the way you do it, the U and V don't chage. You only change their possition by animating the goalOffset. Like this, the colorAtPoint and pointOnSurface won't work, because your U and V don't change. Try animating the goalU and goalV. I believe this is the way to do it.

joss3D
04-01-2005, 08:06 PM
yes you right man, i didn't use the sames rules as you for the particles motion

I forgot to say that this script is just for displacing particle along the normal.
incrementing the goal offset maybe a way to verify if the normal seems correct.
you say that you have dificult to find a good normal at the particle position that's why I post this script.
you can animate the goalU and V but you have to get the u and v parameter ($u et $v on my script) after animate the goalU and V.

hope it's help (by the way I learn a lot doing this ;)

olcho
04-01-2005, 11:19 PM
Thanks joss3D! It's really a big help!:thumbsup: :bounce: :thumbsup: :bowdown:

olcho
04-02-2005, 12:35 AM
joss3D, do you know how can I normalize the U and V of the sphere? Because I get U and V that are more than 1 when I create the Sphere.

olcho
04-02-2005, 01:09 AM
I'm getting something really weird. Could you take a look the scene? The colorAtPoint doesn't match the texture on the sphere. I think it has to do something with the UV of the sphere....

joss3D
04-02-2005, 09:13 AM
joss3D, do you know how can I normalize the U and V of the sphere? Because I get U and V that are more than 1 when I create the Sphere.

you can rebuild your nurbs surface with rubuildSurface, in the option box check on the "0 to 1" option (normalize the UV) and set the num of span U et V to 0 in order to have the same number of span.

i will take a look to your scene when i will be in front of my workstation cause i'm still at home only with my old museum computer and without maya :D

joss3D
04-02-2005, 01:26 PM
i open your scene and the colorAtPoint wasn't well evaluated.

if you open the attribut editor and select your sphere, you see that:
min rage U is 0 , max range U is 4
min rage V is 0 , max range V is 8

that's meen that the parameterU go from 0 to 4 and the parameterV from 0 to 8.

to ahve a normalized UV just select your sphere go to edit Nurbs -> rebuild surface option box -> parameter range from 0 to 1 (to normalize)
->number of span U 0
-> number of span V 0 (to get the same number of span)

go to the attribut editor toi see what's apend on the surface U and V range (go to 0 to 1 now)

with this your colorAtPoint wil be well avalueted from the U and V position of your particles

olcho
04-02-2005, 01:43 PM
Thanks! It's perfect! :bounce:

CGTalk Moderation
04-02-2005, 01:43 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.