View Full Version : math function to fade var in Expression?

 CLT03 March 2003, 02:18 PMHi, I have a variable in an expression and wish to fade the value to 0 across whatever time. - is there an elegant math funtion to do this.. struggling with what should be a simple thing. Cheers
Jozvex
03 March 2003, 03:12 AM
Hi, the linstep function can do that.

Example:

Variable.number = 5 - (linstep(0, 60, frame) * 5);

That will decrease the number 5 down to the number 0 over 60 frames.

Linstep ramps a number from 0 to 1 over a specified time, like this:

Variable.number = linstep("starting time", "ending time", "what the time is")

So Variable.number = linstep(0, 5, time)

Will ramp from 0 to 1 over 0 to 5 seconds.

Get it?

CLT
03 March 2003, 06:32 PM
You diamond .... I had been fiddling with this function
but was not sure if it was the way to go
I`ll see if it will accomplish what I need to do
... will renew my efforts
Thanx alot

Cheers 4 now

ajk48n
04 April 2003, 08:29 PM
You could also make a new variable, and make it equal to "old_variable/currentFrame". That way, as the animation played on, the new variable would continue to get samller.

You might have to multiply the currentFrame by something o get the starting psotion what you want.

I know this is a really rough solution, but it should work.

James Jackson
04 April 2003, 11:07 PM
I like to use ramps. ramps are much friendlier than the linstep and smoothstep.

Take opacityPP on a particle for example. (I am assume we are talking about particles as this is the dynamics thread, but hey I can be wrong)

This is what I do.
create a PP attr named initOpacityPP
example.initOpacityPP = rand (.3,.7);
then i would add the allready built in scalar opacity attr
then i would make another attr on the particleShape node called
opacityMult I would then assign a ramp to that.

then for the opacityPP attr i would write.
//runtime

example.opacityPP = initOpacity * opacity * opacityMult;

//creation

example.opacityPP = initOpacity * opacity * what ever the value of the bottom of the ramp used in opacityMult;

that way you get nice control over your falloff.

of course I use linstep and smoothstep from time to time but I like the ease of ramps.

CLT
04 April 2003, 09:14 PM
Hi , Thanks

I`ll give this a try... sounds interesting anyway..
I `m quite into this ramp thing myself...
Cheers

CGTalk Moderation
01 January 2006, 06:00 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