Shake表达式
Apple Shake是非常强大的后期合成软件,在很多著名电影中都有应用,例如《金刚》等。Shake的表达式跟C语言很像,先贴个操作符、函数表格以供参考。ArithmeticOperators
*
Multiply
/
Divide
+
Plus
-
Subtract
RelationalOperators
<
Less than
>
Greater than
<=
Less than or equal to
>=
Greater than or equal to
==
Equal to
!=
Not equal to
LogicalOperators
&&
And
||
Or
!
Not
ConditionalExpression
expr1?expr2:expr3
If expr1 is true (non-zero),then to expr2, else do expr3
GlobalVariables
time
Current frame number
ImageVariables
Theseare variables carried by each node.
parameterName
Value of parameterNamefrom inside that node.
nodeName.parameterName
Value of parameterNamein nodeName from outside of that node.
parameterName@@time
Allowsyou to access a value at a different frame. For example:
Blur1.xPixel@@(time-3)looks at the value from 3 frames earlier.
bytes
The number of bytes in thatimage. This takes the input bit-depth when called from inside ofthe node, and the output bit-depth when called from outside of thenode.
width
Width of the image. Takesthe input width when called from inside of the node, and theoutput width when called from outside of the node.
height
Height of the image. Takesthe input height when called from inside of the node, and theoutput height when called from outside of the node.
_curImageName
Returnsthe name of the actual file being used for the current frame.Useful when plugged into a Text node:
{FileIn1._curImageName}
dod, dod, dod,dod
The variable for the Domainof Definition xMin, yMin, xMax, yMax, respectively.
In-NodeVariables
Theseare channel variables used in nodes such as ColorX, LayerX,Reorder, etc. Check the documentation for specific supportof any variable.
nr, ng, nb, na, nz
New red, green, blue, alpha,Z channel
r, g, b, a, z
Original red, green, blue,alpha, Z channels
l
Luminance channel forReorder
n
Null channel. Strips out thealpha in Reorder when used like this: rgbn
r2, g2, b2, a2, z2
Second image's channel forLayerX
MathFunctions
abs(x)
Integer absolute value.abs(-4) = 4. Be careful, as this will return an integer, not afloat. Use fabs for float.
biasedGain(value, gain,bias)
This gives aContrastLum-like curve that gives rolloff between twovalues.
cbrt(x)
Cubic root. cbrt(8) = 2
ceil(x)
Truncates to next integer.ceil(5.3) = 6
clamp(x, lo, hi)
Clamps x to betweenlo and hi
clamp(1.5,0,1) = 1
exp(x)
Natural exponent. exp(0) = 1
fabs(x)
Float absolute value.fabs(-4.1) = 4.1
floor(x)
Truncates to next lowestinteger. floor(5.8) = 5
fmod(x,y)
Float modulus. Returns theremainder in float.
fmod(11.45,3) = 2 , ie, (3x3+2.45 =11.45)
log(x)
Natural log. log(1) = 0
log10(x)
Returns base 10 log.log10(10) = 1
M_PI
A variable set to pi at 20decimal places
max(a,b)
Returns maximum between aand b
max(5,10) = 10
max3(a,b,c)
Returns maximum between a,b, and c.
max3(5,2,4) = 5
min(a,b)
Returns minumum between aand b.
min(5,10) = 10
min3(a,b,c)
Returns minumum between a,b, and c.
min3(5,2,4) = 2
a%b
Modulus. 27%20 = 7
pow(x,y)
Returns x to the y power.pow(2,4) = 16
round(x)
Rounds number off. Valuesbelow x.5 are rounded to x, values equal to or above x.5 arerounded to x+1. round(4.3) = 4
sqrt(x)
Square root. sqrt(9) = 3
NoiseFunctions
Theseare ideal for WarpXand ColorX.
noise(seed)
1 dimensional cubic splineinterpolation of noise
noise2d(seed,seed)
2d noise
noise3d(seed,seed,seed)
3d noise
noise4d(seed,seed,seed,seed)
4d noise
lnoise(seed)
1d linear interpolation ofnoise
lnoise2d(seed,seed)
2d noise
lnoise3d(seed,seed,seed)
3d noise
lnoise4d(seed,seed,seed,seed)
4d noise
fnoise(x,xScale)
1d fractal noise based onnoise()
fnoise2d(x,y,xScale,yScale)
fnoise3d(x, y, z, xScale,yScale, zScale)
turbulence(x, xScale)
A cheaper, rougher versionof fnoise().
turbulence2d(x, y, xScale,yScale )
Continuous 2d noise
turbulence3d(x, y, z,xScale, yScale, zScale)
Continuous 3d noise
rnd(seed)
Hash-based pseudo-randomnumbers. Non-hash based RNG (like rand() or drand48()) should notbe used in Shake because they can't be reproduced from one machineto another, and even on the same machine, repeated evaluations ofthe same node at the same time would produce different results.
rnd1d(seed, seed)
1d random value
rnd2d(seed,seed,seed)
2d random value
rnd3d(seed,seed,seed,seed)
3d random value
rnd4d(seed,seed,seed,seed,seed)
4d random value
TrigFunctions (in radians)
M_PI
A variable set to pi at 20decimal places.
acos(A)
Arc cosine in radians
asin(A)
Arc sine
atan(A)
Arc tangent
atan2(y,x)
Returns the radian verifyingsin(a) = y and cos(a) = x.
cos(A)
Cosine
sin(A)
Sin
TrigFunctions (in degrees)
http://tk.files.storage.msn.com/x1pwXtlE9yc32bJQFjNCpk99MaLU8U4GPIu6uYJoRBgJ6mMNNAcDkVPRpQofbb3jakJasIIif0OnfxOKAS1co1F55MNyCnLsETsUP8a1jwFuc0c513EyziQm_giCeYgWDsjADq7rgxyuNA
Hmmm, yummy trigonometry!Welcome back. For those of you who may have forgotten, here is ahelpful chart for some commonly used equations.
acosd(A)
arc cosine in degrees
asind(A)
arc sine in degrees
atand(A)
arc tangent in degrees
atan2d(y,x)
returns the angle verifyingsin(a) = y and cos(a) = x.
cosd(A)
cosine in degrees
distance(x1,y1,x2,y2)
calculates the distancebetween two points, (x1,y1) and (x2, y2)
sind(A)
sin in degrees
tand(A)
tangent in degrees
StringFunctions
stringf( "xyz",...)
Sinceyou basically can write books on this, here is an example.Otherwise, it is recommended to purchase a book on C. There arealso several examples under the Scriptsdocumentation. This example takes the scriptName parameterand uses the system function echo to print it:
extern "C" intsystem(const char*);
const char *z= stringf("echo%s",scriptName);
system(z);
printf( "xyz",...)
strlen("mystring")
Returns the length of thestring
strsub(
const char*string,
int offset,
int length
)
Extracts a string fromanother string.
CurveFunctions
Thecurve functions with implicit time (Linear,CSpline,etc.) all assume that time is the first argument, so the followingstatements are identical:
LinearV(time,0,1@1,20@20)
Linear(0,1@1,20@20)
Youcan, however, adjust the time value explictly with the V versionof each curve type. For more infomation on spline types, jump toAboutSplines.
Theseare the cycle type codes:
0= KeepValue
1 = KeepSlope
2 = RepeatValue
3 =MirrorValue
4 = OffsetValue
biasedGain(x,gain,bias)
Gives a smoothly rampedinterpolation between 0 and 1, similar to Shake's contrast curve.gain increase the contrast, and bias offsets the center.
Linear(cycle,
value@key1,
value@key2,
...)
Linear interpolation fromvalue at key1 to value at key2, etc.
LinearV(time_value, cycle,value@key1,
value@key2,
...)
Linear interpolation fromvalue at key1 to value at key2, etc.
CSpline(cycle,
value@key1,
value@key2,
...)
Cardinal-splineinterpolation, a.k.a. Catmull-Rom splines
CSplineV(time_value, cycle,value@key1,
value@key2,
...)
Cardinal-splineinterpolation, a.k.a. Catmull-Rom splines
JSpline(cycle,
value@key1,
value@key2,
...)
Jeffress-splineinterpolation
JSplineV(time_value, cycle,value@key1,
value@key2,
...)
Jeffress-splineinterpolation
NSpline(cycle,
value@key1,
value@key2,
...)
Natural-spline interpolation
NSplineV(time_value, cycle,value@key1, value@key2,...)
Natural-spline interpolation
Hermite(cycle,
@key1,
@key2,
...)
Hermite-spline interpolation
HermiteV(time_value,cycle,
@key1,
@key2,
...)
Hermite-spline
页:
[1]