This specifies a color whose red component is 1.0 or 100% of full intensity and the green component is 0.5 or 50% of full intensity. Although the blue, filter and transmit components are not explicitly specified, they exist and are set to their default values of 0. The component keywords may be given in any order and if any component is unspecified its value defaults to zero.
Where IDENTIFIER is the name of the identifier up to 40 characters long and COLOR_VECTOR or COLOR_KEYWORDS are any valid color specifications as described in the two previous sections of this document. Here are some examples...
As the LightGray example shows you do not need any color keywords when creating color expressions based on previously declared colors. The last example shows you may use a color identifier with the keyword style syntax. Make sure that the identifier comes first before any other component keywords.
Like floats and vectors, you may re-define colors throughout a scene but the need to do so is rare.
You may use the dot operator to extract a single component from a color. Suppose the identifier Shade was previously defined as a color. Then Shade.red is the float value of the red component of Shade . Similarly Shade.green , Shade.blue , Shade.filter and Shade.transmit extract the float value of the other color components.
When using filter transparency, the colors which come through are multiplied by the primary color components. For example if grey light such as rgb <0.9,0.9,0.9> passes through a filter such as rgbf <1.0,0.5,0.0,1.0> the result is rgb <0.9,0.45,0.0> with the red let through 100%, the green cut in half from 0.9 to 0.45 and the blue totally blocked. Often users mistakenly specify a clear object by
but this has implied red, green and blue values of zero. You've just specified a totally black filter so no light passes through. The correct way is either
or
In the 2nd example it doesn't matter what the rgb values are. All of the light passes through untouched.
Another pitfall is the use of color identifiers and expressions with color keywords. For example...
this substitutes whatever was the red component of My_Color with a red component of 0.5 however...
adds 0.5 to the red component of My_Color and even less obvious...
that cuts the red component in half as you would expect but it also multiplies the green, blue, filter and transmit components by zero! The part of the expression after the multiply operator evaluates to rgbft <0.5,0,0,0,0> as a full 5 component color.
The following example results in no change to My_Color .
This is because the identifier fully overwrites the previous value. When using identifiers with color keywords, the identifier should be first.
One final issue, some POV-Ray syntax allows full color specifications but only uses the rgb part. In these cases it is legal to use a float where a color is needed. For example:
The ambient keyword expects a color so the value 1 is promoted to <1,1,1,1,1> which is no problem. However
is legal but it may or may not be what you intended. The 0.4 is promoted to <0.4,0.4,0.4,0.4,0.> with the filter and transmit set to 0.4 as well. It is more likely you wanted...
in which case a 3 component vector is expected. Therefore the 0.4 is promoted to <0.4,0.4,0.4,0.0,0.0> with default zero for filter and transmit.
"Here" "There" "myfile.gif" "textures.inc"
Where IDENTIFIER is the name of the identifier up to 40 characters long and STRING is a string literal, string identifier or function which returns a string value. Here are some examples...
As the last example shows, you can re-declare a string identifier and may use previously declared values in that re-declaration.
The built-in float identifier pi is obviously useful in math expressions involving circles.
The built-in float identifiers on , off , yes , no , true and false are designed for use as boolean constants.
The built-in vector identifiers x , y and z provide much greater readability for your scene files when used in vector expressions. For example....
An expression like 5*x evaluates to 5 <1,0,0> or <5,0,0>.
Similarly u and v may be used in 2D vectors. When using 4D vectors you should use x , y , z , and t and POV-Ray will promote x , y and z to 4D when used where 4D is required.
Other INI options and switches may be used to animate scenes by automatically looping through the rendering of frames using various values for clock . By default, the clock value is 0 for the initial frame and 1 for the final frame. All other frames are interpolated between these values. For example if your object is supposed to rotate one full turn over the course of the animation you could specify rotate 360*clock*y . Then as clock runs from 0 to 1, the object rotates about the y-axis from 0 to 360 degrees.
Although the value of clock will change from frame-to-frame, it will never change throughout the parsing of a scene.
See "Animation Options" for more details.
The INI option or switch only affects the initial setting. Unlike other built-in identifiers, you may change the value of version throughout a scene file. You do not use #declare to change it though. The #version language directive is used to change modes. Such changes may occur several times within scene files.
Together with the built-in version identifier the #version directive allows you to save and restore the previous values of this compatibility setting. For example suppose mystuff.inc is in version 1 format. At the top of the file you could put:
Function calls consist of a keyword which specifies the name of the function followed by a parameter list enclosed in parentheses. Parameters are separated by commas. For example:
Functions evaluate to values that are floats, vectors or strings and may be used in expressions or statements anywhere that literals or identifiers of that type may be used.
abs(A): Absolute value of A. If A is negative, returns -A otherwise returns A.
vaxis_rotate(A,B,F): Rotate A about B by F. Given the x,y,z coordinates of a point in space designated by the vector A, rotate that point about an arbitrary axis defined by the vector B. Rotate it through an angle specified in degrees by the float value F. The result is a vector containing the new x,y,z coordinates of the point.
Section 7.1.7.2
Built-in Identifier 'clock'
Section 7.1.7.3
Built-in Identifier 'version'
Section 7.1.8
Functions
Section 7.1.8.1
Float Functions
acos(A): Arc-cosine of A. Returns the angle, measured in radians, whose cosine is A.
asin(A): Arc-sine of A. Returns the angle, measured in radians, whose sine is A.
atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in radians, whose tangent is (A/B). Returns appropriate value even if Bis zero. Use atan2(A,1) to compute usual atan(A) function.
ceil(A): Ceiling of A. Returns the smallest integer greater than A. Rounds up to the next higher integer.
cos(A): Cosine of A. Returns the cosine of the angle A, where A is measured in radians.
degrees(A): Convert radians to degrees. Returns the angle measured in degrees whose value in radians is A. Formula is degrees=A/pi*180.0.
div(A,B): Integer division. The integer part of (A/B).
exp(A): Exponential of A. Returns the value of e raised to the A power where e is the non-repeating value approximately equal to 2.71828182846 the base of natural logarithms.
floor(A): Floor of A. Returns the largest integer less than A. Rounds down to the next lower integer.
int(A): Integer part of A. Returns the truncated integer part of A. Rounds towards zero.
log(A): Natural logarithm of A. Returns the natural logarithm base e of the value A where e is the non-repeating value approximately equal to 2.71828182846.
max(A,B): Maximum of A and B. Returns A if A larger than B. Otherwise returns B.
min(A,B): Minimum of A and B. Returns A if A smaller than B. Otherwise returns B.
mod(A,B): Value of A modulo A. Returns the remainder after the integer division of A/B. Formula is mod=((A/B)-int(A/B))*B.
pow(A,B): Exponentiation. Returns the value of A raised to the power B.
radians(A): Convert degrees to radians. Returns the angle measured in radians whose value in degrees is A. Formula is radians=A*pi/180.0.
rand(A): Returns the next pseudo-random number from the stream specified by the positive integer A. You must call seed() to initialize a random stream before calling rand(). The numbers are uniformly distributed, and have values between 0.0 and 1.0, inclusively. The numbers generated by separate streams are independent random variables.
seed(A): Initializes a new pseudo-random stream with the initial seed value A. The number corresponding to this random stream is returned. Any number of pseudo-random streams may be used as shown in the example below:
#declare R1 = seed(0)
#declare R2 = seed(12345)
#sphere { <rand(R1), rand(R1), rand(R1)>, rand(R2) }
Section 7.1.8.2
Vector Functions
vcross(A,B): Cross product of A and B. Returns a vector that is the vector cross product of the two vectors. The resulting vector is perpendicular to the two original vectors and its length is proportional to the angle between them. See the animated demo scene VECT2.POV for an illustration.
vdot(A,B): Dot product of A and B. Returns a float value that is the dot product (sometimes called scaler product of A with B. Formula is vdot=A.x*B.x + A.y*B.y + A.z*B.z. See the animated demo scene VECT2.POV for an illustration.
vlength(A): Length of A. Returns a float value that is the length of vector A. Can be used to compute the distance between two points. Dist=vlength(B-A). Formula is vlength=sqrt(vdot(A,A)).
vnormalize(A): Normalize vector A. Returns a unit length vector that is the same direction as A. Formula is vnormalize=A/vlength(A).
vrotate(A,B): Rotate A about origin by B. Given the x,y,z coordinates of a point in space designated by the vector A, rotate that point about the origin by an amount specified by the vector B. Rotate it about the x-axis by an angle specified in degrees by the float value B.x. Similarly B.y and B.z specify the amount to rotate in degrees about the y-axis and z-axis. The result is a vector containing the new x,y,z coordinates of the point.
Table Of Contents