Jump to content
Hash, Inc. Forums

How to reduce the frequency of iterations Rand() expression?


serg2

Recommended Posts

Instead using the Rand every frame, set up counter that steps through x frames before the Rand is used again.

 

 

I would like to have the opportunity to set the random amplitudes. Or understand where to insert a such counter.

Link to comment
Share on other sites

Instead using the Rand every frame, set up counter that steps through x frames before the Rand is used again.

I would like to have the opportunity to set the random amplitudes. Or understand where to insert a such counter.

 

I just noticed that in 18a there is a new function AtTime(time, n) - perhaps that can be used? along with maybe If, gettime, trunc, round functions ?

 

Is there a place somewhere, where there is a description of each (all) of these functions and what they do (along with maybe units?). I haven't used expressions - so I know nuthin'.

functions18a.jpg

Link to comment
Share on other sites

Instead using the Rand every frame, set up counter that steps through x frames before the Rand is used again.

I would like to have the opportunity to set the random amplitudes. Or understand where to insert a such counter.

 

I just noticed that in 18a there is a new function AtTime(time, n) - perhaps that can be used? along with maybe If, gettime, trunc, round functions ?

 

Is there a place somewhere, where there is a description of each (all) of these functions and what they do (along with maybe units?). I haven't used expressions - so I know nuthin'.

 

 

soul-searching could not understand how they work AtTime() and SetFrame()))

Link to comment
Share on other sites

  • Hash Fellow

Here's AtTime....

 

New expression keyword "AtTime(time, n)", where time is the time for which You want to have the value for n , n is the Bone information example AtTime(GetTime()+SetFrame(2),..|..|..|..|Model1.Transform.Translate.Y) where GetTime()+SetFrame(2) , evaluates the Y position for Model1 at the current chor time + 2 frames

 

 

SetFrames() is also a new keyword, setting the time value in frames based on the current fps, time value is always based on seconds

 

I think these will indeed be helpful.

 

I forgot we don't have actual variables. Lemme think about this a bit more but i have no doubt that what you want can be done.

Link to comment
Share on other sites

Here's AtTime....

 

New expression keyword "AtTime(time, n)", where time is the time for which You want to have the value for n , n is the Bone information example AtTime(GetTime()+SetFrame(2),..|..|..|..|Model1.Transform.Translate.Y) where GetTime()+SetFrame(2) , evaluates the Y position for Model1 at the current chor time + 2 frames

 

 

SetFrames() is also a new keyword, setting the time value in frames based on the current fps, time value is always based on seconds

 

I think these will indeed be helpful.

 

I forgot we don't have actual variables. Lemme think about this a bit more but i have no doubt that what you want can be done.

 

will try!

Link to comment
Share on other sites

  • Hash Fellow

Here's my mystery so far...

 

If I set a Null's Y value to be equal to Sin(ChorTime()) it floats up and down in a sine wave manner as expected

 

If i set another object's Y value to be equal to AtTime(1,the Null's Y value), the object takes the Null's Y value at 1 second and stays put there, as expected, even as the Null continues its sine wave motion.

 

If I set the Null's Y value to be equal to Rand() it jumps up and down within a 0 to 1 range, as expected. If I scrub through 1 second the particular value it has at exactly 1 second is always the same, as expected.

 

 

However... the object, which is set to use the Null's Y value at 1 second, doesn't stay put anymore. It is jumping up and down as if it were constantly tracking the Null's Y value instead of just taking the Y value at 1 second.

Link to comment
Share on other sites

Here's my mystery so far...

 

If I set a Null's Y value to be equal to Sin(ChorTime()) it floats up and down in a sine wave manner as expected

 

If i set another object's Y value to be equal to AtTime(1,the Null's Y value), the object takes the Null's Y value at 1 second and stays put there, as expected, even as the Null continues its sine wave motion.

 

If I set the Null's Y value to be equal to Rand() it jumps up and down within a 0 to 1 range, as expected. If I scrub through 1 second the particular value it has at exactly 1 second is always the same, as expected.

 

 

However... the object, which is set to use the Null's Y value at 1 second, doesn't stay put anymore. It is jumping up and down as if it were constantly tracking the Null's Y value instead of just taking the Y value at 1 second.

 

It could be because of the way the Rand() function generates it's random number. If it's truly random, and generated on each frame, it might change every time you go through the same frame...which I'm guessing would mess with something trying to predict where it will be on a given frame. Just a guess though, I could be totally wrong.

Link to comment
Share on other sites

  • Hash Fellow

Here's a example case. The vase's Y translation is on a Rand() expression.

 

RandomTest.prj

 

Pick any specific time like 1:00 and scrub to it, out of it, back to it, before it, back to it.... the vase will always land in the same spot at 1:00

 

The Rand() function generates a random sequence but the sequence is repeatable no matter how many times the animation is played. That is as it should be and the example behaves that way.

Link to comment
Share on other sites

How can I change the frequency Rand()?

 

inspired by johnl3d post - "expression RGB(r,g,B) has anyone used this, or has instructions"

 

http://www.hash.com/forums/index.php?showtopic=46209

 

RAND.jpg

 

Maybe something like this project? Model1 moves Rand()*30, Model2 moves Round(..|..|..|..|..|..|Shortcut to Model1|Bones|Bone1.Transform.Translate.Y,15)...so, you would use something outside of the visible object (with a random movement) to generate movement on the visible object (which is only moving once a threshold is reached...in this case, 15).

 

Hope that helps.

Random_04_16_2014.prj

Link to comment
Share on other sites

Here's a example case. The vase's Y translation is on a Rand() expression.

 

RandomTest.prj

 

Pick any specific time like 1:00 and scrub to it, out of it, back to it, before it, back to it.... the vase will always land in the same spot at 1:00

 

The Rand() function generates a random sequence but the sequence is repeatable no matter how many times the animation is played. That is as it should be and the example behaves that way.

 

Hmmm, maybe it's a bug in the AtTime() function that is causing the problem?

Link to comment
Share on other sites

  • Hash Fellow
Hmmm, maybe it's a bug in the AtTime() function that is causing the problem?

 

That is my first suspicion, but not supported by the case where we are sampling from a sine wave instead of a random noise wave. I dunno. :unsure:

Link to comment
Share on other sites

Basically i want to sample and hold a value until i need to sample it anew.

 

Some nested "If()" statements along with some "AtTime()" statements could probably get a few things like that done. What would be an example of what you would want to do, Robert?

Link to comment
Share on other sites

  • Hash Fellow
Basically i want to sample and hold a value until i need to sample it anew.

 

Some nested "If()" statements along with some "AtTime()" statements could probably get a few things like that done. What would be an example of what you would want to do, Robert?

 

Serg wants to get a random value captured less often than every frame

 

Say, capture it on frame 0 and assign it to the Y property and then leave that value on that property for 5 frames. Then...

 

Capture a new random value on frame 5 and assign it to the Y property and then leave that value on that property for 5 frames. And so on...

Link to comment
Share on other sites

I forgot we don't have actual variables. Lemme think about this a bit more but i have no doubt that what you want can be done.

 

Create a null and store the value you want to store in one of its channels.

But in the end, what I think you will need is the possibility to access the current Value of a given value you want to set an expression in. I already asked Steffen for such a variable or function, but that may take a while to implement for the public release.

 

Like that you could for instance use stuff like "curValue + rand() * 5" to generated quite nice things with it. Like that you would not have to use a complex function which would give you exactly the graph you need. (which can be quite hard)

 

See you

*Fuchur*

Link to comment
Share on other sites

  • Hash Fellow
Create a null and store the value you want to store in one of its channels.

 

This will just transfer the problem to a different object.

 

 

What I think you will need is the possibility to access the current Value of a given value. I already asked Steffen for one, but that may take a while to implement for the public release.

 

This would make it much simpler. Currently you get a circularity or a crash if you try to assign a value from the same property, even a past value.

Link to comment
Share on other sites

Side note when working on the randomizing color issue I was getting crashes although samples posted worked when I set up mine AM would stop responding and close. I decided to uninstall 18d completely then reinstalled it clean and then issue was resolved. (normally I would just install the update in a new folder i.e 18d and not delete earlier version)

Link to comment
Share on other sites

  • Hash Fellow

My observation so far... AtTime works properly if the target it is getting a value from is something that is keyframed.

 

If the target is something being moved by an expression, AtTime does not work correctly.

 

 

I didn't save my working example where the target was on a Sinewave expression and i can't recreate it today. Maybe i dreamed it. :unsure:

Link to comment
Share on other sites

  • Hash Fellow

David, I watched your AtTime tutorial and I think i am using it correctly. Good tutorial!

 

Here is a demonstratin project that shows teh difference between a keyframed target and an expressioned target.

 

ExpressionTest08_keyframe_vs_expression.prj

 

In both chors the Vase has an expression to set it to the Y value of the Null at 1.5 seconds.

 

In Chor "Keyframed" the null is keyframed in a conventional manner to float up and down. In this chor the Vase stays in a fixed place, as expected.

 

In Chor "Expressioned" the null is on a Sin() expression to make it float up and down. In this chor the vase does not stay fixed and follows the Null.

Link to comment
Share on other sites

David, I watched your AtTime tutorial and I think i am using it correctly. Good tutorial!

 

Here is a demonstratin project that shows teh difference between a keyframed target and an expressioned target.

 

ExpressionTest08_keyframe_vs_expression.prj

 

In both chors the Vase has an expression to set it to the Y value of the Null at 1.5 seconds.

 

In Chor "Keyframed" the null is keyframed in a conventional manner to float up and down. In this chor the Vase stays in a fixed place, as expected.

 

In Chor "Expressioned" the null is on a Sin() expression to make it float up and down. In this chor the vase does not stay fixed and follows the Null.

 

Looks like AtTime() is for keyframed sources only. I don't know if Steffen can add Expression sources, might be worth asking.

Link to comment
Share on other sites

working on idea using for now translate Y this expression If(Mod((ChorTime()*30),5)=0,Rand()*50,100) which keeps the model at 100 except every 5th frame takes random value this might be used to keep color for x number of frames then put a new color in to the next x number frame if values stored in null ...getting late will try more later

 

 

ex1.mov

 

ex1.zip

 

 

Mod gives remainder and division by set number so here ChorTime()*30),5 = 0 every 5th frame

Link to comment
Share on other sites

  • Hash Fellow

Serg, here's a workaround...

 

-Create the Rand() expression like you wanted to.

 

-Set the FPS of the Project to the rate that you want your Rand function to change ( like 3 fps)

 

-"Bake all actions"

 

- set the interpolation of the baked random channel to Hold

 

-set the Project FPS back to the original FPS.

Link to comment
Share on other sites

  • 2 weeks later...
  • Hash Fellow

Steffen has AtTime fixed in v18f so look for that when it comes out.

 

He's also added something called CurrentValue that should let you use a current value in an expression as part of its new value.

Link to comment
Share on other sites

Steffen has AtTime fixed in v18f so look for that when it comes out.

 

He's also added something called CurrentValue that should let you use a current value in an expression as part of its new value.

 

Sadly this does not work for all channels till now. If you find one where it doesnt please let Steffen know, since he has to implement it there too then...

 

See you

*Fuchur*

Link to comment
Share on other sites

Did Steffen ever put up an example of CurrentValue() in use?

 

I haven't had any success with it so far.

 

it just does not do what it should yet. i have already told steffen that but he is not available at the moment.

 

See you

*Fuchur*

Link to comment
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...