Eyeon:Manual/Fusion 6/Expression

From VFXPedia

Jump to: navigation, search
Expression

[ Main Manual Page ]


Expression [-/-]

Image:F6_Icon_Modifier2.png

Adding an Expression modifier to a control will add the ability to control and manipulate either position or value controls based on any number of controls, either positional or value-based. This modifier offers exceptional flexibility compared to the more limited Calculation or Offset modifiers, but it is unable to access values from frames other than the current time.

An Expression will accept up to nine value inputs and nine position inputs that are used as part of a user-defined mathematical expression to output a value.

To add an Expression to a control, right-click on the control and choose

Modify With -> Expression
from the context menu. The type of value that will be returned by the expression entirely depends on the type of control it is modifying.

When used with a value control (like a slider), the expression in the Number Out tab will be evaluated to create the result. When used to modify a positional control (like a tool's center), the Point Out tab will control the result.

The Modifiers view contains the controls for the Expression modifier. Its controls are described below.

Contents




Controls Tab

This tab provides nine number controls, and nine point controls. The values of the number controls can be referred to in an expression as n1 through n9. The X-coordinate of each point control can be referred to as p1x through p9x, while the Y-coordinate is p1y through p9y.

These values can be set manually by the user, connected to other parameters, animated and even connected to other Expressions or Calculations.






Number Out Tab


This enables a mathematical formula to be entered, which can access the values from both the Number In and the Point In tabs and output a value used to modify the control to which the expression was applied.

See below for the syntax to use in this field.





Point Out Tab

Each one of the text boxes in this tab can contain a mathematical formula that can access the values from both the Number In and the Point In tabs and output a value used to modify the control to which the expression was applied. The expression in the top text box control is used to calculate the X-axis value and the bottom text box is used to calculate the Y-axis control.

See below for the syntax to use in this field.





Config Tab


A good expression can be re-used over and over again. As a result, it can be useful to provide more descriptive names for each input and to hide the ones that are unused. The Config Tab of the expressions modifier is used to customize visibility and name for each of the nine point and number inputs.


Random Seed

The Random Seed control is used to seed the Rand() function. The rand(x, y) function produces a random value between X and Y, producing a new value for every frame. As long as the setting of this random seed slider remains the same, the values produced at frame x will always be the same. Adjust the seed slider to a new value to get a different value for that frame.


Show Number Or Point X

There are eighteen of these checkbox controls, one for each of the nine number and point inputs. Enable this checkbox to display the control for Number x or Point x in the Controls tab.


Name For Number Or Point X

There are eighteen of these edit controls, one for each of the nine number and point inputs. Type a new name for the input into this edit control to assign a new name for the input's label in the Controls tab.





Expression Syntax / Formulas


Formulas are entered into the Number Out or Point Out tabs as part of expression. They can be made up of the following functions:

n1..n9 The value of Number Input 1..9.
p1x..p9x The X of Positional Control 1..9.
p1y..p9y The Y of Positional Control 1..9.
time The current time (frame number).
pi The value of pi.
e The value of e.
log(x) The base-10 log of x.
ln(x) The natural (base-e) log of x.
sin(x) The sine of x (x is degrees).
cos(x) The cosine of x (x is degrees).
tan(x) The tangent of x (x is degrees).
asin(x) The arcsine of x, in degrees.
acos(x) The arccosine of x, in degrees.
atan(x) The arctangent of x, in degrees.
atan2(x, y) The arctangent of x,y, in degrees.
abs(x) The absolute (positive) value of x.
int(x) The integer (whole) value of x.
frac(x) The fractional value of x.
sqrt(x) The Square Root of x.
rand(x, y) A random value between x and y.
rands(x, y, s) A random value between x and y, based on seed s.
min(x, y) The minimum (lowest) of x and y.
max(x, y) The maximum (highest) of x and y.
dist(x1, y1, x2, y2) The distance between point x1,y2 and x2,y2.
dist3d(x1,y1,z1,x2,y2,z2) The distance between 3D points x1,y2,z1 and x2,y2,z2
noise(x) A smoothly varying Perlin noise value based on x
noise2(x, y) A smoothly varying Perlin noise value based on x and y
noise3(x, y, z) A smoothly varying Perlin noise value based on x, y and z
if(c, x, y) Returns x if c <> 0, otherwise y.





Expression Syntax / Operators


Operators are used to evaluate statements. They are combined with functions to perform logical and mathematical calculations in the Number Out and Point Out tabs.

x + y x plus y.
x - y x minus y.
x < y 1.0 if x is less than y, otherwise 0.0.
x > y 1.0 if x is greater than y, otherwise 0.0.
!x 1.0 if x = 0, otherwise 0.0.
-x (0.0 - x).
+x (0.0 + x) (effectively does nothing).
x ^ y x raised to the power of y.
x * y x multiplied by y.
x / y x divided by y.
x % y x modulo y, (remainder of (x divided by y)).
x <= y 1.0 if x is less than or equal to y, otherwise 0.0.
x >= y 1.0 if x is greater than or equal to y, otherwise 0.0.
x = y 1.0 if x is exactly equal to y, otherwise 0.0.
x == y 1.0 if x is exactly equal to y, otherwise 0.0 (identical to above).
x <> y 1.0 if x is not equal to y, otherwise 0.0.
x != y 1.0 if x is not equal to y, otherwise 0.0 (identical to above).
x & y 1.0 if both x and y are not 0.0, otherwise 0.0.
x && y 1.0 if both x and y are not 0.0, otherwise 0.0 (identical to above).
x | y 1.0 if either x or y (or both) are not 0.0, otherwise 0.0.
x || y 1.0 if either x or y (or both) are not 0.0, otherwise 0.0 (identical to above).





Examples


Example 1

To make a numeric control equal to the Y value of a motion path, add an expression to the desired target control and connect the Path to Point In 1. Enter the formula

p1y

into the Number Out field.

Example 2

To make the result of the Expressions Number Out be the largest of Number In 1 and Number In 2, multiplied by the cosine of Number In 3, plus the X coordinate of Point In 1, enter the formula

max(n1, n2) * cos(n3) + p1x

into the Number Out field.

Example 3

Add a Background tool set to solid black and a Hotspot tool. Set the Hotspot size to 0.08 and set the Strength to maximum. Modify the Hotspot center with an Expression. Change the current frame to 0.

Set n1 to 0.0 and add a Bezier spline. At frame 29, set the value of n1 to 1.0. Select both points and loop the spline using the spline editor. Now enter the following equations into the Point Out tab of the expression.

X-Axis Expression

n1

Y-Axis Expression

0.5 + sin(time*50) / 4

Render out a preview and have a look at the results. (Try this one with motion blur.)





Tips for Expression (edit)

  • Expressions in the Custom tool and Expression modifier can now get number/point inputs at different times, using n1_at(time), etc. and p1x_at(time)/p1y_at(time), etc.



The contents of this page are copyright by eyeon Software.