1\subsection{Texture and Color} 2\subsubsection{Simple Texture Characteristics} 3 The surface textures applied to an object drastically alter its overall 4appearance, making textures and color one of the most important topics in 5this manual. As with many other renderers, textures can be declared and 6associated with a name so that they may be used over and over again in 7a scene definition with less typing. If a texture is only need once, or it 8is unique to a particular object in the scene, then it may be declared along 9with the object it is applied to, and does not need a name. 10 11 The simplest texture definition is a solid color with no image mapping 12or procedural texture mapping. A solid color texture is defined by the 13{\bf AMBIENT}, {\bf DIFFUSE}, {\bf SPECULAR}, {\bf OPACITY} and {\bf COLOR} 14parameters. The {\bf AMBIENT} parameter defines the ambient lighting 15coefficient to be used when shading the object. Similarly, the {\bf DIFFUSE} 16parameter is the relative contribution of the diffuse shading to the surface 17appearance. The {\bf SPECULAR} parameter is the contribution from perfectly 18reflected rays, as if on a mirrored surface. {\bf OPACITY} defines how 19transparent a surface is. An {\bf OPACITY} value of 0.0 renders the object 20completely invisible. An {\bf OPACITY} value of 1.0 makes the object 21completely solid, and non-transmissive. In general, the values for the 22ambient, diffuse, and specular parameters should add up to 1.0, if they don't 23then pixels may be over or underexposed quite easily. These parameters 24function in a manner similar to that of other ray tracers. The {\bf COLOR} 25parameter is an RGB triple with each value ranging from 0.0 to 1.0 inclusive. 26If the RGB values stray from 0.0 to 1.0, results are undefined. 27In the case of solid textures, a final parameter, {\bf TEXFUNC} is set to 28zero (integer). 29 30\subsubsection{Texture Declaration and Aliasing} 31 To define a simple texture for use on several objects in a scene, the 32{\bf TEXDEF} keyword is used. The {\bf TEXDEF} keyword is followed by 33a case sensitive texture name, which will subsequently be used while 34defining objects. If many objects in a scene use the same texture through 35texture definition, a significant amount of memory may be saved since only 36one copy of the texture is present in memory, and its shared by all 37of the objects. Here is an example of a solid texture definition: 38\begin{verbatim} 39 TEXDEF MyNewRedTexture 40 AMBIENT 0.1 DIFFUSE 0.9 SPECULAR 0.0 OPACITY 1.0 41 COLOR 1.0 0.0 0.0 TEXFUNC 0 42\end{verbatim} 43When this texture is used in an object definition, it is referenced only by 44name. Be careful not to use one of the other keywords as a defined texture, 45this will probably cause the parser to explode, as I don't check for use 46of keywords as texture names. 47 48 When a texture is declared within an object definition, it appears in 49an identical format to the {\bf TEXDEF} declaration, but the {\bf TEXTURE} 50keyword is used instead of {\bf TEXDEF}. If it is useful to have several 51names for the same texture (when you are too lazy to actually finish defining 52different variations of a wood texture for example, and just want to be 53approximately correct for example) aliases can be constructed using the 54{\bf TEXALIAS} keyword, along with the alias name, and the original name. 55An example of a texture alias is: 56\begin{verbatim} 57 TEXALIAS MyNewestRedTexture MyNewRedTexture 58\end{verbatim} 59This line would alias MyNewestRedTexture to be the same thing as the 60previously declared MyNewRedTexture. Note that the source texture must 61be declared before any aliases that use it. 62 63\subsubsection{Image Maps and Procedural Textures} 64 Image maps and procedural textures very useful in making realistic looking 65scenes. A good image map can do as much for the realism of a wooden table 66as any amount of sophisticated geometry or lighting. Image maps are made by 67wrapping an image on to an object in one of three ways, a spherical map, a 68cylindrical map, and a planar map. Procedural textures are used in a way 69similar to the image maps, but they are on the fly and do not use much memory 70compared to the image maps. The main disadvantage of the procedural maps 71is that they must be hard-coded into \RAY\ when it is compiled. 72 73 The syntax used for all texture maps is fairly simple to learn. The biggest 74problem with the way that the parser is written now is that the different 75mappings are selected by an integer, which is not very user friendly. I 76expect to rewrite this section of the parser sometime in the near future to 77alleviate this problem. When I rewrite the parser, I may also end up altering 78the parameters that are used to describe a texture map, and some of them may 79become optional rather than required. 80 81\begin{center} 82\begin{tabular}{|c|c|} 83\multicolumn{2}{c}{Texture Mapping Functions} \\ 84\hline 85{Value for TEXFUNC} & {Mapping and Texture Description}\\ 86\hline 87{0} & {No special texture, plain shading} \\ 88{1} & {3D checkerboard function, like a rubik's cube} \\ 89{2} & {Grit Texture, randomized surface color} \\ 90{3} & {3D marble texture, uses object's base color} \\ 91{4} & {3D wood texture, light and dark brown, not very good yet} \\ 92{5} & {3D gradient noise function (can't remember what it look like} \\ 93{6} & {Don't remember} \\ 94{7} & {Cylindrical Image Map, requires ppm filename} \\ 95{8} & {Spherical Image Map, requires ppm filename} \\ 96{9} & {Planar Image Map, requires ppm filename} \\ 97\hline 98\end{tabular} 99\end{center} 100 101Here's an example of a sphere, with a spherical image map applied to its 102surface: 103\begin{verbatim} 104SPHERE 105 CENTER 2.0 0.0 5.0 106 RAD 2.0 107 TEXTURE 108 AMBIENT 0.4 DIFFUSE 0.8 SPECULAR 0.0 OPACITY 1.0 109 COLOR 1.0 1.0 1.0 110 TEXFUNC 7 /cfs/johns/imaps/fire644.ppm 111 CENTER 2.0 0.0 5.0 112 ROTATE 0.0 0.0 0.0 113 SCALE 2.0 -2.0 1.0 114\end{verbatim} 115 116Basically, the image maps require the center, rotate and scale parameters so 117that you can position the image map on the object properly 118 119