0% found this document useful (0 votes)
14 views

Formula

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Formula

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

See main Table of Contents

Formula

See main Table of Contents Carrara Studio 581


See main Table of Contents

Using Formulas in
Carrara Studio

Carrara Studio 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:

• How to use a formula item


• The Formula Editor interface
• Supported functions, operators,
constants, and parameters
• The valid input and output variable for
each formula item.

See main Table of Contents Carrara Studio 582


See main Table of Contents

Creating Formula 2 Choose Formula from the pop-up. The

Items formula controls appear in the Transition


Options dialog.

The method for creating a formula item To create Formula shaders:


depends on the item you want to create. You
can create the following items using 1 Display the Shader Tree Editor by
formulas: double-clicking a shader in the Browser.

• Primitive objects
2 Select the shader tree component where
you want to use a formula.
• Deformers
3 Select Pattern Functions> Formula
• Tweeners from the list. The formula controls
appear on the selected branch of the
• Shaders
shader tree.
• Gels
To create Formula gels:
• Backgrounds and Backdrops
1 Select a light other than Distant light.
To create a Formula primitive:
2 Display the Properties tray: Effects
1 Drag the Formula Primitive icon into the tab: Gel panel.
scene, or choose Insert menu > 3 Choose Formula from the list. The
Formula. formula controls appear in the dialog.
2 Double-click the object to display the
formula controls, or click the Model To create Formula backgrounds or
room button. backdrops:

To create a Formula deformer: 1 In the Properties tray, select the scene,


then click the Effects tab.
1 Click the Properties tray: Modifiers 2 Select Background or Backdrop.
tab.
3 From the (Background or Backdrop)
2 Choose Formula from the pop-up. The pop-up, choose Formula. The formula
formula controls appear in the Modifiers controls appear in the Effects section in
section. the Background or Backdrop controls.
To create Formula tweeners:

1 Double-click the gap between key events


on the time track. Studio opens the
Transition Options dialog.

See main Table of Contents Carrara Studio 583


See main Table of Contents

Formula Controls Carrara Studio opens the Formula Editor.


• You can type into the window to build
The formula controls include a readout of the your formula. Be careful, the editor is
formula itself, sliders for adjusting case-sensitive.
parameters, a Parse button, and a More • Each statement must end with a
button. semicolon.
2 When you are finished in the Formula
Editor, click OK.
3 In the formula controls, click the Parse
button.
Parsing compiles the formula to run.
4 If appropriate to this formula, you can
adjust the parameter sliders.

Formula Operators
Use the Formula Editor controls to enter formulas
and set variables. sin(x) sine of x
For a few items, the controls also include a cos(x) cosine of x
preview of sorts. (For the tweener formula,
the preview is a graph.) 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


The formula editor for tweeners displays a preview
of the formula as a graph. tanh(x) hyperbolic tangent of x

sqrt(x) square root of x


Editing Formulas
pow(x,y) x raised to the power of y
To create or edit a formula:
exp(x) exponential
1 In the formula controls, click More.

See main Table of Contents Carrara Studio 584


See main Table of Contents

log(x) logarithm Constants:


log10(x) base-10 logarithm PI
floor(x) floor of x (The largest integer that is E
less than or equal to x)

ceil(x) ceiling of x (The smallest integer that Animatable Input


is greater than or equal to x) Parameters:
abs(x) absolute value of x
p1, p2, p3, p4
mod(x,y)x modulus y
These parameters can be set between –1 and
+1.
Comparison Operators:
< less than
Variables
<= less than or equal to The variables valid for a particular item
depend on its type. Refer to the section below
== equal to that describes the variables for the formula
item you are creating. To define a variable,
!= not equal to just use it. Its initial value will be 0.
> greater than

>= greater than or equal to


Formula Shader
&& logical “and” Output Variables
|| logical “or” value (output is a grey level) or red, green,
blue (output is a color)

Conditional: The expected output is between 0 (black) and


1 (white or color maximum intensity).
variable=((comparison)?(value if
TRUE):(value if FALSE)) You can use any of these output variables,
however, the program can’t use ‘value’ and
For example: any of ‘red’, ‘green’, ‘blue’ simultaneously. If
the shader is used in a color based channel,
a=((b>1)?1:b); then color output variables will have priority
(meaning if ‘value’ and ‘red’ are defined,
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.

See main Table of Contents Carrara Studio 585


See main Table of Contents

then only ‘red’ will be used). The opposite


applies when using the shader in a value
Formula Tweener
based channel, like Shininess. (If ‘value’ is
defined, ‘value’ will be used).
Output Variables
value
Input Variables
u and v These are parametric mapping
Input Variables
coordinates. t, tmin, tmaxt is time. One t unit is 1/1800th
x, y and z These are the local space of a second. t is between tmin and tmax.
coordinates of the point being shaded.
Formula Backdrop
nx, ny and nz These are the normal local
coordinates (normalized vector). Output Variables
X, Y and Z These are the global space
value or red, green, blue
coordinates of the point being shaded.
Note: See the Formula Shader.
NX, NY and NZ These are the normal global
coordinates (normalized vector).
Input Variables
Formula Deformer u,v(u,v) defines a point on the backdrop. The
range is between 0 and 1. (0,0) is the lower
The Formula Deformer iterates on all the left corner, (1,1) the upper right.
points of an object, deforming them one by
one.
Formula Background
Output Variables: Output Variables
dx, dy and dz The local coordinates of the
value or red, green, blue
deformed point. The range is –1 to +1 (0 is
the center.) Refer to “Formula Shader” on page 585.

Input Variables: Input Variables


x, y, z The local coordinates of the point to x,y,z (x,y,z) is the global coordinates of the
be deformed. direction vector, from the camera eye to the
background. The vector (x,y,z) is normalized
and each coordinate ranges between –1 and
+1.

See main Table of Contents Carrara Studio 586


See main Table of Contents

Formula Gel
Output Variables
value or red, green, blue

Refer to “Formula Shader” on page 585.

Input Variables
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.

Formula Primitive
(Object)
Output Variables
x,y,z local coordinates of the point defined
by (u,v).

Input Variables
u,v The parametric space coordinates. The
range is between 0 and 1.

See main Table of Contents Carrara Studio 587

You might also like