Pscale from zero to one at random times
3811 11 1-
- R_Stewart
- Member
- 56 posts
- Joined: 3月 2022
- Offline
Hello,
I have a set of points that are animated along splines using MOPS. I need to have these points pscale go from zero to one at random times but I need to control exactly when they all are at pscale zero and all at pscale 1.
For example:
The sequence is 1000 frames long and I need 2 moments when all points are at pscale 1 along this timeline. So frame 1 all would be at pscale zero then by frame 350, they have all scaled up to pscale one at random times, then frame 500 they are all back down to zero, then frame 850 have them all up to 1 again, then frame 1000 all back down to zero.
I'd like to make a slider that I can keyframe from zero to one. .5 on the slider would mean half of the points have randomly scaled to 1 and I need them to scale up slowly so that they are not just popping into existence.
Does that make sense? Sorry, it's probably a really easy thing to do if you know VEX!
I've attached my hip file if anyone would be kind enough to take a look.
Thanks!
I have a set of points that are animated along splines using MOPS. I need to have these points pscale go from zero to one at random times but I need to control exactly when they all are at pscale zero and all at pscale 1.
For example:
The sequence is 1000 frames long and I need 2 moments when all points are at pscale 1 along this timeline. So frame 1 all would be at pscale zero then by frame 350, they have all scaled up to pscale one at random times, then frame 500 they are all back down to zero, then frame 850 have them all up to 1 again, then frame 1000 all back down to zero.
I'd like to make a slider that I can keyframe from zero to one. .5 on the slider would mean half of the points have randomly scaled to 1 and I need them to scale up slowly so that they are not just popping into existence.
Does that make sense? Sorry, it's probably a really easy thing to do if you know VEX!
I've attached my hip file if anyone would be kind enough to take a look.
Thanks!
-
- Hatchery
- Member
- 139 posts
- Joined: 3月 2016
- Offline
-
- animatrix_
- Member
- 4853 posts
- Joined: 2月 2012
- Online
You can write some simple VEX code like this:




string sframes [ ] = split ( chs("frames") ); string svalues [ ] = split ( chs("values") ); int count = len ( sframes ); int frames [ ] = array ( 1 ); int values [ ] = array ( 0 ); for ( int i = 0; i < count; ++i ) { append ( frames, atoi ( sframes [ i ] ) ); append ( values, atoi ( svalues [ i ] ) ); } int startframe = -1; int endframe = -1; float startval = -1; float endval = -1; for ( int i = 0; i < count; ++i ) { int start = frames [ i ]; int end = frames [ i + 1 ]; if ( @Frame >= start && @Frame <= end ) { startframe = start; endframe = end; startval = values [ i ]; endval = values [ i + 1 ]; } } int id = @ptnum; int rendframe = floor ( fit01 ( rand ( id + 4175.2342 + ch("seed") ), startframe, endframe ) ); float val = fit ( @Frame, startframe, rendframe, startval, endval ); @pscale = val; @Cd = hsvtorgb ( val, 1, 1 );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]

-
- florianpruetz
- Member
- 6 posts
- Joined: 7月 2022
- Offline
-
- animatrix_
- Member
- 4853 posts
- Joined: 2月 2012
- Online
florianpruetzanimatrix_
int frames = array ( 1 );
int values = array ( 0 );
Hey,
nice solution!
A question: Why do you use array(1) and array(0) after you declare the arrays? Couldn´t you just declare empty arrays?
FLO
That's to initialize the first frame to 1 and first pscale to 0 as mentioned by OP. This way the user doesn't have the specify what happens in the first frame.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]

-
- R_Stewart
- Member
- 56 posts
- Joined: 3月 2022
- Offline
-
- R_Stewart
- Member
- 56 posts
- Joined: 3月 2022
- Offline
This is exactly what I asked for which is great. Another thing I'd like to do if you are able to help is to have the particles increase in number coming from left to right.
What would be the best way to create a particle system that spawns particles at the start of the splines and sends them perfectly along the moving splines as they are currently. But I'd want to be able to control the birth rate of the particles to give the effect of increased particles coming from the left at certain times on the timeline? This way they would all be entering the camera view at pscale 1, and not randomly scaling up.
This is for a visualisation of traffic data so think of the points/particles as cars on the road. I'd like to be able to make more cars entering from the left but not sure how to do this.
The scaling solution is working just fine but if I could have them entering in higher volumes that would also be really cool!
Thanks for the help I really appreciate it!
What would be the best way to create a particle system that spawns particles at the start of the splines and sends them perfectly along the moving splines as they are currently. But I'd want to be able to control the birth rate of the particles to give the effect of increased particles coming from the left at certain times on the timeline? This way they would all be entering the camera view at pscale 1, and not randomly scaling up.
This is for a visualisation of traffic data so think of the points/particles as cars on the road. I'd like to be able to make more cars entering from the left but not sure how to do this.
The scaling solution is working just fine but if I could have them entering in higher volumes that would also be really cool!
Thanks for the help I really appreciate it!
-
- animatrix_
- Member
- 4853 posts
- Joined: 2月 2012
- Online
I wouldn't use particles for this, just simple points.

You can birth them using Point Generate SOP and control the birth rate there, but you have to use a Solver SOP to accumulate them like this while storing the birth frame:

Then you can get the points to travel along the curve with some speed difference controlled by min/max time to reach the end:


You can birth them using Point Generate SOP and control the birth rate there, but you have to use a Solver SOP to accumulate them like this while storing the birth frame:

Then you can get the points to travel along the curve with some speed difference controlled by min/max time to reach the end:

if ( i@birthframe > @Frame ) removepoint ( 0, @ptnum ); int primid = floor ( fit01 ( rand ( @ptnum * 11.21223 + i@birthframe * 34.123653 ), 0, nprimitives ( 1 ) ) ); float mintime = ch("mintime"); float maxtime = ch("maxtime"); float time = fit01 ( rand ( @ptnum * 7.3242 + i@birthframe * 8.732 ), mintime, maxtime ); int frame = floor ( time * $FPS ); int endframe = i@birthframe + frame; float u = fit ( @Frame, i@birthframe, endframe, 0, 1 ); @P = primuv ( 1, "P", primid, u ); @Cd = primuv ( 1, "Cd", primid, u ); if ( u >= 1 ) removepoint ( 0, @ptnum );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]

-
- R_Stewart
- Member
- 56 posts
- Joined: 3月 2022
- Offline
-
- animatrix_
- Member
- 4853 posts
- Joined: 2月 2012
- Online
No problem, enjoy

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]

-
- R_Stewart
- Member
- 56 posts
- Joined: 3月 2022
- Offline
Hello again animatrix_
Sorry to bother you again but when I open up your file something is not working and I can't figure it out. It will be a very handy tool that I'd love to get working on my end. Seems to be an issue in the solver (or my skill level
When I hit play the points flicker in a stationary position.
Any idea why it wouldn't work for me when I open it up?
Thanks!
Sorry to bother you again but when I open up your file something is not working and I can't figure it out. It will be a very handy tool that I'd love to get working on my end. Seems to be an issue in the solver (or my skill level

When I hit play the points flicker in a stationary position.
Any idea why it wouldn't work for me when I open it up?
Thanks!
Edited by R_Stewart - 2022年10月13日 15:25:15
-
- animatrix_
- Member
- 4853 posts
- Joined: 2月 2012
- Online
Hi, I opened your file, it works here. I didn't use anything custom so not sure why it doesn't work on your computer.
Maybe try the latest build and make sure simulation is enabled.
Maybe try the latest build and make sure simulation is enabled.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]

-
- Quick Links