Carrara allows you to create mathematical formulas that in turn create custom features. Using formulas, you can define your own objects, deformers, tweeners, shaders, gels, backgrounds, and backdrops. The interface for creating formulas is common for all items. The valid input and output variables differ for each item you create. Formula editing becomes technical quickly. Higher math or programming experience is recommended.
This chapter describes the following:
The method for creating a formula item depends on the item you want to create. You can create the following items using formulas:
To create a Formula primitive:
To create a Formula deformer:
To create Formula tweeners:
To create Formula shaders:
To create Formula gels:
To create Formula backgrounds or backdrops:
The formula controls include a readout of the formula itself, sliders for adjusting parameters, a Parse button, and a More button.
Use the Formula Editor controls to enter formulas and set variables.
For a few items, the controls also include a preview of sorts. (For the tweener formula, the preview is a graph.)
The formula editor for tweeners displays a preview of the formula as a graph.
To create or edit a formula:
sin(x) | sine of x |
cos(x) | cosine of x |
tan(x) | tangent of x |
asin(x) | arcsine of x |
acos(x) | arccosine of x |
atan(x) | arctangent of x |
atan2(y,x) | arctangent of y/x |
sinh(x) | hyperbolic sine of x |
cosh(x) | hyperbolic cosine of x |
tanh(x) | hyperbolic tangent of x |
sqrt(x) | square root of x |
pow(x,y) | x raised to the power of y |
exp(x) | exponential |
log(x) | logarithm |
log10(x) | base-10 logarithm |
floor(x) | floor of x (The largest integer that is less than or equal to x) |
ceil(x) | ceiling of x (The smallest integer that is greater than or equal to x) |
abs(x) | absolute value of x |
mod(x,y) | x modulus y |
< | less than |
⇐ | less than or equal to |
== | equal to |
!= | not equal to |
> | greater than |
>= | greater than or equal to |
&& | logical “and” |
|| | logical “or” |
variable=1)
For example:
a=((b>1)?1:b);
The expression (b>1) is the comparison. If it's true, the formula returns a=1. If it's false, the formula returns a=b.
PI
E
p1, p2, p3, p4
These parameters can be set between -1 and +1.
The variables valid for a particular item depend on its type. Refer to the section below that describes the variables for the formula item you are creating. To define a variable, just use it. Its initial value will be 0.
value (output is a grey level) or red, green, blue (output is a color)
The expected output is between 0 (black) and 1 (white or color maximum intensity).
You can use any of these output variables, however, the program can't use `value' and any of `red', `green', and `blue' simultaneously. If the shader is used in a color based channel, then color output variables will have priority (meaning if `value' and `red' are defined, then only `red' will be used). The opposite applies when using the shader in a value based channel, like Shininess. (If `value' is defined, `value' will be used).
u and v | These are parametric mapping coordinates. |
x, y and z | These are the local space coordinates of the point being shaded. |
nx, ny and nz | These are the normal local coordinates (normalized vector). |
X, Y and Z | These are the global space coordinates of the point being shaded. |
NX, NY and NZ | These are the normal global coordinates (normalized vector). |
The Formula Deformer iterates on all the points of an object, deforming them one by one.
dx, dy and dz The local coordinates of the deformed point. The range is -1 to +1 (0 is the center.)
x, y, z The local coordinates of the point to be deformed.
value
t, tmin, tmax t is time. One t unit is 1/1800th of a second. t is between tmin and tmax.
value or red, green, blue
Note: See the Formula Shader.
u,v (u,v) defines a point on the backdrop. The range is between 0 and 1. (0,0) is the lower left corner, (1,1) the upper right.
value or red, green, blue
Refer to Formula Shader.
x,y,z (x,y,z) is the global coordinates of the direction vector, from the camera eye to the background. The vector (x,y,z) is normalized and each coordinate ranges between -1 and +1.
value or red, green, blue
Refer to Formula Shader.
u,v (u,v) defines a point on the backdrop. The range is between 0 and 1. (0,0) is the lower left corner, (1,1) the upper right.
x,y,z local coordinates of the point defined by (u,v).
u,v The parametric space coordinates. The range is between 0 and 1.