Download 3Delight User`s Manual
Transcript
Chapter 6: The Shading Language 95 type random ( ) Returns a random float, color or point. Returned range is [0..1]. Can return uniform or varying values. Here is a trick to put a random color in each grid of micropolygons: uniform float red = random(); uniform float green = random(); uniform float blue = random(); Ci = color( red, green, blue ); 6.4.3 Geometry, Matrices and Colors float xcomp ( point Pt ) float ycomp ( point Pt ) float zcomp ( point Pt ) void setxcomp ( output point Pt; float x ) void setycomp ( output point Pt; float y ) void setzcomp ( output point Pt; float z ) Gets or sets the x, y, or z component of a point (or vector). float comp ( matrix M; float row, col ) Returns M[row,col]. void setcomp ( output matrix M; float row, col, x ) M[row,col] = x. float comp ( color c; float i ) void setcomp ( output color c, float i, x ) Returns or sets the “ith” component of the given color. point point point point point point ( string [fromspace,] tospace; point Pt ) ( [string fromspace;] matrix M; point Pt ) ( string [fromspace,] tospace; vector V ) ( [string fromspace;] matrix M; vector V ) ( string [fromspace,] tospace; normal N ) ( [string fromspace;] matrix M; normal N ) Transforms a point, vector or normal from a given space (fromspace) to another space (tospace). If the optional fromspace is not given, it is assumed to be the ‘current’ space. Refer to Table 6.3 for the complete list of valid space names. transform transform transform transform transform transform ( string [fromspace,] tospace; vector V ) ( [string fromspace;] matrix M; vector V ) ( string [fromspace,] tospace; normal Nr ) ( [string fromspace;] matrix M; normal Nr ) Same as transform() above but specifically selects a transform on normals or vectors (no polymorphism). note: One should use transform() instead since that shadeop will correctly select the appropriate transform depending on the parameter type. vector vector normal normal vtransform vtransform ntransform ntransform color ctransform ( string [fromspace,] tospace; color src_color ) Transforms color src color from color space fromspace to color space tospace. If the optional fromspace is not specified, it is assumed to be ‘rgb’. 3Delight recognizes the following color