download script here > http://www.vfxtalk.com/forum/attachment.php?attachmentid=5205&stc=1&d=1198102192
view in high res here > vfxtalk
Flipbook FX
Stepping Expression
A few time ago i need to create a tree that works like a flipbook, so a big part of the technique reside in a function than can keep a value for a variable number of steps and jump to next value, for example if i want to flip exposing 4 frames each one i need a function that create this step graphic...
so each value must be kept 4 frames somethig like
frame 1 timevalue 0
frame 2 timevalue 0
frame 3 timevalue 0
frame 4 timevalue 0
frame 5 timevalue 4
frame 6 timevalue 4
frame 7 timevalue 4
frame 8 timevalue 4
....
the graphic must look like this....
stepping function
the equation behind this graphic is inside a time node and is the following>
newTime = floor( ( floor( time/(step) )*step ) )
this can be read as
new time is equal at time divided by step tacked down floor and then multiplied by step and tacked down floor again.
for example time value at 22 with a step value of 4
newTime= floor( ( floor( 22/(4) )*4 ) )
- newTime= 22/4=5.5
- newTime= floor(5.5)=5
- newTime= 5*4=20
newTime=20
this way we are getting the same entire value until the decimal part goes to one unit more each 4 steps.
( for nuke you can use de Hold operator, or whatever you can generate the expression inside another node adding a step custom knob and putting this expression>
expression > floor(frame/this.step)*this.step)
)
to take control of this expression i create 2 custom variables
- fliptime
- step
And step is the final calculation of the stepping. (if you want to add some noise behavior you can calculate on the step... for now step will be the same as fliptime ).
timeMaster
Flipping Expression
Well, with this we will be stepping the animation frames, that is the first part of the script, but now we need to create a function that drives a loop to have the paper flipping in the selected step range.
For example for the same stepping of 4
frame 1 rotattion -110
frame 2 rotation -82.5
frame 3 rotation -55
frame 4 rotation -27.5
frame 5 rotation 0
frame 6 rotattion -110
frame 7 rotation -82.5
frame 8 rotation -55
frame 9 rotation -27.5
frame 10 rotation 0
Our graphics may look like these
flip function
The expression to obtain this kind of loop fliping equation is
angle = ( ( (time % step)/ step)-1 ) *desiredangle
basically we are taking the remainder of dividing the time over the step.
This way we are getting a loop of values kind of
Step 4
remainder = frame % 4
frame 1 remainder 1
frame 2 remainder 2
frame 3 remainder 3
frame 4 remainder 0
frame 5 remainder 1
frame 6 remainder 2
frame 7 remainder 3
frame 8 remainder 0
then i am dividing this reminder over the step to get the percentage point of the stepping so
percentageOfStepping=remainder/step
frame 0 percentageOfStepping 0%
frame 1 percentageOfStepping 25%
frame 2 percentageOfStepping 50%
frame 3 percentageOfStepping 75%
frame 4 percentageOfStepping 0%
frame 5 percentageOfStepping 25%
frame 6 percentageOfStepping 50%
frame 7 percentageOfStepping 75%
The next -1 is used to obtain de completent of 1 this way im switching the direction of the graphic.
frame 0 percentageOfStepping 100%
frame 1 percentageOfStepping 75%
frame 2 percentageOfStepping 50%
frame 3 percentageOfStepping 25%
frame 4 percentageOfStepping 100%
frame 5 percentageOfStepping 25%
frame 6 percentageOfStepping 50%
frame 7 percentageOfStepping 75%
finally this values are multiplied by the max flipped angle value
i use this expressions on a move 3d node
move3D function
Another useful expression is a variant of the steeping one equation that adss some randomness to each loop cycle
the expression is teh following>
noiseStep=(noise(floor(time/step)*step)*NoiseRange)
as you can see im feeding the noise with the same
floor(time/step)*step
that we use to retime our clip then the result is multiplied by a NoiseRange the way we can obtain each cycle a different but constant value.
I use this on my random stepped color correction functions>
frame 1 rotattion -110
frame 2 rotation -82.5
frame 3 rotation -55
frame 4 rotation -27.5
frame 5 rotation 0
frame 6 rotattion -110
frame 7 rotation -82.5
frame 8 rotation -55
frame 9 rotation -27.5
frame 10 rotation 0
Our graphics may look like these
flip function
The expression to obtain this kind of loop fliping equation is
angle = ( ( (time % step)/ step)-1 ) *desiredangle
basically we are taking the remainder of dividing the time over the step.
This way we are getting a loop of values kind of
Step 4
remainder = frame % 4
frame 1 remainder 1
frame 2 remainder 2
frame 3 remainder 3
frame 4 remainder 0
frame 5 remainder 1
frame 6 remainder 2
frame 7 remainder 3
frame 8 remainder 0
then i am dividing this reminder over the step to get the percentage point of the stepping so
percentageOfStepping=remainder/step
frame 0 percentageOfStepping 0%
frame 1 percentageOfStepping 25%
frame 2 percentageOfStepping 50%
frame 3 percentageOfStepping 75%
frame 4 percentageOfStepping 0%
frame 5 percentageOfStepping 25%
frame 6 percentageOfStepping 50%
frame 7 percentageOfStepping 75%
The next -1 is used to obtain de completent of 1 this way im switching the direction of the graphic.
frame 0 percentageOfStepping 100%
frame 1 percentageOfStepping 75%
frame 2 percentageOfStepping 50%
frame 3 percentageOfStepping 25%
frame 4 percentageOfStepping 100%
frame 5 percentageOfStepping 25%
frame 6 percentageOfStepping 50%
frame 7 percentageOfStepping 75%
finally this values are multiplied by the max flipped angle value
i use this expressions on a move 3d node
move3D function
Noise Stepped Expression
Another useful expression is a variant of the steeping one equation that adss some randomness to each loop cycle
the expression is teh following>
noiseStep=(noise(floor(time/step)*step)*NoiseRange)
as you can see im feeding the noise with the same
floor(time/step)*step
that we use to retime our clip then the result is multiplied by a NoiseRange the way we can obtain each cycle a different but constant value.
I use this on my random stepped color correction functions>
Well these are the basic expressions to create a true flipbok effect take a look at the script.
tree overview
download script here > http://www.vfxtalk.com/forum/attachment.php?attachmentid=5205&stc=1&d=1198102192