PDA

View Full Version : Making Wave


olivermr
08-30-2009, 07:32 PM
hello all,

I would like to ask how I can make a surface emit particles based on the color of an image and the height of its vertices.

My intention is to create a wave, and I’d like particles it emits as it was born.

This is my script but does not work.

vector $pos = nParticleShape1.position;
float $px = $pos.x;
float $pz = $pos.z;
float $foam[] = `colorAtPoint -u $px -v $pz ramp1`;
float $py = $foam[0];
float $foamheight= .5;
if( $foam[0] > $foamheight ){
nParticleShape1.position=<<$pos.x, $py, $pos.z>>;
nParticleShape1.lifespanPP = rand(1) + 0.4 ;
} else {
nParticleShape1.lifespanPP = 0;
}

anyone know where I’m wrong?

these are my references:

http://surfsup.awn.com/?type=article&artID=3

http://www.veoh.com/search/videos/q/sony+surf+up#watch&#x3D;v1173792TjBMTyYC

Thanks!!!

Aikiman
08-30-2009, 07:53 PM
Looks like you are missing an 'if' statment just after float $foamheight= .5;.

olivermr
08-30-2009, 08:03 PM
Looks like you are missing an 'if' statment just after float $foamheight= .5;.


Hello

no, my mistake was writing the post, in my scene is fine, and I corrected the post


attached a sample scene



Maya 2009

Thanks!

Aikiman
08-30-2009, 09:14 PM
Sorry I cant fix your problem entirely but there a just a couple of things you need to know to make this work. Firstly your code is fine, I just checked it and it works on a ocean shader. Secondly make sure your particles are set to lifespanPP not Random Lifespan otherwise they wont listen to your lifespanPP calls in your expressions. And thirdly you have to remember that the colorAtPoint command is referencing your file and NOT the mesh so like the ocean shader your file should drive the displacement of your mesh also. Therefore your expression is reading the white value on your ramp and not the cluster handle (or more accurately the vertice displacement) on your mesh. If you change your foamheight to 5 for example and then go into your ramp and change the white to 6 you will notice that your particles will emit at 6 units in Y.

Heres where I am having problems. Although your particles are emitting 6 units high, they are not being culled in x and z. Seems like a very simple problem to fix, I need a little more time to play around with it.

Aikiman
08-30-2009, 09:37 PM
vector $pos = nParticleShape1.position;
float $parentU = parentU;
float $parentV = parentV
float $foam[] = `colorAtPoint -u $parentU -v $parentV ramp1`;
float $py = $foam[0];
float $foamheight= .5;
if( $foam[0] > $foamheight ){
nParticleShape1.position=<<$pos.x, $py, $pos.z>>;
nParticleShape1.lifespanPP = rand(1) + 0.4 ;
} else {
nParticleShape1.lifespanPP = 0;
}


Try this for size. Using parentU and parentV for position works, make sure "need ParentUVs" is on for the emitter.

olivermr
08-31-2009, 08:38 AM
hello Aikiman,

first of all, thanks for answering so fast.

I changed my script, but I still get the effect I want. With your permission, I send you a mail for that scene to see exactly as it should work.

again thank you very much for your help.

CGTalk Moderation
08-31-2009, 08:38 AM
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.