Value > Basic Data Values > Color Values |
All the places that colors turn up in MAXScript (such as, wireColor, light color, and others) are represented by instances of the Color class. You can also use Point3 values to specify colors.
Predefined MAXScript globals.
r,g,b and optional alpha are float values, typically in the range of 0 to 255.
Interprets x as r, y as g, z as b. Alpha is assumed opaque (255).
<color>.red or .r: Float <color>.green or .g: Float <color>.blue or .b: Float <color>.alpha or .a: Float
<color> == <color> <color> != <color> <color> + <color_or_number> <color> - <color_or_number> <color> * <color_or_number> <color> / <color_or_number>
Channel-by-channel mathematical operations. Numbers operate on R,G,B and A channels equally.
IMPORTANT NOTES ON COLOR OPERATIONS: |
The addition and subtraction operations are performed on the R, G, B and A channels equally: |
The high Alpha value is caused by the fact that MAXScript does not print the Alpha value if it is 255, but internally the value of the variable aColor is (color 1 1 1 255). Thus, adding the Alpha channels of 255 to 255 produces an Alpha of 512, analogous to the R,G, and B channels. |
While the Color Values allow floating point components, when originally implemented in3ds Max 2, it was assumed that they would be used mainly for 8 bit per channel RGBA values because MAXScript did not support floating point color bitmaps at that point in time. An internal conversion is performed when printing color values or converting other values to color. Thus, multiplication of two color values leads to seemingly strange results: |
The reason for these results when multiplying color values is that the actual component values are float values normally in the range of 0 to 1. The scaling from 0-1 to 0-255 is an operation that MAXScript performs to the underlying color value when the value is printed or converted to some other value type. A gray value of 128 multiplied by a gray value of 128 is not really 128*128 = 16384, which is a blown out white, but (128/255.0 * 128/255.0)*255 or (.501961*.501961)*255 which is the DARKER shade of gray (color 64.251 64.251 64.251) So, when (color 1 1 1 255) is converted to components in the range from 0 to 1, it also results in RGB components of (1.0/255*1.0/255)*255=0.00392157, while the Alpha of 255 turns into 1.0 and then back into 255. |
Thus, the Color Value is not well suited for High Dynamic Range Image calculations with floating point color components. For that type of operations, MAXScript provides a Point4 value that can be used to represent floating point colors without implicit conversion from/to the 0-255 range. This value was introduced in 3ds Max 6 to support the color parameters of mental ray shaders. |
Creates a new copy of the color value.
FOR EXAMPLE: |
The new value contains a copy of the input color value, and is independent of the input color value. |
Returns a random color between the given colors. The alpha component of the result will always be 255.
Composites color1 over color2 through color1 's alpha. This function is equivalent to:
noise3 <color> noise4 <color> <phase_float> turbulence <color> <frequency_float> fractalNoise <color> <H_float> <lacunarity_float> <octaves_float>
See Point3 Values for a description of the noise functions.
The following script shows the use of various literals, constructors, properties, operators, and methods of the Color class.