Node Group: Frame-ON/OFF

FramesON-OFF-Group

FrameON/OFF (download)

Outputs 1 if current Frame in Range On/Off else 0.
Can be used to have a certain effect only for certain time.
Note: For large Node Setups you might want to use Node Layout – Switch with animated Switch. This would be faster to compute.

Inputs:

  • On Frame

Set Start Frame

  • Off Frame

Set End Frame

Note: On Frame MUST be lower than Off Frame. Otherwise it doens’t work.

How it works:

The Time Node, top left, outputs 0 on Start Frame and 1 on End Frame. For Blender standard Frame Range of 1 – 250 this means the Time Node outputs:

Frame:       Output:
1                   0
2                   0.004
3                   0.008
125               0.498
126               0.502
250               1

You see in each Frame the value rises by 0.004

Now we have two Inputs (for the Node Group FrameON/OFF),
On and Off. Let’s say we have:

On Frame 5
Off Frame 7

And remember we have Frame 1 – 250 as Range, or 0 – 1 as outputed by Time Node.
We now need the On 5 and Off 7 values mapped to 0-1 as well.
To do so we Devide 1 / 250 = 0.004
(Same as Step from Time node Output)

Now we multiply the two Values On and Off by it:

5 * 0.004 = 0.02
7 * 0.004 = 0.028

If you look inside the Node Group (Tab) this is what happens in Frames 0-1 Frame.

Now, what we want to do now is to make, while Time Node is raising from 0-1 by Value 0.004 each Frame, extract the Range from 0.02 to 0.028

To do so we use the Math Nodes Greather Than and Less Than.
The Function of those is simple, but effective. If set to greather than(>):

Value1:     Value2:     Output Value:
0                 2                 0
1                  2                 0
2                  2                 0
3                  2                 1
4                  2                 1

You see it Outputs 1 as soon as Value1 is Greather Than Value2 otherwise 0. (Like False/True)

Now Less than is just the opposite:

Value1:     Value2:     Output Value:
0                 2                 1
1                  2                 1
2                  2                 1
3                  2                 0
4                  2                 0

Let’s remember, We need to extract from Time 0-1 the Range from 0.02 – 0.028. So we use the Greather Than to output 1 if Time > 0.02 and the Less than to Output 1 if Time < 0.028

This will leave us with two Output Values, where the            Greather Than is always:
1 after Frame 5 (or Time >0.02)
Less Than always is:
 1 before Frame 7 (or Time <0.028)
We have now a Overlay of those two on Frame 5, 6 and 7, where both Values are 1. If we multiply the two we get 1 only if both are 1/True.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s