Jump to content
shadowst17

Creating an attribute that slowly decreases per frame?

Recommended Posts

Hello,

I want to create an attribute that over time decreases on each point depending on when they entered the event. Pretty much an age attribute. I can't seem to figure out how to get it to work as you can't seem to reference time within an Attribute VOP and any tutorials that have something similar utilise temperature or particle age which only work if using those types of FX.

Any help with this would be great as feel it can't be too difficult and would be incredibly useful in a number of my projects.

Share this post


Link to post
Share on other sites

I have not used it yet but you may want to check out AttributeFade. Pull up the help card. I think it was designed for tasks such as fading attributes over time.

Edited by Atom

Share this post


Link to post
Share on other sites

You can use attribute Wrangle or do it in attribute Vop 

check you spreadsheet and see how the pscale value goes down. You can decrease any attribute this way and create any kind of event as well. 

f@pscale = 1;

if (@Frame >= 2) { 
    @pscale -= .01 * @Frame;
}
Edited by Sepu

Share this post


Link to post
Share on other sites

Or you can use a fit. I love this function:

float result = fit(@Frame, 100, 200, 1, 0);

This way you can set exactly the duration and the range.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

The two VEX wrangle methods decrease over time which is great. How can I go about beginning that decrease on each point individually when they reach a certain value? Sepu's method seems to do this if I add a CHOP with lag node but eventually they all catch up and crease the value on all points at the same value.

Edited by shadowst17

Share this post


Link to post
Share on other sites

I do not have Houdini in front of me but you could multiply @Time by @ptnum 

something like this 

float myTime = @Time * chf('speed');

@pscale -= myTime * @ptnum;

then you could remove points that are 0 or less, use the removepoint vex function.

Share this post


Link to post
Share on other sites

its the same as saying 

@attr = @attr - other variable or attribute

@attr -= or += is just a shorthand op.

Edited by Sepu

Share this post


Link to post
Share on other sites

bear in mind that multiplying time by 0...1 will be a non-linear asymptote (which can be problematic if you need a zero value). I think that @haggi fit() solution is more predictable.

Edited by shawn_kearney

Share this post


Link to post
Share on other sites
18 minutes ago, fencer said:

You mean like that?

chahge_over_time.hip

This method works really well! The value seems to taper off very quickly though over time, how would I go about making it so it can be a linear transition from 0-1? Haven't really used VEX much.

Share this post


Link to post
Share on other sites
26 minutes ago, shawn_kearney said:

so then:

@P.y += 10

is the same as saying 

@P.y = @P.y + 10

Yes is the same .

Share this post


Link to post
Share on other sites
2 hours ago, shadowst17 said:

This method works really well! The value seems to taper off very quickly though over time, how would I go about making it so it can be a linear transition from 0-1? Haven't really used VEX much.

if(@P.y <0) f@ctime = point(1, "ctime", @ptnum) + 0.1;

0.1 value is increasing value, you can change it on for example 0.0416 (1/24 fps), means that value will change from 0 to 1 in 1 sec

Edited by fencer

Share this post


Link to post
Share on other sites

Hi,  I create one using a sop solver, maybe is usefull, not as elegant as the ones already showed tho, inside the solver there is a ramp that allow you either to make them shrink or grow throw time, also you can control the duration of the Fading modifying the Fade attribute, its just a quick idea, maybe not the most optimized way as you need a solver.

testScaleFade.hip

  • Like 1

Share this post


Link to post
Share on other sites
10 minutes ago, moneitor said:

Hi,  I create one using a sop solver, maybe is usefull, not as elegant as the ones already showed tho, inside the solver there is a ramp that allow you either to make them shrink or grow throw time, also you can control the duration of the Fading modifying the Fade attribute, its just a quick idea, maybe not the most optimized way as you need a solver.

testScaleFade.hip

its really rare, i was developed like this and just finished 5 minute before you upload, and you have done similiar with my approach, and more advance than mine because has a ramp on the solver, thanks moneitor..its really help me alot.

 

Share this post


Link to post
Share on other sites
14 minutes ago, moneitor said:

Hi,  I create one using a sop solver, maybe is usefull, not as elegant as the ones already showed tho, inside the solver there is a ramp that allow you either to make them shrink or grow throw time, also you can control the duration of the Fading modifying the Fade attribute, its just a quick idea, maybe not the most optimized way as you need a solver.

testScaleFade.hip

and how about a random speed time,

where should i put multiplication of random id of point to do speed random time?

Share this post


Link to post
Share on other sites

Hi man, I just added a bit of words to the attribwrangle in order to add some random variation, the slider variation will give you some random values between -variation to +variation.

testScaleFade.hip

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×