View Full Version : particle opacity based on angle to camera

 Eraq09 September 2010, 11:02 AMHi good peoples. I just need some good inputs on how to get a solution on a little problem Im having. Im in a need for a smart solution for following: I would like to control a particlesystems opacity based on the angle between a giving camera and the particles velocity. My conditions are: Less opacity when the particles-velocity point into the camera between 5, and -5 degree, full opacity at 0 degree. Less opacity when the particles-velocity point into the camera between 175, and 185 degree, full opacity at 180 degree. I know the basic vectormath to get the angle between the camera and the partilce-velocity, so its more how to transfer this concept into an expression. Im not that good at scripting, so if I can get some suggestions Ill be very happy. Much apriciated. Erik
berniebernie
09 September 2010, 11:36 AM
i did a particle expression once to emit according to facing ratio, should give you some ideas... it's probably not the best code in the world, but works

vector \$pos = particleShape1.position;
vector \$velo = particleShape1.velocity;
vector \$camTr = getAttr("camera1.translate");
vector \$part = \$camTr-\$pos;
\$facingratio = (1-abs(\$angle));
if(\$facingratio <.8){
particleShape1.lifespanPP = 0;
}else{
particleShape1.lifespanPP = 1;
}

Eraq
09 September 2010, 11:58 AM
Hi Matthieu.

Thanks for your input. I can definitely use this script in my development.

You rock :-)

Erik

Eraq
09 September 2010, 12:08 PM
vector \$pos = particleShape1.position;
vector \$velo = particleShape1.velocity;
vector \$camTr = getAttr("camera1.translate");
vector \$part = \$camTr-\$pos;
\$facingratio = (1-abs(\$angle));
if(\$facingratio <.8){
particleShape1.lifespanPP = 0;
}else{
particleShape1.lifespanPP = 1;
}

I just edited the code, so that \$angel is between \$velo and \$part rather that \$velo and \$camTr

Isnt that correct??

Erik

CGTalk Moderation
09 September 2010, 12:08 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