<html>
<head>
<title>Scene</title>
</head>
<body bgcolor="#ffffff">
<tab id=0 indent=0>
<tab id=1 indent=4>
<tab id=2 indent=8>
<tab id=3 indent=12>
<tab id=4 indent=16>
<tab id=5 indent=20>
<tab id=6 indent=24>
<tab id=7 indent=28>
<tab id=8 indent=32>
<tab id=9 indent=36>
<tab id=10 indent=40>
<tab id=11 indent=44>
<tab id=12 indent=48>
<tab id=13 indent=52>
<tab id=14 indent=56>
<tab id=15 indent=60>
<tab id=16 indent=64>
<tab id=17 indent=68>
<tab id=18 indent=72>
<tab id=19 indent=76>
<p><a name=cB><h1>Scene Description</h1></a> 

<p><a name=iDBI></a><a name=iDBJ></a><a name=iDCA></a><a name=iDCB></a>The scene to render is read from an ascii or binary file called the <tt><b>.mi</b></tt> file. It contains a list of commands and frames. Commands are instructions to mental ray that set options such as verbosity or external shaders to be linked; frames describe scenes to render. Each frame describes one image; files containing multiple frames are used to describe multi-frame animations. Each frame contains a <i>view</i>, describing the camera and other global setups, the materials, lights, and textures, and the geometric objects. 

<p>The sequence runs like this: 

<p>
<p><pre>    <i>list of commands</i> 
    <tt><b>frame</b></tt> <i>number<sub>int</sub></i> [<i>time</i>]
        <i>list of lights, textures, and materials</i> 
        <i>view</i> 
        <i>list of lights, textures, materials, and objects</i> 
    <tt><b>end frame</b></tt> 
    <i>list of commands</i> 
    <tt><b>frame</b></tt> <i>number<sub>int</sub></i> 
        ...             # frame body 
    <tt><b>end frame</b></tt> 
    ...                 # more commands and frames 
 
</pre><p> 

<p><a name=iDCC></a>The frames describe the scene to be rendered. Everything between a <tt><b> </b></tt> frame and <tt><b>end frame</b></tt> pair describes a complete scene that is interpreted, rendered, and written to output files before starting with the next frame. Frames are largely independent of one another (one notable exception is the optional field rendering mode, which combines pairs of frames into a single image by interlacing scanlines). The frame contains: 

<p> 
<ul>

<li>  <a name=iDCD></a> (see <a href=scene.html#iDHH>light</a>) Lights that illuminate certain objects. Lights are referenced in materials only, they are not applied directly to objects. All lights name a shading function; there are predefined shaders for points, spots, and directional lights, optionally in combination with various types of area light sources. 

<p>
</ul>

<ul>

<li>  <a name=iDCE></a> (see <a href=scene.html#iDJA>texture</a>) Textures to apply 2D or 3D color, bump<a name=iDCF></a>, <a name=iDCG></a><u>transparency</u>, displacement, and other maps to objects. Textures are also referenced by <a name=iDCH></a><a href=scene.html#iDJG>material</a>s only; their interpretation is up to the <a name=iDCI></a><a href=scene.html#iDJH>material shader</a>.  Textures may appear verbatim in the file, or may be read from a texture file, or may be fully procedural, or a combination of textures. 

<p>
</ul>

<ul>

<li>  Materials describe the color, <a name=iDCJ></a><u>transparency</u>, <a name=iDDA></a><u>reflection</u>, and other properties of objects, in addition to listing lights<a name=iDDB></a> and textures.  Materials name several shading functions for material properties, <a name=iDDC></a><u>shadow</u> casting, <a name=iDDD></a><u>environment map</u>ping, volume shading<a name=iDDE></a> (see <a href=shaders.html#iHGA>volume shader</a>) , <a name=iDDF></a><u>displacement map</u>ping, as well as a number of property flags. 

<p>
</ul>

<ul>

<li>  The <a name=iDDG></a><a href=scene.html#iEDG>view</a> is a description of the <a name=iDDH></a><u>camera</u> along with other global rendering parameters, such as image <a name=iDDI></a><u>resolution</u> and output file names. 

<p>
</ul>
Finally, <a name=iDDJ></a><a href=scene.html#iFGF>object</a>s describe the actual geometry. Objects reference materials to determine the visual appearance of the surface. Various types of geometry descriptions are supported, such as <a name=iDEA></a><u>polygon</u>al objects and <a name=iDEB></a><u>free-form surface</u>s. 

<p>The ``#'' character introduces <a name=iDEC></a><u>comment</u>s, unless quoted. Comments extend to the end of the line. Whitespace is ignored. 

<p>This section discusses the parts that make up an <tt><b>.mi</b></tt> file. In this section, a less formal syntax is used for the syntax description: a bar ``|'' denotes alternatives, items enclosed in tall square brackets ``[ ]'' are optional, and the ellipsis ``...'' denotes omission. Literal text is set in <tt><b>teletype</b></tt>, while variable metasymbols are set in <i>italics</i>. All other punctuation characters are literals. Strings are quoted with double quotes; this includes all names. Names, such as material, light, or object names, need not be quoted, but it is highly recommended to avoid conflicts with reserved words (future versions may reserve more words than described in this manual), and to allow non-alphabetic characters. Without quotes, only lowercase and uppercase letters, underscores, and digits may be used; a digit may not be the first character of an unquoted name. No such restrictions apply to quoted names. 

<p>Integers<a name=iDED></a> are distinguished from <a name=iDEE></a><u>floating point</u> numbers by appending the suffix <b>int</b>, as in <i>degree<sub>int</sub></i>. Integers are an optional ``+'' or ``-'' sign followed by a sequence of digits ``0'' through ``9''.  Floating-point numbers follow the same rules, but always contain either a decimal point ``.'' with at least one digit before and at least one digit after the decimal point. Strings<a name=iDEF></a> can be distinguished from numbers because the grammar always forces them to be enclosed in double quotes. 

<p><p><a name=cC><h2>Commands</h2></a> 

<p>
<p><pre>    <tt><b>$include "</b></tt><i>filename</i><tt><b>"</b></tt> 
 
</pre><p> 

<p><a name=iDEG></a>This command is different from all others in that it can appear at any place in the file, not just between frames. The $ must appear in column 1 of the line. The named file is included (pasted into) the <tt><b> </b></tt> .mi file, replacing the $include statement. Includes can be nested. The main purpose is to include declarations (see below), but materials, light sources, even objects can be included.  The included file is read on the client host only; the included file need not exist on any remote hosts that help render the scene. 

<p>
<p><pre>    <tt><b>version "</b></tt><i>string</i><tt><b>"</b></tt> 
 
</pre><p> 

<p>This commands informs mental ray that this .mi file requires mental ray version <i>string</i> or later. Version strings consist of four numbers separated with dots, such as <tt><b>"1.2.3.4"</b></tt>. The string can underspecify the version, as in <tt><b>"1.9"</b></tt>. Missing numbers are implicitly assumed to be 0 so <tt><b>"1.9"</b></tt> becomes <tt><b>"1.9.0.0"</b></tt>. Each number, beginning with the first, is checked in turn.  If the number in the <i>string</i> is greater than the version number built into mental ray, an error message is printed and mental ray aborts; otherwise the next number is considered. If all given numbers pass the test, mental ray continues. This command is recommended for declaration files included with <tt><b>$include</b></tt>. 

<p>
<p><pre>    <tt><b>verbose on|off</b></tt> 
 
</pre><p> 

<p>This command turns <a name=iDEH></a><u>verbose message</u>s on or off. Default is off. If verbose mode is enabled, objects found in the frame are listed as they are parsed, progress reports are printed during rendering, and time and memory <a name=iDEI></a><u>statistics</u> are printed after rendering has finished. Verbose messages can slow down mental ray significantly while parsing. The verbose command can be overridden with the <tt><b>-verbose</b></tt> command-line option. 

<p>
<p><pre>    <tt><b>echo "</b></tt><i>message</i><tt><b>"</b></tt> 
 
</pre><p> 

<p>The named <i>message</i>, which must be enclosed in double quotes, is printed to stdout. The <a name=iDEJ></a><u>echo</u> command is executed during parsing. Parsing is done frame-by-frame, rendering takes place when a frame ends. This means that echo statements between frames are not printed until the preceding frame has been rendered. Echoing is independent of the verbose mode. 

<p>
<p><pre>    <tt><b>system "</b></tt><i>shell_command</i><tt><b>"</b></tt> 
 
</pre><p> 

<p>This command starts a <a name=iDFA></a><u>shell</u>, which executes the named <i> </i> shell_command.  The shell command must be enclosed in double quotes. mental ray waits until the shell command has completed; this can be defeated by ending the command with a shell <tt><b>&</b></tt> command. The system command, like echo, is executed while parsing, not during rendering. Its main purpose is writing finished pictures to an output device. 

<p>
<p><pre>    <tt><b>memory</b></tt> <i>maxmem<sub>int</sub></i> 
 
</pre><p> 

<p>The memory command limits the maximum <a name=iDFB></a><u>resident set</u> of mental ray to <i>maxmem</i> megabytes, on systems that support resource limits. Only the maximum amount of physical RAM used is limited, not the maximum amount of virtual memory. This means that swapping to disk may be increased if RAM runs out. This can be used to partition available <a name=iDFC></a><u>physical RAM</u> among multiple processes, because it prevents mental ray from grabbing all available space. This command can be overridden with the <tt><b>-memory</b></tt> command-line option. See also the discussion of the <tt><b>subdivision_memory</b></tt> statement in the <tt><b>view</b></tt> statement, below. 

<p>
<p><pre>    <tt><b>code "</b></tt><i>filename</i><tt><b>"</b></tt> 
 
</pre><p> 

<p><a name=iDFD></a><a name=iDFE></a> (see <a href=shaders.html#iIFB>shader parameters</a>) <a name=iDFF></a> (see <a href=shaders.html#iHHE>state variables</a>) <a name=iDFG></a>The named <i>filename</i> is interpreted as a C source file, ending with the extension ``.c'', is compiled and linked into mental ray. From this point on, the shaders it defines are available in mental ray as shading functions. For example, if the source defines a C function <i> </i> myshader, with the usual three parameters <i>result</i>, <i>state</i>, and <i>paras</i> (see the section on writing shaders for details), the name <i>myshader</i> may be used in materials, lights, textures and so on as the quoted shader name, just like one of the built-in shaders like <i>soft_material</i> or <i>mi_wave_light</i>. The command-line option <tt><b>-code</b></tt> provides an alternative way of compiling and linking C source. Multiple code commands are possible. Note that every shading function must also be declared; see below. 

<p>
<p><pre>    <tt><b>link "</b></tt><i>filename</i><tt><b>"</b></tt> 
 
</pre><p> 

<p><a name=iDFH></a>Like the code command, the link command attaches external shaders to mental ray, which can then be used as shading functions. While the code command accepts ``.c'' files as <i>filename</i>, the link command expects either object files ending in ``.o'', or dynamic shared object (DSO) files ending in ``.so''. Object files are linked, while DSOs are just attached without any preprocessing. <a name=iDFI></a>DSOs are the fastest way of attaching an external shader, and require no compilers or development options, which are sometimes sold separately by system vendors.For system and development software  requirements, see the Release and Installation Notes. However, not all systems support DSOs. The <tt><b>-link</b></tt> command-line option provides an alternative way of linking objects files and DSOs. Any number of files can be linked. Note that every shading function must also be declared; see below. If Dynamical Shared Objects (DSOs) are to be linked on SGI machines, the <tt><b>LD_LIBRARY_PATH</b></tt> environment variable must include the path of the .so file to be linked; see ``Dynamic Linking of Shaders''. 

<p>
<p><pre>    <tt><b>declare "</b></tt><i>shader_name</i><tt><b>" (</b></tt><i>parameters</i><tt><b>)</b></tt> 
 
</pre><p> 

<p><a name=iDFJ></a><a name=iDGA></a> (see <a href=shaders.html#iIFG>shader declaration</a>) <a name=iDGB></a> (see <a href=shaders.html#iIFB>shader parameters</a>) All shading functions linked with a code or link statement, and all shading functions built into mental ray must be declared.  Shading functions accept a pointer to an arbitrary parameter structure as their third argument, and mental ray must know the structure declaration in order to put together the parameter block according to C structure layout conventions. Usually, declarations are included from a separate file using the <tt><b>$include</b></tt> statement. For a detailed description of the <i>parameters</i> part of the declaration, see the section on writing shaders. 

<p><br> 
<p><pre>     <tt><b>scalar|color texture "</b></tt><i> </i> texture_name<tt><b>" [</b></tt><i>width<sub>int</sub></i> <i>height<sub>int</sub></i> [<i>depth<sub>int</sub></i>] <tt><b>]</b></tt> <i>bytes</i> ... 
     <tt><b>vector texture "</b></tt><i> </i> texture_name<tt><b>"</b></tt> <tt><b>[</b></tt><i>width<sub>int</sub></i> <i>height<sub>int</sub></i> <tt><b>]</b></tt> <i>bytes</i> ... 
     [ <tt><b>local</b></tt> ] <tt><b>scalar|color|vector texture "</b></tt><i> </i> texture_name<tt><b>" "</b></tt><i>filename</i><tt><b>"</b></tt> 
     <tt><b>scalar|color|vector texture "</b></tt><i> </i> texture_name<tt><b>" "</b></tt><i>shader_name</i><tt><b>" </b></tt> (<i>parameters</i><tt><b>)</b></tt> 
 
</pre><p> <br> 

<p><a name=iDGC></a> (see <a href=scene.html#iDJA>texture</a>) <a name=iDGD></a> (see <a href=scene.html#iDJB>procedural texture</a>) <a name=iDGE></a> (see <a href=scene.html#iDJC>image texture</a>) <a name=iDGF></a> (see <a href=scene.html#iDJD>texture shader</a>) Textures are normally defined in a frame, as part of the <i> </i> frame_description list. These textures are available for the duration of the frame, and are unloaded from memory when the frame has completed. Textures can also be defined outside frames. These textures are called <a name=iDGG></a><u>global textures</u>, and can be used in all following frames. Global textures are never unloaded from memory until mental ray terminates. For a description of the syntax, see the in the Textures subsection below. 

<p>
<p><pre>    <tt><b>frame</b></tt> <i>frame_number<sub>int</sub></i> [<i>frame</i>]
        <i>frame_description</i> 
    <tt><b>end frame</b></tt> 
 
</pre><p> 

<p>This command defines a <a name=iDGH></a><a href=scene.html#iDCC>frame</a>, and renders it when the <tt><b> </b></tt> end frame is reached during parsing. During rendering, only shaders that were compiled and/or linked and declared are available for this frame. The next section describes the <i>frame_description</i> in detail. The <i>frame_number</i> is a sequential number, usually starting with 1, that distinguishes multiple frames in the file. Among other things, it is used for <a name=iDGI></a><a href=scene.html#iFEJ>field rendering</a>. The optional <i>time</i> gives the frame number as a time in seconds; it relates to the frame number and the desired frame rate. It is available to shaders for animations. The default is 0.0. 

<p><br>
 <p><a name=cD><h2>Frames</h2></a> 

<p><a name=iDGJ></a>A frame describes a single scene. It contains a <a name=iDHA></a><u>camera</u> (called a <i><a name=iDHB></a><a href=scene.html#iEDG>view</i></a></b></tt>), <a name=iDHC></a><a href=scene.html#iDJG>material</a>s, <a name=iDHD></a><a href=scene.html#iDJA>texture</a>s, <a name=iDHE></a><a href=scene.html#iDHH>light</a>s, and <a name=iDHF></a><a href=scene.html#iFGF>object</a>s. The frame consists of a list of items of these five types in any order, with the restriction that the view must precede the first object, and that materials, lights, and textures must be defined before they are being used. Lights will normally precede the view because some types of <a name=iDHG></a><a href=shaders.html#iHGG>lens shader</a>s (such as the lens flare shader) need a list of lights as shader parameters. Since textures and lights are usually referenced in materials, they must precede the materials they are used in. In all these cases, an item is ``used'' when it is named as a parameter of a shader. 

<p>A detailed description of the five types that make up a frame follows. The view is listed last. It has a large list of parameters, most of them optional. The other types are mostly simple, all the complexity and cross-references are hidden in the shading functions. A material, for example, does not list the lights that illuminate it directly; the list appears as a shader parameter. For a description of shading functions, see the section on writing shaders, or the chapter on built-in shaders. 

<p><p><a name=cE><h3>Lights</h3></a> 

<p>
<p><pre>    <tt><b>light</b></tt> <tt><b>"</b></tt><i>light_name</i><tt><b>"</b></tt> 
        <tt><b>"</b></tt><i>shader</i><tt><b>" (</b></tt><i>parameters</i><tt><b>)</b></tt> 
        [ <i>area_light_primitive</i> ] 
        [ <tt><b>origin</b></tt> <i>x y z</i> ] 
        [ <tt><b>direction</b></tt> <i>dx dy dz</i> ] 
    <tt><b>end light</b></tt> 
 
</pre><p> 

<p><a name=iDHH></a><a name=iDHI></a>This statement defines a light source. All light sources need a light shader, such as the built-in <a name=iDHJ></a><a href=builtin.html#iBCJG><i>soft_light</i></a> or <a name=iDIA></a><a href=builtin.html#iBEBI><i> mi_wave_light</i></a> shaders, or a shader linked with a <tt><b>code</b></tt> or <tt><b> </b></tt> link command (see above). <tt><b>"</b></tt><i>shader</i><tt><b>"</b></tt> above stands for the quoted name of the shader. Like any other shader, a parameter list<a name=iDIB></a> (see <a href=shaders.html#iIFB>shader parameters</a>)  enclosed in parentheses must be given. The parameters depend on the particular shader; they include the light color, attenuations, and spot light directions.  The declaration of the shader determines which parameters are available in the <i> </i> parameters list; see the section ``User Parameter Declarations'' for details on shader parameters.  mental ray distinguishes two kinds of light shaders: <a name=iDIC></a><a href=shaders.html#iJGA>point light</a>s, giving off light in all directions; directional (infinite) lights, whose light rays are all parallel in a particular direction. Point lights must define an <i>origin</i> but no <i>direction</i>, while <a name=iDID></a><u>directional light</u>s must define a <i> </i> direction but no <i>origin</i>.  Spot lights<a name=iDIE></a> (see <a href=shaders.html#iJGD>spot light</a>)  are a variation of point lights whose shader imposes a directional <a name=iDIF></a><u>attenuation</u>. That directional attenuation is purely a function of the shader, it is independent of the <tt><b>direction</b></tt> keyword in the light definition. 

<p>After the definition, the light source can be referenced in parameter lists of shading functions (such as a <a name=iDIG></a><a href=scene.html#iDJG>material</a> shading function) by listing <i>light_name</i>. Material shading functions usually have an array parameter accepting one or more <i>light_name</i>s, which they loop over to accumulate the contribution by each light. Lights are one of the standard data types that are available for shading function parameters. The <i>light_name</i> may be quoted to avoid clashes with predefined words, and to allow non-alphabetic characters. 

<p>Any point or spot light may be turned into an <a name=iDIH></a><u>area light</u> source by naming an <i>area_light_primitive</i>. Area light sources generate <a name=iDII></a><a href=builtin.html#iBDDJ>soft shadow</a>s because shadow-casting objects may partially obscure the light source. Three types of area light primitives are supported: 

<p>
<p><pre>    <tt><b>rectangle</b></tt> <i>x<sub>0</sub></i> <i>y<sub>0</sub></i> <i>z<sub>0</sub></i> <i>x<sub>1</sub></i> <i>y<sub>1</sub></i> <i>z<sub>1</sub></i> [ <i>u_samples</i> <i>v_samples</i> ] 
    <tt><b>disc</b></tt> <i>x</i> <i>y</i> <i>z</i> <i>radius</i> [ <i>u_samples</i> <i>v_samples</i> ] 
    <tt><b>sphere</b></tt> <i>radius</i> [ <i>u_samples</i> <i>v_samples</i> ] 
 
</pre><p> 

<p>All three area light types are centered at the <i>origin</i> position in the light definition. A rectangular area light is specified by two vectors from the center to two edges; a disc area light is specified by its normal vector and a radius, and a sphere area light is specified only by its radius. Note that the orientation of the rectangle or the disc are independent of the <i>direction</i> and any directional attenuation the shader applies. 

<p>The <i>u_samples</i> and <i>v_samples</i> parameters subdivide the area light source primitive. For discs and spheres, <i>u_samples</i> subdivides the radius and <i>v_samples</i> subdivides the angle. When sampling the area light source,<a name=iDIJ></a> mental ray samples one point in each subdivision at a location precisely determined by the sample parameters and a predefined lighting distribution, and then combines the results.  The default is 3 for each sample parameter, so an area light source without explicitly given <i>samples</i> parameters is sampled 9 times. 

<p><br>
 <p><a name=cF><h3>Textures</h3></a> 

<p>
<p><pre>    <tt><b>scalar texture "</b></tt><i>texture_name</i><tt><b>" [</b></tt><i>width<sub>int</sub></i> <i>height<sub>int</sub></i> [<i>depth<sub>int</sub></i>] <tt><b>]</b></tt> <i>bytes</i> ... 
    [ <tt><b>local</b></tt> ] <tt><b>scalar texture "</b></tt><i>texture_name</i><tt><b>" "</b></tt><i>filename</i><tt><b>"</b></tt> 
    <tt><b>scalar texture "</b></tt><i>texture_name</i><tt><b>" "</b></tt><i>shader_name</i><tt><b>" </b></tt> (<i>parameters</i><tt><b>)</b></tt> 
 
</pre><p> 
<p><pre>    <tt><b>color texture "</b></tt><i>texture_name</i><tt><b>" [</b></tt><i>width<sub>int</sub></i> <i>height<sub>int</sub></i> [<i>depth<sub>int</sub></i>] <tt><b>]</b></tt> <i>bytes</i> ... 
    [ <tt><b>local</b></tt> ] <tt><b>color texture "</b></tt><i>texture_name</i><tt><b>" "</b></tt><i>filename</i><tt><b>"</b></tt> 
    <tt><b>color texture "</b></tt><i>texture_name</i><tt><b>" "</b></tt><i>shader_name</i><tt><b>" </b></tt> (<i>parameters</i><tt><b>)</b></tt> 
 
</pre><p> 
<p><pre>    <tt><b>vector texture "</b></tt><i>texture_name</i><tt><b>"</b></tt> <tt><b>[</b></tt><i>width<sub>int</sub></i> <i>height<sub>int</sub></i> <tt><b>]</b></tt> <i>bytes</i> ... 
    [ <tt><b>local</b></tt> ] <tt><b>vector texture "</b></tt><i>texture_name</i><tt><b>" "</b></tt><i>filename</i><tt><b>"</b></tt> 
    <tt><b>vector texture "</b></tt><i>texture_name</i><tt><b>" "</b></tt><i>shader_name</i><tt><b>" </b></tt> (<i>parameters</i><tt><b>)</b></tt> 
 
</pre><p> 

<p><a name=iDJA></a><a name=iDJB></a><a name=iDJC></a><a name=iDJD></a>Textures are lookup functions. They come in two flavors: lookups of two-dimensional texture or picture files or literal bytes, and procedural lookups. File textures require a file name parameter or a byte list; procedural textures require a shading function parameter. There are three types of texture functions: textures computing scalars, colors, and vectors. Which one is chosen depends on what the texture is used for. Textures are used as parameters to other shaders, typically material shaders. A material shader could, for example, use a color texture to wrap a picture around an object, or a scalar texture as a transparency or displacement map, or a vector texture as a bump map. The actual use of the texture result is entirely up to the shader that uses the texture. The built-in SOFTIMAGE material shader <a name=iDJE></a><a href=builtin.html#iBCDC><i> soft_material</i></a>, for example, uses arrays of color textures only. 

<p>All of the above syntax variations define a texture <i>texture_name</i>. The <i>texture_name</i> should be quoted to avoid reserved words or to allow non-alphabetic characters. This is the name that the texture will later be referenced as. The name is valid only in the current frame, and the texture will be unloaded from memory at the end of the frame. To avoid this, the texture definition can be made global<a name=iDJF></a> by moving it outside the frame definition, which makes it a command like <tt><b>declare</b></tt> or <tt><b>$include</b></tt>. The statement syntax does not change; see above. This is useful for textures that do not change during an animation. 

<p>Non-procedural textures can be defined by specifying the <i>width</i> and <i>height</i> of the texture and an optional <i>depth</i> (bytes per component, 1 or 2, default is 1), followed by a list of <i>width * height *depth</i> hexadecimal two-digit bytes, most significant digit first if <i>depth</i> is 2, in RGBA order for colors and UV order for vectors. Note that the brackets around the sizes are literally part of the <tt><b>.mi</b></tt> file, while the skinny brackets around <i>depth</i> denote that the depth is optional and are not part of the <tt><b>.mi</b></tt> file. 

<p>Non-procedural textures can also be defined by naming a texture or picture file; for a list of allowed file formats, see the section on Available Output File Formats. In this case, the sizes (width, height, and depth) are read from the file. If the <tt><b>local</b></tt> keyword is not present, the file is read once on the master host and then transmitted over the network to all slave hosts that participate in the rendering. With the <tt><b>local</b></tt> keyword, only the file name is transmitted to the slave hosts; this requires the <tt><b>filename</b></tt> to be valid on all slave hosts but reduces network transfer times drastically if many texture files or very large texture files are used. Maximum speed improvements are achieved if <tt><b>filename</b></tt> is not on an NFS-mounted file system (NFS stands for Network File System, distinguishable by the <tt><b>nfs</b></tt> type in the output from the Unix <tt><b>df</b></tt> command). 

<p>Procedural textures are defined by naming a shading function with parameters; the shading function can either be one of the built-in functions or an external function from a <tt><b>code</b></tt> or <tt><b>link</b></tt> command. 

<p>When the material shader (or any other shader) evaluates a texture by calling a texture evaluation function provided by mental ray, mental ray either looks up non-procedural shaders by looking up the texture in the range <i>[0, 1]</i> in each dimension, or it calls the named shader in the procedural case. The shader is free to interpret the point for which it evaluates the texture in any way it wants, two-dimensional or three-dimensional. 

<p><br>
 <p><a name=cG><h3>Materials</h3></a> 

<p>
<p><pre>    <tt><b>material</b></tt> <tt><b>"</b></tt><i>material_name</i><tt><b>"</b></tt> [<tt><b>nocontour</b></tt>] [<tt><b>opaque</b></tt>] 
        <tt><b>"</b></tt><i>material_shader_name</i><tt><b>"</b></tt> (<i>parameters</i>) 
        [<tt><b>displace "</b></tt><i>displace_shader_name</i><tt><b>"</b></tt> (<i>parameters</i>)] 
        [<tt><b>shadow "</b></tt><i>shadow_shader_name</i><tt><b>"</b></tt> (<i>parameters</i>)] 
        [<tt><b>volume "</b></tt><i>volume_shader_name</i><tt><b>"</b></tt> (<i>parameters</i>)] 
        [<tt><b>environment "</b></tt><i>environment_shader_name</i><tt><b>"</b></tt> (<i>parameters</i>)] 
    <tt><b>end material</b></tt> 
 
</pre><p> 

<p><a name=iDJG></a><a name=iDJH></a>Materials determine the look of geometric objects. They are referenced by <i>material_name</i> in the geometry definition in <tt><b>object</b></tt> statements (see below). Lights and textures cannot be referenced by objects; they are referenced by the material which uses them to compute the color of a point on the object's surface. All built-in material shaders accept <a name=iDJI></a><a href=scene.html#iDJA>texture</a>s and lights<a name=iDJJ></a> as shader parameters. 

<p>When a <a name=iEAA></a><a href=shaders.html#iHJH>primary ray</a> cast from the camera hits an object, that object's material shader is called. The material shader then calculates a color (and certain other optional values such as <a name=iEAB></a><u>label</u>s, <a name=iEAC></a><u>depth</u>s, and <a name=iEAD></a><u>normal</u>s that can be written to special output files). This color may then be modified by the optional <a name=iEAE></a><a href=shaders.html#iHGA>volume shader</a> if present. The resulting color is stored in the output <a name=iEAF></a><a href=shaders.html#iBAGD>frame buffer</a>, which is written to the output picture file when rendering has finished. In order to calculate the color, the material shader may cast secondary<a name=iEAG></a> (see <a href=shaders.html#iHJI>secondary ray</a>)  <a name=iEAH></a><u>reflection</u>, <a name=iEAI></a><u>refraction</u>, or <a name=iEAJ></a><u>transparency</u> rays, which in turn may hit objects and cause other (or the same; multiple objects may share a material) material shaders to be called. The material shader bases the decision whether to cast secondary rays on its parameters, which are part of the scene description and may contain parameters such as the material's <a name=iEBA></a><u>diffuse color</u> or its <a name=iEBB></a><u>reflectivity</u> and <a name=iEBC></a><u>transparency</u>, light sources, and <a name=iEBD></a><a href=scene.html#iDJA>texture</a>s. The parameters depend entirely on the material shader. In this sense, material shaders are ``primary'' shaders that get help from ``secondary'' texture and light shaders. 

<p><a name=iEBE></a> (see <a href=shaders.html#iIFB>shader parameters</a>) The <i>material_name</i> should be quoted to avoid reserved names or if it contains non-alphabetic characters. The <tt><b>nocontour</b></tt> flag, if present, prevents the <a name=iEBF></a><u>contour</u> line rendering option from drawing a contour line at any point on an object that uses this material. The <tt><b>opaque</b></tt> flag, if present, informs mental ray that this material is not transparent (i.e., it does not cast <a name=iEBG></a><u>refraction</u> or <a name=iEBH></a><u>transparency</u> rays and always sets its alpha<a name=iEBI></a> result value to 1); this allows certain optimizations that improve rendering speed. The material shader and its parameters are mandatory. 

<p>There are several optional functions that can be listed in a material. The <a name=iEBJ></a><u>displacement shader</u> is a function returning a scalar that displaces the object's surface in the direction of its normal. In version 1.9, displacements are possible only on <a name=iECA></a><u>free-form surface</u>s, which must have a sufficiently fine approximation to reveal  details of the displacement map. Polygons and <a name=iECB></a><u>polygon</u> meshes can be displaced in version 2.0 of mental ray.

<p>The <a name=iECC></a><u>shadow shader</u> is called when a <a name=iECD></a><u>shadow</u> calculation is done, and the <a name=iECE></a><a href=shaders.html#iJFH>shadow ray</a> from the light source towards the point in shadow intersects with this material. The shadow shader then changes the color of the ray, which is initially the (possibly attenuated) color of the light to another color, typically a darker or tinted color if the material is colored glass. It returns black if the material is totally opaque, which is also the default if no shadow shader is present.  Shadow shaders are usually reduced versions of the material shaders; they evaluate transparencies and colors but cast no secondary rays. 

<p>It is possible to use the material shader as a shadow shader; material shaders can find out whether they are called as material or shadow shaders and do only the required subset in the latter case. The built-in <a name=iECF></a><a href=builtin.html#iBCDC><i>soft_material</i></a> shader is written this way. This is done by naming the material shader after the <tt><b>shadow</b></tt> keyword, and giving no parameters (i.e., giving <tt><b>()</b></tt>). mental ray will notice the absence of parameters and pass the material parameters instead. If the shadow shader has no parameters of its own, it is not defined whether it receives a pointer to the material shader parameters, or a pointer to a copy of the material shader parameters. 

<p>A <a name=iECG></a><a href=shaders.html#iHGA>volume shader</a> affects rays traveling inside an object. They are conceptually similar to <a name=iECH></a><a href=shaders.html#iJCI>fog</a> or <a name=iECI></a><a href=shaders.html#iJCJ>atmosphere</a> shaders. When a ray (either from the eye or from a light source) hits this material, the shadow shader, if present, is called to change the color returned by the ray based on the distance the ray has traveled, and atmospheric or material parameters. A volume shader can also be named in the <tt><b> </b></tt> view<a name=iECJ></a> (see <a href=scene.html#iEDG>view</a>)  (see below); that shader is used for rays traveling outside<a name=iEDA></a> objects. It is the material shader's responsibility to determine inside and outside of objects. 

<p>Finally, the <a name=iEDB></a><a href=shaders.html#iHGE>environment shader</a> is called when a <a name=iEDC></a><u>reflection</u> or <a name=iEDD></a><u>refraction</u> ray cast by the material shader leaves the scene entirely without striking another object. There is a built-in environment shader <a name=iEDE></a><a href=builtin.html#iBDBB><i>soft_env_sphere</i></a>, for example, that maps a texture on a sphere with an infinite radius surrounding the scene. (This is another example for an application of a texture; a texture name must be used as a parameter for the <tt><b>soft_env_sphere</b></tt> shader for this to work.) The <tt><b>view</b></tt> statement also offers an environment shader; that shader is used when the ray leaves the scene without ever striking any object (or exceeding the <a name=iEDF></a><u>trace depth</u>). 

<p><br>
 <p><a name=cH><h3>The View</h3></a> 

<p>
<p><pre>    <tt><b>view</b></tt> 
        <i>outputs</i> 
        <i>viewdefs</i> 
    <tt><b>end view</b></tt> 
 
</pre><p> 

<p>A <a name=iEDG></a><u>view</u> describes the <a name=iEDH></a><u>output file</u>s to be created, the <a name=iEDI></a><u>camera</u>, and <a name=iEDJ></a><u>option</u>s.  More than one output file can be created, and <a name=iEEA></a><a href=shaders.html#iHGH>output shader</a>s such as filters can be listed that operate on the final rendered image, before it is written to a picture file. <i> </i> outputs is one or more output statements. There are two kinds of <a name=iEEB></a><u>output statement</u>s: 

<p>
<p><pre>    <tt><b>output</b></tt> [<tt><b>"</b></tt><i>datatype</i><tt><b>"</b></tt>] <tt><b>"</b></tt><i>filetype</i><tt><b>"</b></tt> <tt><b>"</b></tt><i>filename</i><tt><b>"</b></tt> 
    <tt><b>output</b></tt> <tt><b>"</b></tt><i>datatype</i><tt><b>"</b></tt> <tt><b>"</b></tt><i>shader_name</i><tt><b>" (</b></tt><i>parameters</i><tt><b>)</b></tt> 
 
</pre><p> 

<p>The first kind writes a picture to a file named <i>filename</i>, using <a name=iEEC></a><u>file format</u> <i>filetype</i>. Normally, file formats imply a data type, but the defaults can be overridden by naming an explicit <i> </i> datatype.  For example, the file type <tt><b>"pic"</b></tt>, which stands for a SOFTIMAGE picture file, implies the data type <tt><b>"RGBA"</b></tt>, but if the data type is explicitly set to <tt><b>"contour"</b></tt>, <a name=iEED></a><u>contour</u>s instead of colored pixels will be written to the <tt><b>pic</b></tt> file. For a list of data types and file types, see the ``Output Shaders'' chapter in the ``Functionality'' section. 

<p>The second kind of output statement calls an <a name=iEEE></a><a href=shaders.html#iHGH>output shader</a>, such as a filter, that may operate on all available frame buffers. Here, the <i>datatype</i> may be a comma-separated list of types if the shader requires multiple frame buffers. For example, a shader that filters the RGBA image with a filter whose size depends on the distance of objects needs both the RGBA buffer and the depth buffer, and would have a data type <tt><b>"rgba,z"</b></tt>. mental ray creates all types of frame buffers requested by at least one output statement of either kind. 

<p>There is a variety of <i>viewdefs</i> that can be listed in the <a name=iEEF></a><a href=scene.html#iEDG>view</a>.  Some of them define the <a name=iEEG></a><u>camera</u>, others add <a name=iEEH></a><a href=shaders.html#iJCJ>atmosphere</a>s or set <a name=iEEI></a><u>option</u>s.  Most of them can be overridden by specifying an appropriate command-line option; see the section Command Line Syntax. The following <i>viewdefs</i> are supported: 

<p> 

<p>
<dl>

<dt><tt><b>focal</b></tt> <i>distance</i>|<tt><b>infinity</b></tt>
<dd>    The <a name=iEEJ></a><u>focal distance</u> is set to <i>distance</i>. The focal distance is the distance from the camera to the <a name=iEFA></a><u>viewing plane</u>. The viewing plane is the plane in front of the camera that the rendered scene is projected onto; its edges correspond to the edges of the rendered image. However, objects between the camera and the viewing plane will still be rendered; a common approach is to place the viewing plane in the middle of the interesting objects in the scene and then set the <a name=iEFB></a><u>aperture</u> such that it is a bit larger than the horizontal extent of the objects in <a name=iEFC></a><u>camera space</u>. If <tt><b>infinity</b></tt> is used in place of the <i>distance</i>, an orthographic view<a name=iEFD></a> is rendered. An orthographic view turns off <a name=iEFE></a><u>perspective</u>, all camera rays are parallel. View-dependent surface tessellation is not possible in orthogonal mode. 

<p>
</dl>

<dl>

<dt><tt><b>aperture</b></tt> <i>aperture</i>
<dd>    The <a name=iEFF></a><u>aperture</u> is the width of the <a name=iEFG></a><a href=scene.html#iEFA>viewing plane</a>. The height of the viewing plane is <i>aperture</i> divided by <i>aspect</i>. Together with the <tt><b>focal</b></tt> and <tt><b>aspect</b></tt> <i>viewdefs</i>, <tt><b>aperture</b></tt> defines the lens of the camera. 

<p>
</dl>

<dl>

<dt><tt><b>aspect</b></tt> <i>aspect</i>
<dd>    This is the <a name=iEFH></a><u>aspect ratio</u> of the camera. The default is 1.33. In <a name=iEFI></a><u>camera space</u>, <i>aperture</i> is the width of the <a name=iEFJ></a><a href=scene.html#iEFA>viewing plane</a> and <i>aperture</i> divided by <i>aspect</i> is the height. The viewing plane is divided into pixels as specified by the <tt><b>resolution</b></tt> <i> </i> viewdef, so the aspect will result in nonsquare pixels if it is not equal to the X <a name=iEGA></a><u>resolution</u> divided by the Y resolution.  For example, to render a PAL image at a resolution of <i> 720 *576</i> pixels, at an image ratio of 3:4 as defined by the PAL standard, pixels are slightly wider than tall, by a factor of <i>576 /720 *4  /3 = 1.0667</i>. If this number is specified as <i>aspect</i>, objects will appear undistorted on a PAL video display (but not on a computer display with <a name=iEGB></a><u>square pixels</u>). 

<p>
</dl>

<dl>

<dt><tt><b>resolution</b></tt> <i>x<sub>int</sub></i> <i>y<sub>int</sub></i>
<dd>    <a name=iEGC></a>Specifies the width and height of the output image in pixels. 

<p>
</dl>

<dl>

<dt><tt><b>window</b></tt> <i>x_low<sub>int</sub></i> <i>y_low<sub>int</sub></i> 
<dd>  <i>x_high<sub>int</sub></i> <i>y_high<sub>int</sub></i>  <a name=iEGD></a>Only the sub-rectangle of the image specified by the four bounds will be rendered. All pixels that fall outside the rectangle will be left black. 

<p>
</dl>

<dl>

<dt><tt><b>transform</b></tt> <i>a<sub>00</sub></i> <i>a<sub>10</sub></i> <i>a<sub>20</sub></i> 
<dd>  <i>a<sub>30</sub></i> <i>a<sub>01</sub></i> ... <i>a<sub>33</sub></i>   The transformation matrix transforms <a name=iEGE></a><u>camera space</u> to <a name=iEGF></a><u>world space</u>. It is made available to shaders that need world coordinates. It does not actually transform any geometry, the <a name=iEGG></a><u>camera</u> is always assumed to sit at the coordinate origin and look down the negative Z axis regardless of the transformation matrix. Rendering will not be affected if the transformation matrix is missing, but shaders can no longer do calculations in world coordinates; mental ray defaults to an identity matrix in this case. 

<p>
</dl>

<dl>

<dt><tt><b>min samples</b></tt> <i>min<sub>int</sub></i>
<dd>    This parameter determines the minimum <a name=iEGH></a><u>sample rate</u>. Each pixel is sampled at least <i> 2<sup>2 *min</sup></i> times. If <i>min</i> is 0, each pixel is sampled at least once. Positive values increase the minimum sample rate; negative numbers reduce the sample rate to less than one initial sample per pixel (<a name=iEGI></a><u>infrasampling</u>). <i>min</i> must be at least -2, which means that at least one sample per <i>4 *4</i> pixels is taken. -2 is the default.  If <i>min</i> is chosen too small, small features may be lost if all samples happen to miss it (if it is found just once in any pixel of a task, mental ray will analyze the feature and render it correctly). If a <tt><b>filter</b></tt> view statement is used to set a filter other than <tt><b>box 1 1</b></tt>, <tt><b>min samples</b></tt> must be set to <i>-1</i> or greater. If depth, normal, or label frame buffers<a name=iEGJ></a><a name=iEHA></a><a name=iEHB></a> are used by an appropriate <a name=iEHC></a><u>output statement</u>, the <tt><b>min samples</b></tt> parameter should be set to 0 or greater to avoid gaps.<a name=iEHD></a> 

<p>
</dl>

<dl>

<dt><tt><b>max samples</b></tt> <i>max<sub>int</sub></i>
<dd>    This parameter sets the maximum <a name=iEHE></a><u>sample rate</u>. If neighboring samples find a difference in <a name=iEHF></a><a href=scene.html#iEIH>contrast</a> exceeding the contrast limit, the area that contains the contrast is subdivided until the maximum recursion depth specified by <i>max</i> is reached. At most <i> 2<sup>2 * </sup> max</i> samples per pixel are taken. mental ray will also automatically analyze features once detected in one pixel, which permits choosing a very low minimum number of samples (such as -2) because if an feature is missed in one pixel, it might be found later and traced back into the earlier pixel.  If a <tt><b>filter</b></tt> view statement is used to set a filter other than <tt><b>box 1 1</b></tt>, <tt><b>max samples</b></tt> must be set to <i>1</i> or greater.<a name=iEHG></a> 

<p>
</dl>

<dl>

<dt><tt><b>recursive on|off</b></tt>
<dd>    This flag controls the recursive <a name=iEHH></a><u>sampling</u> method that takes image samples at pixel corners, and recursively subdivides pixels into subpixels where contrasts exceeding the contrast threshold are detected. Recursive sampling uses the <tt><b>min samples</b></tt> and <tt><b>max samples</b></tt> parameters. It is enabled by default unless <a name=iEHI></a><u>contour</u> rendering or <a name=iEHJ></a><u>motion blur</u>ring is enabled. If it is disabled, the sampling method is chosen based on the <tt><b>adaptive</b></tt> parameter; see below.<a name=iEIA></a> 

<p>
</dl>

<dl>

<dt><tt><b>samples</b></tt> <i>samples<sub>int</sub></i>
<dd>    The <tt><b>samples</b></tt> parameter exists for backwards compatibility only. It sets the maximum number of samples to <i>samples<sup>2</sup></i> for the non-recursive supersampling algorithm, which is currently used only when <a name=iEIB></a><u>contour</u> rendering or <a name=iEIC></a><u>motion blur</u>ring is enabled. This parameter may be removed from later versions of mental ray.<a name=iEID></a> 

<p>
</dl>

<dl>

<dt><tt><b>adaptive on|off</b></tt>
<dd>    The adaptive flag, like the <tt><b>samples</b></tt> parameter, is obsolete. If <a name=iEIE></a><u>contour</u> rendering or <a name=iEIF></a><u>motion blur</u>ring is enabled, or if there is a <tt><b>recursive off</b></tt> statement, an algorithm that uses <tt><b>samples</b></tt> and <tt><b>adaptive</b></tt> is used. If <tt><b>adaptive</b></tt> is <tt><b>off</b></tt>, the number of samples is always <i>samples<sup>2</sup></i>; if it is <tt><b>on</b></tt>, the number of samples is either 1 or <i>samples<sup>2</sup></i>. The <tt><b>min samples</b></tt> and <tt><b>max </b></tt> samples offer a more flexible way of controlling the number of samples.<a name=iEIG></a> 

<p>
</dl>

<dl>

<dt><tt><b>contrast</b></tt> <i>r g b</i> [ <i>a</i> ]
<dd>    The <a name=iEIH></a><u>contrast</u> controls supersampling. If neighboring samples differ by more than the color <i>r, g, b, a</i>, supersampling is done as specified by the sampling parameters<a name=iEII></a> (see above). Default for <i>a</i> is the average of <i>r</i>, <i>g</i>, and <i>b</i>. The <a name=iEIJ></a><u>recursive supersampling</u> algorithm controlled by <tt><b>min </b></tt> samples and <tt><b>max samples</b></tt> modifies the contrast based on the recursion level: at sample level 0, the contrast is used directly; at sample level 1, the contrast is doubled (effectively requiring a higher contrast to force another subdivision), and so on. Negative levels divide the contrast, i.e. use a fraction <i> 1 /2</i>, <i> 1 /4</i>, and so on. In general, the contrast is multiplied by <i> 2<sup>level</sup></i> at the supersampling level <i>level</i>, which is bounded by <tt><b>min samples</b></tt> and <tt><b>max samples</b></tt>.<a name=iEJA></a> 

<p>
</dl>

<dl>

<dt><tt><b>time contrast</b></tt> <i>r g b</i> [ <i>a</i> ]
<dd>    The <a name=iEJB></a><u>time contrast</u> controls temporal supersampling for motion blurred scenes. It works similar to the spatial contrast parameter explained above: If neighboring samples in time differ by more than the color <i>r, g, b, a</i>, supersampling is done.  Default for <i> </i> a is the average of <i>r</i>, <i>g</i>, and <i>b</i>. Using values for <tt><b>time contrast</b></tt> that are higher than <tt><b>contrast</b></tt> can speed up motion blur rendering at the price of more grainy images without degrading the quality of spatial antialiasing.<a name=iEJC></a> 

<p>
</dl>

<dl>

<dt><tt><b>filter box|triangle|gauss</b></tt> <i>width</i> [<i>height</i>]
<dd>    The <a name=iEJD></a><u>filter</u> parameter specifies how multiple samples in recursive sampling mode are to be combined. The filter defaults to a box filter of width and height 1. The box filter can be replaced with a triangle filter or a gaussian filter centered on the pixel. The filter size in pixel units can also be specified; if no height is given the width is used. Larger filter sizes result in softer images. Typical values are 1.0 for box filters, 2.0 for triangle filters, and 3.0 for gaussian filters. The box filter sums all samples in the filter area with an equal weight The triangle filter functions has the shape of a pyramid centered on the pixel. The gauss filter weights the samples using a gauss curve which is cut off at an ellipse centered on the pixel; it has a spherical shape. Large sizes and filters other than box may reduce rendering speed. The filter sizes should not be smaller than 1.0. In order to use filters, the <tt><b>min samples</b></tt> parameter must be set to -1 or greater, and <tt><b>max samples</b></tt> must be set to <tt><b>1</b></tt> or greater, or a warning will be printed and the <tt><b>filter</b></tt> statement is ignored. Note that the sample defaults do not satisfy these conditions. The filter shapes of the three filters are: 

<p>
</dl>
<br>   <img src="filter_box.fig.ps.gif" alt="filter_box.fig.ps.gif">
 <img src="filter_triangle.fig.ps.gif" alt="filter_triangle.fig.ps.gif">
 <img src="filter_gauss.fig.ps.gif" alt="filter_gauss.fig.ps.gif">
 <br> 

<p>
<dl>

<dt><tt><b>jitter</b></tt> <i>jitter</i>
<dd>    The <a name=iEJE></a><u>jitter</u>ing factor introduces systematic variations into sample locations. Without jittering, samples are taken at the corners of pixels or subpixels. Jittering displaces the samples by an amount calculated by lighting analysis, limited to <i>jitter</i> pixels. This is used to reduce artifacts. Jittering is turned off by default, or by specifying a <i>jitter</i> of <tt><b>0.0</b></tt>. Jittering works best in ray tracing mode. 

<p>
</dl>

<dl>

<dt><tt><b>shutter</b></tt> <i>shutter</i>
<dd>    This statement specifies the <a name=iEJF></a><u>shutter</u> open time. A <i>shutter</i> value of 0.0 turns motion blurring off, values greater than 0.0 turn motion blurring on. The <i>shutter</i> value scales the motion vectors attached to object vertices; if <i>shutter</i> is 1.0, each vertex moves the distance given by its motion vector, and is blurred in the image over this distance. Values less than 1.0 reduce this path. 

<p>
</dl>

<dl>

<dt><tt><b>trace depth</b></tt> <i>reflect<sub>int</sub></i> [<i>refract<sub>int</sub></i> 
<dd>  [<i>sum<sub>int</sub></i>]]  <a name=iEJG></a><i>reflect</i> limits the number of recursive <a name=iEJH></a><u>reflection</u> rays. If it is set to 0, no reflection rays will be cast; if it is set to 1, one level is allowed but a reflection ray can not be reflected again, and so on.  Similarly, <i>refract</i> controls the maximum depth of <a name=iEJI></a><u>refraction</u> and <a name=iEJJ></a><u>transparency</u> rays (which implement <a name=iFAA></a><u>transparency</u> with and without <a name=iFAB></a><u>index of refraction</u>). Additionally, it is possible to limit the sum of reflection and refraction rays with <i>sum</i>. For example, if <tt><b>3 3 4</b></tt> is given, an eye ray may be reflected 3 times, or refracted 3 times, or reflected twice and then refracted twice, or any other combination that sums up to at most 4. The defaults are 2 2 4. 

<p>
</dl>

<dl>

<dt><tt><b>shadow_sort on|off</b></tt>
<dd>    This flag controls the way shadow shaders are called. Shadow shaders determine how much light from a light source passes through a shadow-casting object between the light source and an illuminated point on some other object. If the sorting flag is off (the default), the shadow shaders are called in random order. If sorting is on, the shadow-casting objects are sorted such that the shadow shader of the object closest to the light source is called first. This slows down rendering slightly, but is required if certain complex shaders such as fur shaders are used. 

<p>
</dl>

<dl>

<dt><tt><b>acceleration spatial subdivision</b></tt>
<dd>    Selects the <a name=iFAC></a><u>binary space partitioning</u> (<a name=iFAD></a><u>BSP</u>) rendering algorithm. This algorithm is often, but by no means always, faster. It is controlled by the <tt><b>max size</b></tt> and <tt><b>max depth</b></tt> parameters. 

<p>
</dl>

<dl>

<dt><tt><b>acceleration ray classification</b></tt>
<dd>    Selects the <a name=iFAE></a><u>ray classification</u> rendering algorithm. This algorithm is recommended for very large scenes. It operates with a constant acceleration memory size, controlled by the <tt><b>subdivision memory</b></tt> and <tt><b>subdivision</b></tt> view statements. 

<p>
</dl>

<dl>

<dt><tt><b>max size</b></tt> <i>size<sub>int</sub></i>
<dd>    The maximum number of primitives in a leaf of the <a name=iFAF></a><u>BSP</u> tree. This parameter is used only if <a name=iFAG></a><u>binary space partitioning</u> is enabled, it has no effect on the <a name=iFAH></a><u>ray classification</u> algorithm. Larger leaf sizes reduce memory consumption but increase rendering time. The default is 4. 

<p>
</dl>

<dl>

<dt><tt><b>max depth</b></tt> <i>depth<sub>int</sub></i>
<dd>    The maximum number of levels in the <a name=iFAI></a><u>BSP</u> tree. This parameter is used only if <a name=iFAJ></a><u>binary space partitioning</u> is enabled. Larger tree depths reduce rendering time but increase memory consumption, and also slightly increase preprocessing time. The default is 25. 

<p>
</dl>

<dl>

<dt><tt><b>subdivision</b></tt> <i>subdiv<sub>int</sub>  subdiv_2d<sub>int</sub></i>
<dd>    mental ray uses a ray tracing algorithm that subdivides the space of all rays<a name=iFBA></a>. The optimal subdivision is determined automatically by a built-in scene analysis.  The <tt><b>subdivision</b></tt> parameter can be used to modify the result of this analysis; arguments of 0 leave the calculated subdivision unchanged, positive numbers increase and negative numbers reduce the subdivision. <i>subdiv</i> controls general subdivision; <i>subdiv_2d</i> controls primary (eye) and shadow rays. This option has no effect if the BSP algorithm is used. 

<p>
</dl>

<dl>

<dt><tt><b>subdivision memory</b></tt> <i>memory<sub>int</sub></i>
<dd>    This parameter sets the amount of memory to be used by the ray space subdivision algorithm for acceleration data structures to <i>memory</i> megabytes on each CPU. It has no effect if the <a name=iFBB></a><u>BSP</u> algorithm is used. mental ray allows presetting the amount of rendering acceleration memory independently of <a name=iFBC></a><u>scene complexity</u> without sacrificing speed. The default is set to 6 megabytes, which is sufficient for most scenes.  Even for extremely large scenes, little can be gained from memory sizes greater than 12 megabytes. Note that this parameter does not affect the amount of memory used for the scene description, which depends on the complexity of the geometry in the current frame. Compare also the <tt><b>memory</b></tt> command; see above. 

<p>
</dl>

<dl>

<dt><tt><b>face front|back|both</b></tt>
<dd>    The <i>front</i> side of a geometric object in the scene is defined to be the side its normal vector points away from. By specifying that only front-facing<a name=iFBD></a> triangles are to be rendered, speed can be improved because fewer triangles need to be tested for a ray. This works well unless there are objects whose back side is seen by refracted or reflected rays -- with <tt><b>face front</b></tt>, the back side would not be visible. The default is <tt><b>face both</b></tt>. 

<p>
</dl>

<dl>

<dt><tt><b>clip</b></tt> <i>hither yon</i>
<dd>    The <i>hither</i> (near) and <i>yon</i> (far) planes are planes parallel to the <a name=iFBE></a><a href=scene.html#iEFA>viewing plane</a> that delimit the rendered scene<a name=iFBF></a>. Points outside the space between the hither and yon planes will not be rendered (this does not apply to the infinite-radius <a name=iFBG></a><u>environment map</u>s because they are not geometric objects). The <tt><b>clip</b></tt> statement specifies the distance of the hither and yon planes from the camera. The defaults are 0.0001 for the hither distance and 1000000.0 for the yon plane. 

<p>
</dl>

<dl>

<dt><tt><b>volume "</b></tt><i>volume_shader_name</i><tt><b>" </b></tt> 
<dd>  (<i>parameters</i><tt><b>)</b></tt>  This statement specifies a volume (atmosphere) shader<a name=iFBH></a> (see <a href=shaders.html#iHGA>volume shader</a>) .  The <a name=iFBI></a><a href=shaders.html#iJCJ>atmosphere</a> affects all rays passing through the space outside objects by attenuating the color of the ray. It is possible to specify a volume shader for the inside of objects<a name=iFBJ></a> too, by naming a volume shader in the <tt><b>material</b></tt> statement (see above). 

<p>
</dl>

<dl>

<dt><tt><b>environment "</b></tt><i>environment_shader_name</i><tt><b>" </b></tt> 
<dd>  (<i>parameters</i><tt><b>)</b></tt>  This statement specifies an <a name=iFCA></a><a href=shaders.html#iHGE>environment shader</a>. Environment shaders control the color returned by <a name=iFCB></a><a href=shaders.html#iHJH>primary ray</a>s that, after leaving the <a name=iFCC></a><u>camera</u>, never strike any object in the scene. They are similar to environment shaders named in materials, which control <a name=iFCD></a><u>reflection</u> rays cast by the material shader that leave the scene without striking another object (or exceeding the <a name=iFCE></a><u>trace depth</u>). 

<p>
</dl>

<dl>

<dt><tt><b>lens "</b></tt><i>lens_shader_name</i><tt><b>" </b></tt> 
<dd>  (<i>parameters</i><tt><b>)</b></tt>  Lens shaders<a name=iFCF></a> (see <a href=shaders.html#iHGG>lens shader</a>)  simulate lenses by changing the <a name=iFCG></a><u>camera</u>. If no lens shader is present, the camera is a <a name=iFCH></a><u>pinhole camera</u> that casts rays from the origin in all directions that pass through the <a name=iFCI></a><a href=scene.html#iEFA>viewing plane</a>, or an <a name=iFCJ></a><u>orthographic camera</u> that casts parallel rays if <tt><b>focal infinity</b></tt> is specified. A lens shader accepts the origin and direction of the camera ray, modifies them, and casts a new camera ray. Examples for lens shaders includes fish-eye lenses that exaggerate the direction vector in a nonlinear way (there is a code example in the Shader section). Multiple lenses can be specified in the view; the <i>n</i>-th lens shader receives the origin and direction computed by the <i>n-1</i>st lens shader. 

<p>
</dl>

<dl>

<dt><tt><b>shadow on|off</b></tt>
<dd>    By default, shadows are enabled. The <a name=iFDA></a><u>shadow</u> statement in the view can be used to turn shadows off globally. 

<p>
</dl>

<dl>

<dt><tt><b>trace on|off</b></tt>
<dd>    Normally, mental ray will use a combination of a <a name=iFDB></a><u>scanline</u> algorithm and <a name=iFDC></a><u>ray tracing</u> to calculate samples of the scene. If <tt><b> </b></tt> trace off is specified, ray tracing is disabled, and mental ray will rely exclusively on the scanline algorithm. Without ray tracing, <a name=iFDD></a><u>reflection</u> rays and <a name=iFDE></a><u>refraction</u> rays cannot be cast. However, scanline transparency that, unlike refractions, does not support changing the direction of the ray based on the <a name=iFDF></a><u>index of refraction</u> of the <a name=iFDG></a><a href=scene.html#iDJG>material</a>, and <a name=iFDH></a><u>environment map</u>s will work when ray tracing is turned off. Ray tracing is turned on by default. 

<p>
</dl>

<dl>

<dt><tt><b>scanline on|off</b></tt>
<dd>    This statement allows turning the <a name=iFDI></a><u>scanline</u> algorithm off to force mental ray to rely exclusively on <a name=iFDJ></a><u>ray tracing</u>. This will slow down rendering in most cases. By default, scanline is turned on unless motion blurring, the <a name=iFEA></a><u>BSP</u> algorithm, or lens shaders are used. 

<p>
</dl>

<dl>

<dt><tt><b>desaturate on|off</b></tt>
<dd>    If a first-generation material shader returns a color whose RGB components are outside the range [0, 1], mental ray will clip the color to a legal range<a name=iFEB></a>. Negative component values are clipped to 0. If any of R, G, and B exceed 1, they are either set to 1 (if <a name=iFEC></a><u>desaturation</u> is turned off), or R, G, and B are faded towards white (if desaturation is turned on). Alpha is always set to 1 if it exceeds 1, or to the maximum of R, G, and B if any of them exceed alpha<a name=iFED></a>. Desaturation is turned off by default. 

<p>
</dl>

<dl>

<dt><tt><b>dither on|off</b></tt>
<dd>    mental ray supports both 8 and 16 bits per color component. In some cases, 8 bits per pixel, as supported by all popular picture <a name=iFEE></a><u>file format</u>s, can cause visible <a name=iFEF></a><u>banding</u> when the floating-point color values calculated by the material shader are quantized<a name=iFEG></a> to the 8-bit values used in the picture file. Dithering mitigates the problem by introducing noise into the pixel such that the round-off errors are randomly distributed. Note that this can cause run-length encoded picture files to be larger than without <a name=iFEH></a><u>dithering</u>. Dithering is turned on by default. 

<p>
</dl>

<dl>

<dt><tt><b>gamma</b></tt> <i>gamma_factor</i>
<dd>    Gamma correction can be applied to rendered color pixels to compensate for output devices with a nonlinear color response. All R, G, B, and alpha component values are raised to <i>gamma_factor</i>. The default gamma factor is 1.0, which turns <a name=iFEI></a><u>gamma correction</u> off. 

<p>
</dl>

<dl>

<dt><tt><b>field even|odd|both</b></tt>
<dd>    Field rendering<a name=iFEJ></a> is a technique that allows smooth <a name=iFFA></a><u>animation</u>s on <a name=iFFB></a><u>interlaced video</u> displays. To reduce flicker, video displays first display only every other scanline of the picture, and then the remaining scanlines in a second sweep. Each sweep is called a <i>field</i>. Two fields are one frame. Since sweeps occur at one half of the frame rate, animated objects may have moved between sweeps. Not taking this into account results in rough animations.  By default, mental ray renders full frames, resulting in a non-interlaced output picture. If field rendering is set to <tt><b>even</b></tt>, every consecutive pair of rendered frames is combined such that the first frame contributes the even scanlines (counted from the top), and the second frame contributes the odd scanlines. This is reversed if field rendering is set to <tt><b>odd</b></tt>.  The decision of which frame is the first or second is based on the frame number; the first field has an odd frame number (usually 1).  If <a name=iFFC></a><a href=scene.html#iFEJ>field rendering</a> is enabled, there must be an even number of <i>frame</i>s in the input file. 

<p>
</dl>
The remaining options are for <a name=iFFD></a><u>contour</u> rendering only. 

<p>
<dl>

<dt><tt><b>contour on|off</b></tt>
<dd>    If contour rendering is turned on, mental ray will render contour lines based on the visibility, self-occlusion, transparency, and normal vectors instead of color images. This option is useful for <a name=iFFE></a><u>cartoon animation</u>.  Contour rendering is turned off by default. If it is turned on, the <tt><b>output</b></tt> statements at the beginning of the <tt><b> </b></tt> view statement must either specify <a name=iFFF></a><u>PostScript</u> output files (<i> </i> filetype <tt><b>"ps"</b></tt>), or must specify an RGB or RGBA file type together with a <i>datatype</i> <tt><b>"contour"</b></tt>. 

<p>
</dl>

<dl>

<dt><tt><b>paper size "</b></tt><i>format</i><tt><b>"</b></tt>
<dd>    If <a name=iFFG></a><u>contour</u> rendering is turned on and the output is a <a name=iFFH></a><u>PostScript</u> file<a name=iFFI></a> (see <tt><b>output</b></tt> statements above), <i>format</i> determines the <a name=iFFJ></a><u>paper size</u>. Available paper sizes are a3, a4, a5, a6, b4, b5, b6, 11x17 (or b), letter (or a), executive, or legal. All paper size strings are case-insensitive. The default is 11x17. 

<p>
</dl>

<dl>

<dt><tt><b>paper scale</b></tt> <i>scale</i>
<dd>    The <a name=iFGA></a><u>paper scale</u> is a correction factor for the size of the <a name=iFGB></a><u>contour</u> drawing on paper. The default is 1.0; numbers greater then 1.0 enlarge the drawing and numbers less than 1.0 reduce it. 

<p>
</dl>

<dl>

<dt><tt><b>discontinuity</b></tt> <i>angle</i>
<dd>    Determines the angle discontinuity required to produce a contour line, in degrees. Any two triangles forming an angle of more than the specified number will produce a contour line segment between them. A value of 0.0 will outline every triangle. The default is 60.0. 

<p>
</dl>

<dl>

<dt><tt><b>contour line width</b></tt> <i>width</i>
<dd>    This parameter determines the <a name=iFGC></a><u>contour</u> line width in points for <a name=iFGD></a><u>PostScript</u> output, and in pixels for picture output. The default is 0.5. 

<p>
</dl>

<dl>

<dt><tt><b>contour depth</b></tt> <i>depth</i>
<dd>    The <a name=iFGE></a><u>contour</u> depth controls contours around occluded or self-occluding objects. A contour line will be drawn between two triangles in the same object if their z depths differ by more than <i> </i> depth. The depth is also used to decide whether to draw a contour line or not between two objects if only one of them has the <tt><b>nocontour</b></tt> flag set in its material. In this case, the Z depths of the two objects are compared, with <i>depth</i> being a threshold: if the two objects differ in Z by less than <i>depth</i> then --- assuming intersection or touching --- no contour line is drawn. If the two objects differ in z by more than <i>depth</i>, draw the contour line if contour generation for the <b>foremost</b> object is enabled; otherwise no contour line is drawn. <i>depth</i> must be positive. The default is 0.0. 

<p>
</dl>

<dl>

<dt><tt><b>paper transform</b></tt> <i>b d</i>
<dd>    The paper transformation defines a transformation that corrects distortions introduced by the printer. The PostScript coordinates expressed in points are transformed according to the matrix <i>(<tt><b>1</b></tt>  b  <tt><b>0</b></tt>  d)</i>. The default is the identical transformation, i.e. no distortion correction. 

<p>
</dl>
<br>
 <p><a name=cI><h3>Objects</h3></a> 

<p><a name=iFGF></a>All <a name=iFGG></a><u>geometry</u> is specified in <a name=iFGH></a><u>camera space</u>. The <a name=iFGI></a><u>camera</u> is assumed to sit at the coordinate origin and points down the negative Z axis. The appearance such as color and transparency of objects is determined by naming materials in an object definition. Before a <a name=iFGJ></a><a href=scene.html#iDJG>material</a> can be used in an object, it must be defined; see above for details. Naming the material determines all aspects of the object's appearance. No further parameters, textures, or lights need to be specified; they are all part of the material definition. 

<p>The two most common approaches to materials and objects are to name all materials first and then all objects, which may simplify the implementation of material editors because all materials may be put in a separate file and then included in the <tt><b>.mi</b></tt> file using a <tt><b> </b></tt> $include command<a name=iFHA></a> (see <a href=scene.html#iDEG>include command</a>) ; or materials and objects may be interspersed as long as each material definition precedes its first use. 

<p>All objects, regardless of the geometry type, have a common format in the <tt><b>.mi</b></tt> file: 

<p>
<p><pre>    <tt><b>object "</b></tt><i>object_name</i><tt><b>"</b></tt> 
        [ <tt><b>visible</b></tt> ] 
        [ <tt><b>shadow</b></tt> ] 
        [ <tt><b>trace</b></tt> ] 
        [ <tt><b>tag</b></tt> <i>label_number<sub>int</sub></i> ] 
        [ <tt><b>transform</b></tt> <i>a<sub>00</sub></i> <i>a<sub>10</sub></i> <i>a<sub>20</sub></i> <i>a<sub>30</sub></i> <i>a<sub>01</sub></i> ... <i>a<sub>33</sub></i> ] 
        [ <i>basis list</i> ] 
        <tt><b>group</b></tt> 
            [ <tt><b>merge</b></tt> <i>epsilon</i> ] 
            <i>vector list</i> 
            <i>vertex list</i> 
            <i>geometry list</i> 
        <tt><b>end group</b></tt> 
        ...             # more groups 
    <tt><b>end object</b></tt> 
 
</pre><p> 

<p>The individual parameters are: 

<p> 
<ul>

<li>  The <tt><b><a name=iFHB></a><a href=scene.html#iFGF>object</b></tt></a></i> name <i>object_name</i> serves to  uniquely identify the object. The name is not used by mental ray in any form except to give meaningful progress reports and error messages. Object names should be enclosed in double quotes to disambiguate them from reserved words. 

<p>
</ul>

<ul>

<li>  The <tt><b>visible</b></tt> flag<a name=iFHC></a> causes the object to be visible. Most objects will have this flag set. Not setting it will make the object invisible to <a name=iFHD></a><a href=shaders.html#iHJH>primary ray</a>s (those originating from the <a name=iFHE></a><u>camera</u>), which means it will disappear from the image. 

<p>
</ul>

<ul>

<li>  The <tt><b>shadow</b></tt> flag<a name=iFHF></a> causes the object to cast <a name=iFHG></a><u>shadow</u>s. The standard case is specifying both the <tt><b>visible</b></tt> and <tt><b>shadow</b></tt> flags. If an object is very complex, it may be desirable to set only the <tt><b>visible</b></tt> flag but not the <tt><b>shadow</b></tt> flag, and create a second object that resembles the first one but is much simpler and set the <tt><b>shadow</b></tt> but not the <tt><b>visible</b></tt> flag on it. The effect is that the object appears unchanged, but shadow calculations see a much simpler shadow object that casts about the same shadow as the primary visible object would. 

<p>
</ul>

<ul>

<li>  The <tt><b>trace</b></tt> flag<a name=iFHH></a> serves a similar purpose as the <tt><b>shadow</b></tt> flag.  Normally, it is always set along with the <tt><b> </b></tt> visible and <tt><b>shadow</b></tt> flags. It controls whether the object is visible to secondary (reflected or refracted) rays<a name=iFHI></a> (see <a href=shaders.html#iHJI>secondary ray</a>) . If the reflecting or refracting objects are fuzzy or only slightly reflective or refractive, it may result in a considerable speedup to make the <a name=iFHJ></a><u>reflection</u> and <a name=iFIA></a><u>refraction</u> rays see a much simpler object than primary rays would. Like with the <tt><b>shadow</b></tt> flag, this is achieved by not setting the <tt><b>trace</b></tt> flag in the primary, high-definition object, and create a second one that roughly resembles the primary object that has the <tt><b>trace</b></tt> flag (and perhaps the <tt><b> </b></tt> shadow flag) but not the <tt><b>visible</b></tt> flag set. 

<p>
</ul>

<ul>

<li>  The <tt><b>tag</b></tt> specifies an arbitrary 32-bit number that identifies the object.  mental ray normally uses the term <i>label</i><a name=iFIB></a>, the keyword <tt><b>tag</b></tt> is retained for backwards compatibility. The term <i>tag</i> is used by mental ray to identify entries in the scene database; this is of concern only to shader writers. By specifying an appropriate <tt><b>output</b></tt> statement in the <tt><b>view</b></tt> (see above), it is possible to cause mental ray to write a label file that, for each pixel, contains the label code of the object that the camera ray hits first. Exactly which label is stored is under the control of the material shader; using the label of the foremost object regardless of reflections and refractions is merely the default behavior. 

<p>
</ul>

<ul>

<li>  The <tt><b>transform</b></tt> statement specifies the transformation matrix that defines the <a name=iFIC></a><u>object space</u> with respect to the <a name=iFID></a><a href=shaders.html#iHDI>internal space</a>. (Coordinate spaces are explained in the Shader section.) Specifying the transformation allows material and texture shaders to do calculations in object space. For example, a 3D texture shader will normally work in object space to prevent the 3D texture from shifting between frames when the camera moves. If no transformation is specified, the identity matrix is used. The last row of the matrix is the translation. 

<p>
</ul>

<ul>

<li>  The <i>basis list</i><a name=iFIE></a> is a list of bases to be used in <a name=iFIF></a><u>free-form surface</u> descriptions. Only <a name=iFIG></a><u>curve</u>s and surfaces use bases. For a list of supported bases, see below. The defined bases can be used in all groups that follow, until the end of the object. 

<p>
</ul>

<ul>

<li>  Finally, a list of <a name=iFIH></a><u>group</u>s contain the actual geometric representation.  The decision whether to put all geometry into a single group or to use different groups for different geometric entities is of importance only for <a name=iFII></a><u>free-form surface</u>s. If two surfaces appear in the same group, they may be connected if the appropriate <tt><b> </b></tt> connect<a name=iFIJ></a> statements are used (see below) or if <a name=iFJA></a><u>adjacency detection</u> (<a name=iFJB></a><u>edge merging</u>) takes place. Surfaces in different groups cannot be connected. Connecting surfaces means that they will be approximated<a name=iFJC></a> (see <a href=scene.html#iHBB>approximation</a>)  such that there is no crack between them; they will form one continuous combined surface in the range of the connection. The merge <i>epsilon</i><a name=iFJD></a> that can be specified in the group determines the maximum gap between two surfaces that still leads to the automatic connection of both surfaces.  The smaller the epsilon, the closer any two surfaces must be to become merged.  By default, the merge epsilon is 0.0 and no edge merging is computed. 

<p>
</ul>
Groups contain the actual <a name=iFJE></a><u>geometry</u>. All geometry needs  <i>vector list</i>s and <i>vertex list</i>s. The <i>vector list</i> contains 3D <a name=iFJF></a><u>vector</u>s that can describe points in space, normals, texture vertices, basis vectors, or motion vectors. Vectors are anonymous, they are triples of floating-point numbers separated by whitespace without inherent meaning. They are numbered beginning with 0.  Numbering restarts at 0 whenever a new group starts. 

<p>mental ray also accepts a compressed binary format for vectors. Instead of three floating-point numbers, a sequence of 12 bytes enclosed in backquotes is accepted. These 12 bytes are the memory image of three floats in IEEE 854 format, in the endianness of the machine ray is running on. This format is intended for increasing translation and parsing speed when ray is connected to a native translator; it should not be used in files exchanged between machines or modified with text filters. Many editors refuse to edit files containing binary data. 

<p>Vertices<a name=iFJG></a> build on vectors. In the <tt><b>.mi</b></tt> format, there is no syntactical difference between polygon vertices and control points vertices for free-form surfaces; both are collectively referred to as ``vertices'' in this discussion. All vertices define a point in space and optional vertex normals, motion vectors, and zero or more textures and basis vectors: 

<p>
<p><pre>    <tt><b>v</b></tt>   <i>index<sub>int</sub></i> 
    [ <tt><b>n</b></tt> <i>index<sub>int</sub></i> ] 
    [ <tt><b>t</b></tt> <i>index<sub>int</sub></i> [ <i>index<sub>int</sub></i> <i>index<sub>int</sub></i> ] ]
    [ <tt><b>m</b></tt> <i>index<sub>int</sub></i> ] 
    ... 
 
</pre><p> 

<p>
<dl>

<dt><tt><b>v</b></tt>
<dd>  specifies the point in space, 

<p>
</dl>

<dl>

<dt><tt><b>n</b></tt>
<dd>  specifies the <a name=iFJH></a><u>vertex</u> <a name=iFJI></a><u>normal</u> (ignored when the vertex is used as a curve or surface <a name=iFJJ></a><u>control point</u>), 

<p>
</dl>

<dl>

<dt><tt><b>m</b></tt>
<dd>  specifies the <a name=iGAA></a><u>motion vector</u> (the distance the point moves during the <a name=iGAB></a><a href=scene.html#iEJF>shutter</a> open time specified in the <tt><b>view</b></tt> statement), and 

<p>
</dl>

<dl>

<dt><tt><b>t</b></tt>
<dd>  specifies a <a name=iGAC></a><u>texture vertex</u> with an optional X/Y <a name=iGAD></a><u>basis vector</u> pair for <a name=iGAE></a><u>bump map</u> calculation. There can be up to 64 <tt><b>t</b></tt> lines for any given <tt><b>v</b></tt> vertex. (The texture and basis vectors are ignored when the vertex is used as a curve or surface control point. Texture and basis information for surfaces is defined using a ``texture surface'', described below.) 

<p>
</dl>
Every vertex begins with a <tt><b>v</b></tt> statement and ends with the next <tt><b>v</b></tt> statement or with the start of the geometry description. If the vertex is to be used as a <a name=iGAF></a><u>control point</u>, it is not meaningful to specify a vertex normal. All occurrences of <i>index</i> above index into the vector list; 0 is the first vector in this group. As stated before, all vectors are 3D. If the third coordinate is not used (as is the case for 2D texture vertices, for 2D curve control points, and for 2D surface special points) it should be set to 0.0. If both the second and third coordinates are unused (as is the case for 1D curve special points), they should be set to 0.0. 

<p>Vertices themselves are numbered, independently of vectors. The first vertex in every group is numbered 0. The geometry description is referencing vertices by <a name=iGAG></a><u>vertex index</u>, just like vertices are referencing vectors by <a name=iGAH></a><u>vector index</u>. This results in a three-stage definition of geometry: 

<p>
<dl>

<dt>1.
<dd>  List of vectors 

<p>
</dl>

<dl>

<dt>2.
<dd>  List of vertices 

<p>
</dl>

<dl>

<dt>3.
<dd>  List of geometry 

<p>
</dl>
The reason for this three-stage process is that it allows both sharing of vectors and sharing of vertices<a name=iGAI></a><a name=iGAJ></a>. This is best illustrated with an example.  Consider two triangles ABC and ABD sharing an edge AB. (This example will use the simplest form of <a name=iGBA></a><u>polygon</u> syntax that will be described later in this section.) The simplest definition of this two-triangle object is: 

<p>
<p><pre><tt><b> </b></tt>   object "twotri" 
        visible 
        group 
            0.0 0.0 0.0 
            1.0 0.0 0.0 
            0.0 1.0 0.0 
            1.0 0.0 0.0 
            1.0 1.0 0.0 
            0.0 1.0 0.0 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           v 0 
            v 1 
            v 2 
            v 3 
            v 4 
            v 5 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           p "material_name" 0 1 2 
            p "material_name" 3 4 5 
        end group 
    end object 
 
</pre><p> 

<p>The first three vectors are used to build the first three vertices, which are used in the first triangle. The remaining three vectors build the next three vertices, which are used for the second triangle. Two vectors are listed twice and can be shared: 

<p>
<p><pre><tt><b> </b></tt>   object "twotri" 
        visible 
        group 
            0.0 0.0 0.0 
            1.0 0.0 0.0 
            0.0 1.0 0.0 
            1.0 1.0 0.0 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           v 0 
            v 1 
            v 2 
            v 1 
            v 3 
            v 2 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           p "material_name" 0 1 2 
            p "material_name" 3 4 5 
        end group 
    end object 
 
</pre><p> 

<p>The order of vector references is noncontiguous to ensure that the second triangle is in counter-clockwise order. Two vertices are redundant and can also be removed by sharing: 

<p>
<p><pre><tt><b> </b></tt>   object "twotri" 
        visible 
        group 
            0.0 0.0 0.0 
            1.0 0.0 0.0 
            0.0 1.0 0.0 
            1.0 1.0 0.0 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           v 0 
            v 1 
            v 2 
            v 3 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           p "material_name" 0 1 2 
            p "material_name" 1 3 2 
        end group 
    end object 
 
</pre><p> 

<p>The need for sharing both vectors and vertices can be shown by specifying vertex normals: 

<p>
<p><pre><tt><b> </b></tt>   object "twotri" 
        visible 
        group 
            0.0 0.0 0.0 
            1.0 0.0 0.0 
            0.0 1.0 0.0 
            1.0 1.0 0.0 
            0.0 0.0 1.0 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           v 0 n 4 
            v 1 n 4 
            v 2 n 4 
            v 3 n 4 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           p "material_name" 0 1 2 
            p "material_name" 1 3 2 
        end group 
    end object 
 
</pre><p> 

<p>In this last example, both vector sharing and vertex sharing takes place.  The normal is actually redundant: if no normal is specified, mental ray uses the <a name=iGBB></a><u>polygon normal</u>. Defaulting to the polygon normal is slightly more efficient<a name=iGBC></a> than interpolating vertex normals, if vertex normals are explicitly specified. 

<p>Two types of geometry can be contained in the <i>geometry list</i>, polygonal geometry and free-from surfaces. In the next sections the syntax of the definitions of polygonal geometry and free-form surfaces is described and illustrated by examples. 

<p>More than one <a name=iGBD></a><u>geometry</u> type may be present within a single group. Although this allows <a name=iGBE></a><u>vector sharing</u> and <a name=iGBF></a><u>vertex sharing</u> between different geometric types (say polygons and surfaces), it will actually slow the parsing stage and is thus not recommended. Future versions of mental ray may explicitly disallow sharing between different types of geometry. It is advised to use only one geometric type per group.  The various types of geometry are described separately in the following sections. 

<p><br> <p><a name=cJ><h3>Polygonal Geometry</h3></a> 

<p>Polygonal geometry consists of polygons. For efficiency reasons, mental ray distinguishes simple <a name=iGBG></a><u>convex polygon</u>s from general <a name=iGBH></a><u>concave polygon</u>s or polygons with holes. <a name=iGBI></a>Both are distinguished by keyword: 

<p>
<p><pre><tt><b> </b></tt>   c "<i>material_name</i>" <i>vertex_ref_list</i> 
    cp "<i>material_name</i>" <i>vertex_ref_list</i> 
    p "<i>material_name</i>" <i>vertex_ref_list</i> 
    p "<i>material_name</i>" <i>vertex_ref_list</i> hole <i>vertex_ref_list</i> ... 
 
</pre><p> 

<p>The <tt><b>c</b></tt> keyword selects convex polygons without holes. The results are unpredictable if the polygon is not convex. The <tt><b>cp</b></tt> keyword is a synonym for <tt><b>c</b></tt> for backwards compatibility; <tt><b>c</b></tt> should be used in new translators. The <tt><b>p</b></tt> keyword also renders concave polygons correctly, and allows specification of holes, using one or more <tt><b>hole</b></tt> keywords, each followed by a <i>vertex_ref_list</i>. 

<p>If all polygons within the same object group are simple convex polygons containing three sides (i.e. triangles), mental ray will pre-process them in a more efficient manner than non-triangular polygons. 

<p>A <i>vertex_ref_list</i> is a list of non-negative integers <i>index</i>  that reference vertices in the vertex list of the group described in the  previous section.  The first vertex in the vertex list is numbered 0. 

<p>Any <a name=iGBJ></a><u>vertex index</u> can be used in both polygon and hole <i>vertex_ref_list</i>s. A polygon with <i>n</i> vertices is defined by <i>n</i> index values in the vertex list following the <a name=iGCA></a><a href=scene.html#iDJG>material</a> name.  The order of the polygon vertices is important. A counter-clockwise ordering of the vertices<a name=iGCB></a> yields a front-facing polygon<a name=iGCC></a> (see <a href=scene.html#iFBD>back culling</a>) . The vertex list of a hole may be ordered any way. 

<p>The material name must have been defined before the object definition that contains the polygon definition, in a statement like 

<p>
<p><pre><tt><b> </b></tt>   material "<i>material_name</i>" 
        ... 
    end material 
 
</pre><p> 

<p>In both cases, it is recommended to quote the material name to avoid conflicts with reserved words, and to allow arbitrary characters in the name. For a detailed description of material definitions, see the section on materials above. 

<p>The tessellation of polygons assumes that polygons are ``reasonably'' planar. This means that every polygon will be tessellated, but the exact subdivision into triangles does not attempt to minimize curvature.  If the curvature is low, different tessellations cannot be distinguished, but consider the extreme case where the four corners of a tetrahedron are given as polygon vertices: the resulting polygon will consist of two triangles, but it cannot be predicted which of the four possible triangles will be chosen. 

<p>The behavior will be different for convex polygons without holes  (<tt><b>cp</b></tt> keyword) and polygons which contain holes or are concave  (<tt><b>p</b></tt> keyword).   Convex polygons without holes are triangulated by picking a vertex on the  outer loop and connecting it with every other vertex except its direct  neighbors. If polygons are not flagged by the <tt><b>cp</b></tt> keyword but do not  have any holes an automatic convexity test is performed and if they are  indeed convex they are triangulated as described.   Convex polygons with holes and concave polygons are triangulated by a  different algorithm. In any case a projection plane is chosen such that the extents of the  projection of the bounding box of the (outer) loop have maximal size.   If the projection of the polygon onto that plane is not one-to-one the  results of the triangulation will be erroneous. 

<p>

<p><br> <p><a name=cBA><h3>Free-Form Surface Geometry</h3></a> 

<p>Free-form surfaces<a name=iGCD></a> are polynomial <a name=iGCE></a><u>patch</u>es of any degree up to twenty-one.The algorithms used impose no  inherent limit. The limit may be increased in future versions.Supported basis types include <a name=iGCF></a><u>B&eacute;zier</u>, <a name=iGCG></a><u>Taylor</u>, <a name=iGCH></a><u>B-spline</u>, <a name=iGCI></a><u>cardinal</u>, and basis-matrix<a name=iGCJ></a> form.  Any type can be rational<a name=iGDA></a> or non-rational. Patches can be explicitly or automatically connected to one another, or may be defined to contain explicitly defined points or curves in their <a name=iGDB></a><a href=scene.html#iHBB>approximation</a>. Various approximation types including parametric<a name=iGDC></a>, spatial<a name=iGDD></a>, curvature-dependent<a name=iGDE></a>, and camera-dependent<a name=iGDF></a> are available. Surfaces may be bounded by a <a name=iGDG></a><a href=scene.html#iHAD>trimming curve</a>, and may contain holes. 

<p>Surface geometry, like polygonal geometry, is defined by a series of sections. An object containing only surface geometry follows this broad outline: 

<p>
<p><pre>    <tt><b>object "</b></tt><i>object_name</i><tt><b>"</b></tt> 
        [ <tt><b>visible</b></tt> ] 
        [ <tt><b>shadow</b></tt> ] 
        [ <tt><b>trace</b></tt> ] 
        [ <tt><b>tag</b></tt> <i>label_number<sub>int</sub></i> ] 
        [ <tt><b>transform</b></tt> <i>a<sub>00</sub></i> <i>a<sub>10</sub></i> <i>a<sub>20</sub></i> <i>a<sub>30</sub></i> <i>a<sub>01</sub></i> ... <i>a<sub>33</sub></i> ] 
        [ <i>basis list</i> ] 
        <tt><b>group</b></tt> 
            [ <tt><b>merge</b></tt> <i>epsilon</i> ] 
            <i>vector list</i> 
            <i>vertex list</i> 
            [ <i>list of curves</i> ] 
            <i>surface</i> 
            [ <i>list of texture or vector surfaces</i> ] 
            ...                         # more surfaces 
            [ <i>list of approximation statements</i> ] 
            [ <i>list of connection statements</i> ] 
        <tt><b>end group</b></tt> 
        ...                             # more groups 
    <tt><b>end object</b></tt> 
 
</pre><p> 

<p>Curves, surfaces, approximations, and connections may be interspersed as long as names are defined before they are used. For example, a curve must come before the surface it is trimming, and an approximation must come after the surface to be approximated. Texture and vector texture surfaces must always directly follow the surface they apply to.  The individual sections are: 

<p>
<ul>

<li>  The <i>basis list</i><a name=iGDH></a> must be specified at the beginning of the object definition, just before the group begins. Bases defined in this section are referenced by name in the curve and surface definitions to specify their degrees and types (B&eacute;zier, B-spline, etc.). 

<p>
</ul>

<ul>

<li>  The <i>vector list</i> in the group is a list of <i>(x, y, z)</i> vectors used to build control points later. This section is the same as the vector section used to build vertices for polygonal geometry. 

<p>
</ul>

<ul>

<li>  The <i>vertex list</i> that follows the vector list builds control points out of the vectors. This also works like the vertex list for polygonal geometry, except that no normals and texture vertices can be defined here (i.e., no <tt><b>n</b></tt> or <tt><b>t</b></tt> statements may appear). Normals are defined implicitly by the surface, and textures are defined by <i>texture surfaces</i> instead as described below.  Rational curves and surfaces specify additional weights at each vertex reference (see below). 

<p>
</ul>

<ul>

<li>  <i>Curves</i> may be defined and used as <a name=iGDI></a><a href=scene.html#iHAD>trimming curve</a>s, <a name=iGDJ></a><a href=scene.html#iHAE>hole curve</a>s, and <a name=iGEA></a><a href=scene.html#iHAF>special curve</a>s. This section is optional; if no trimming curve is defined surfaces are untrimmed. Trimming a surface means to cut away portions that fall outside an outer boundary curve; holes cut away portions inside the hole curve. Special curves are curves that are always included in the tessellation; they can be used to define features like sharp creases that need to be tessellated consistently.  Surfaces may also be connected<a name=iGEB></a> along trimming  curves. 

<p>
</ul>

<ul>

<li>  The surface geometry list consists of <tt><b>surface</b></tt> statements, much like polygonal geometry that consists of <tt><b>c</b></tt> and <tt><b>cp</b></tt> statements. A surface is defined by a <tt><b>surface</b></tt> statement, optionally followed by one or more <tt><b>texture surface</b></tt> or <tt><b>vector surface</b></tt> statements. 

<p>
</ul>

<ul>

<li>  <i>Approximation</i><a name=iGEC></a> (see <a href=scene.html#iHBB>approximation</a>)  statements give additional information about how a surface and its trimming and hole curves are to be approximated. Various modes such as parametric, curvature-dependent, and view-dependent approximations can be selected, along with the precision. 

<p>
</ul>
For a description of vector lists and vertex lists, refer to the Object section above. Note that no vector or vertex should be shared between both polygonal and surface geometry statements. That is, no vertex, and no vector used for building it, may be used as a polygon vertex and a surface control point at the same time. It is recommended but not required that an object contains only polygonal or surface geometry but not both, because there is a slight speed reduction if mental ray has to sort out which vertex and vector is used for which geometry. 

<p>

<p><p><a name=cBB><h4>Bases</h4></a> 

<p>When surfaces and curves are present within an object group, it is mandatory  that at least one <a name=iGED></a><u>basis</u> has been defined within the object.  Bases define the degree and type of polynomials (denoted by  <i>N<sub>i,n</sub></i> below) to be used in  the description of curves or surfaces.  Curves and surfaces reference bases by name.  Every surface needs two bases, one for the U and one for the V parameter direction. Both can have a different degree, but must have the same type (for  example, rational B&eacute;zier in U and Cardinal in V is not allowed). There are  five basis types: 

<p><a name=iGEE></a><a name=iGEF></a><a name=iGEG></a><a name=iGEH></a><a name=iGEI></a><a name=iGEJ></a><a name=iGFA></a><a name=iGFB></a><a name=iGFC></a>
<p><pre>    <tt><b>basis "</b></tt><i>basis_name</i><tt><b>"</b></tt> [ <tt><b>rational</b></tt> ] <tt><b>taylor</b></tt> <i>degree<sub>int</sub></i> 
    <tt><b>basis "</b></tt><i>basis_name</i><tt><b>"</b></tt> [ <tt><b>rational</b></tt> ] <tt><b>bezier</b></tt> <i>degree<sub>int</sub></i> 
    <tt><b>basis "</b></tt><i>basis_name</i><tt><b>"</b></tt> [ <tt><b>rational</b></tt> ] <tt><b>cardinal</b></tt> 
    <tt><b>basis "</b></tt><i>basis_name</i><tt><b>"</b></tt> [ <tt><b>rational</b></tt> ] <tt><b>bspline</b></tt> <i>degree<sub>int</sub></i> 
    <tt><b>basis "</b></tt><i>basis_name</i><tt><b>"</b></tt> [ <tt><b>rational</b></tt> ] <tt><b>matrix</b></tt> <i>degree<sub>int</sub></i> <i>stepsize<sub>int</sub></i> <i>basis_matrix</i> 
 
</pre><p> 

<p>A parametric representation may be either non-rational or rational as indicated by the <tt><b>rational</b></tt> flag. Rational curves and surfaces specify additional weights at each control point.  The <i>degree</i> specifies the degree of the polynomials used in the description of curves or surfaces; recall that the degree of a polynomial is the highest power of the parameter occuring in its definition.  When bases of degree 1 are used control points are connected with straight lines. Cardinal bases always have degree 3.  The degree and the type combined determine the length of the <a name=iGFD></a><u>parameter vector</u> and the number of control points needed for the surface.  The meaning of the parameter vector differs for the different basis types.  This is described in detail below. 

<p>The supported polynomial types for curves <a name=iGFE></a> and  surfaces <a name=iGFF></a> are <tt><b>bezier</b></tt><a name=iGFG></a>,  <tt><b>bspline</b></tt><a name=iGFH></a>, <tt><b>taylor</b></tt><a name=iGFI></a>, <tt><b>cardinal</b></tt><a name=iGFJ></a>  and <tt><b>matrix</b></tt><a name=iGGA></a>. 

<p><tt><b>taylor</b></tt> specifies the basis functions:<a name=iGGB></a> 
<p><center> N<sub>i,n</sub>(t) = t<sup>i</sup>
</center><p>
 

<p><tt><b>bezier</b></tt> specifies the basis functions:<a name=iGGC></a> 
<p><center> N<sub>i,n</sub>(t) = n  <I>over</I> it<sup>i</sup>(1-t)<sup>n-i</sup>
</center><p>
 

<p><tt><b>cardinal</b></tt><a name=iGGD></a> specifies third <a name=iGGE></a><u>degree</u> curves<a name=iGGF></a> and surfaces <a name=iGGG></a>.   The Cardinal splines, also known as Catmull-Rom splines, are most easily formulated as a conversion from B&eacute;zier form.  If we let <i>B<sub>i,3</sub>(t)</i> be the cubic <a name=iGGH></a><u>B&eacute;zier</u> basis functions (i.e., the above basis functions <i>N<sub>i,n</sub>(t)</i> with <i>n=3</i>), then we may write the cardinal<a name=iGGI></a> basis functions as  
<p><center><br>
<br>
N<sub>0,3</sub> = -1/6 B<sub>1,3</sub>(t) <br>
N<sub>1,3</sub> = B<sub>0,3</sub>(t) + B<sub>1,3</sub>(t) + 1 /6 B<sub>2,3</sub>(t) <br>
N<sub>2,3</sub> = 1 /6 B<sub>1,3</sub>(t) + B<sub>2,3</sub>(t) + B<sub>3,3</sub>(t) <br>
N<sub>3,3</sub> = -1 /6 B<sub>2,3</sub>(t) 
</center><p>
 

<p><tt><b>bspline</b></tt> specifies a non-uniform <a name=iGGJ></a><u>B-spline</u> representation whose basis functions are given by the following recursive definition: 
<p><center> N<sub>i,0</sub>(t) =  1  if x<sub>i</sub> &lt;=t &lt; x<sub>i+1</sub> <br>
<br>
0  otherwise  
</center><p>
 and 
<p><center> N<sub>i,n</sub>(t) = <br>
t-x<sub>i</sub>     /x<sub>i+n</sub>-x<sub>i</sub>     N<sub>i,n-1</sub>(t) <br>
+ x<sub>i+n+1</sub>-t /x<sub>i+n+1</sub>-x<sub>i+1</sub> N<sub>i+1,n-1</sub>(t) <br>

</center><p>
 where, by convention, <i> 0/0 = 0</i>. <i>(x<sub>0</sub>,...,x<sub>q</sub>)</i> is known as the <a name=iGHA></a><u>knot vector</u>.  It must be specified through the parameter lists when using B-spline  bases in curves and surfaces (see below). 

<p>A <tt><b>matrix</b></tt> <i>(b<sub>i,j</sub>)<sub>0 &lt;=i &lt;=n,0 &lt;=j &lt;=n</sub></i> specifies the basis functions:<a name=iGHB></a> 
<p><center> N<sub>i,n</sub>(t) = Sum<sub>j=0</sub><sup>n</sup>b<sub>i,j</sub>t<sup>j</sup>
</center><p>
 When a curve or surface is being evaluated and a transition from one segment or patch to the next occurs, the set of control points (the `evaluation window') used is incremented by the <i> </i> stepsize<a name=iGHC></a>.  The appropriate <i> </i> stepsize depends on the representation type expressed through the basis matrix and on the degree. 

<p>Suppose we are given a curve with <i>k</i> control points <i>{v<sub>1</sub>, ..., v<sub>k</sub>}</i>. If the curve is of degree <i>n</i>, then <i>n+1</i> control points are needed for each polynomial segment.  If the <i>stepsize</i> is given as <i>s</i>, then the <i>(1+i)</i>th polynomial segment, will use the control points  <i>{v<sub>is+1</sub>,...,v<sub>is+n+1</sub>}</i>.  For example, for B&eacute;zier curves <i>s=n</i>, whereas for Cardinal curves <i>s=1</i>. For surfaces, the above description applies independently to each parametric dimension. 

<p>The <i>basis_matrix</i> specifies the basis functions used to evaluate a parametric representation. For a basis of degree <i>n</i> the matrix must be of size <i>(n+1)*(n+1)</i>. The matrix is laid out in the order <i>b<sub>0,0</sub>, b<sub>0,1</sub>, ... ,</i> <i>b<sub>0,n</sub>, ... , b<sub>n,n</sub></i>. 

<p>Note that the generalization to the rational case for all representations is admitted in all cases.<a name=iGHD></a> 

<p>As an example, an object containing a nonrational B&eacute;zier surface of degree 3 in one parameter direction and degree 1 in the other parameter direction needs two bases defined at the beginning of the object like this: 

<p>
<p><pre><tt><b> </b></tt>   object "mysurface" 
        visible 
        basis "bez1" bezier 1 
        basis "bez3" bezier 3 
        group 
            ... 
 
</pre><p> 

<p>The surface definition will reference the two bases by their names, <tt><b>bez1</b></tt> and <tt><b>bez3</b></tt>. 

<p>

<p><p><a name=cBC><h4>Surfaces</h4></a> 

<p><a name=iGHE></a>A surface specifies a name and a list of control points. For both parametric dimensions it specifies a <a name=iGHF></a><u>basis</u>, a global parameter range, and a parameter list<a name=iGHG></a>. Optionally, it specifies <a name=iGHH></a><u>texture surface</u>s, <a name=iGHI></a><a href=scene.html#iHAD>trimming curve</a>s, <a name=iGHJ></a><a href=scene.html#iHAE>hole curve</a>s, <a name=iGIA></a><a href=scene.html#iHAF>special curve</a>s and <a name=iGIB></a><a href=scene.html#iHAG>special point</a>s. Special curves and points are included as edges and vertices in the <a name=iGIC></a><a href=scene.html#iHBB>approximation</a> (<a name=iGID></a><u>triangulation</u>) of the surface. 

<p>
<p><pre>        <tt><b>surface "</b></tt><i>surface_name</i><tt><b>" "</b></tt><i>material_name</i><tt><b>"</b></tt> 
            <tt><b>"</b></tt><i>u_basis_name</i><tt><b>"</b></tt> <i>range u_param_list</i> 
            <tt><b>"</b></tt><i>v_basis_name</i><tt><b>"</b></tt> <i>range v_param_list</i> 
            <i>hom_vertex_ref_list</i> 
            [ <i>texture_surface_list</i> ] 
            [ <i>surface_specials_list</i> ] 
 
</pre><p> 

<p>The bases used in the definition of the surface must have been  defined in the <i>basis list</i> of the object.  The are referenced  by their <i>basis_name</i>s.  Their <i>range</i>s consist of two floating-point numbers specifying the minimum and maximum parameter values used in the respective direction. 

<p>The <i>parameter_list</i>s in the basis specifications define the  number of patches of the surface and the number of control points.  For bases of the types <tt><b>taylor</b></tt>, <tt><b>bezier</b></tt>, <tt><b>cardinal</b></tt> and <tt><b>matrix</b></tt> such a <i>parameter_list</i> consists of a strictly increasing list of at least two floating-point numbers. For <tt><b>bspline</b></tt> bases the <i>parameter_list</i>s specify the knot vector. If the <a name=iGIE></a><u>B-spline</u> basis to be used is of degree <i>n</i>  the knot vector <i>(x<sub>0</sub>,...,x<sub>q</sub>)</i> must have at least <i>q+1=2(n+1)</i>  elements.  Knot values represent a monotone sequence of floating-point  numbers but are not necessarily strictly increasing, i.e. <i>x<sub>i</sub> &lt;=x<sub>i+1</sub></i>.   Moreover, they must satisfy the following conditions: 
<p><pre> (1)    <i>x<sub>0</sub> &lt; x<sub>n+1</sub> </i> 
 (2)    <i>x<sub>q-n-1</sub> &lt; x<sub>q</sub> </i> 
 (3)    <i>x<sub>i</sub> &lt; x<sub>i+n</sub> for 0&lt;i&lt;q-n-1 </i> 
 (4)    <i>x<sub>n</sub> &lt;=t<sub>min</sub> &lt; t<sub>max</sub> &lt;=x<sub>q-n</sub> </i> 
 
</pre><p> where <i>[t<sub>min</sub>,t<sub>max</sub>]</i> is the range over which the <a name=iGIF></a><u>B-spline</u> is to be evaluated. Equation (1) demands that no more than <i>n + 1</i> parameters at the beginning of the parameter list may have the same value. Equation (2) is the same restriction for the end of the parameter list. Equation (3) says that in the middle of the parameter list, at most <i>n</i> consecutive parameters may have the same value. To generate closed B-spline curves, it is often necessary to write a parameter list where the first <i>n</i> and last <i>n</i> parameters in the list produce initial and final curve segments that should not become part of the curve; in this case equation (4) allows choosing a start and end parameter in the range bounded by the first and last parameter of the parameter list. 

<p>The number of control points per direction can be derived from the number of parameters <i>p</i>, the degree of the basis <i>n</i>, and the step size <i>s</i>. Their total number can be calculated by multiplying the numbers taken from the following table for each of the U and V directions. 
<p><pre><tt><b> </b></tt> type          min. no. of parameters  no. of control points 
 <hr>
 Taylor         <i> 2</i>                      <i>(p - 1) *(n + 1) </i> 
 B&eacute;zier         <i> 2</i>                      <i>(p - 1) *n + 1 </i> 
 cardinal       <i> 2</i>                      <i>p + 2 </i> 
 basis matrix   <i> 2</i>                      <i>(p - 2) *s + n + 1</i> 
 B-spline       <i> 2(n+1)</i>                 <i>p - n - 1 </i> 
 <hr>
 
</pre><p> 

<p>Note that only certain numbers of control points are possible; for example, if the U basis is a degree-3 B&eacute;zier, the number of control points in the U direction can be 4, 7, 10, 13, and so on, but not 3 or 5. For <a name=iGIG></a><u>B-spline</u> bases of degree 3 the minimum number of parameters is 8 corresponding to 4 control points. 

<p>Each vertex reference in the <i>hom_vertex_ref_list</i> is an integer index into the vertex list of the current group in the object (index 0 is the first vertex).  When the surface is rational, <a name=iGIH></a><u>homogeneous coordinates</u> must be  given with the <a name=iGII></a><u>control point</u>s, by appending a floating-point weight to  every vertex reference integer in the <i>hom_vertex_ref_list</i>.  Weights are used only if the surface is rational but ignored otherwise. If a weight in a rational surface is missing, it defaults to 1.0. The surface specials list is used to define <a name=iGIJ></a><a href=scene.html#iHAD>trimming curve</a>s, <a name=iGJA></a><a href=scene.html#iHAE>hole curve</a>s, <a name=iGJB></a><a href=scene.html#iHAF>special curve</a>s, and <a name=iGJC></a><a href=scene.html#iHAG>special point</a>s (vertex references). A surface may be further modified by approximation and connection statements, as described below. 

<p>For example, an object with a simple degree-3 B&eacute;zier surface can be written as: 

<p><pre>
     object "mysurface"
          visible
          basis "bez3" bezier 3 
          group 
               0.314772   -3.204608  -7.744229   # vector 0 
               0.314772   -2.146943  -6.932366 
               0.314772   -1.089277  -6.120503 
               0.314772   -0.031611  -5.308641 
               -0.660089  -2.650739  -8.465791   # vector 4 
               -0.660089  -1.593073  -7.653928 
               -0.660089  -0.535407  -6.842065 
               -0.660089  0.522259   -6.030203 
               -1.634951  -2.096869  -9.187352   # vector 8 
               -1.634951  -1.039203  -8.375489 
               -1.634951  0.018462   -7.563627 
               -1.634951  1.076128   -6.751764 
               -2.609813  -1.543000  -9.908914   # vector 12 
               -2.609813  -0.485334  -9.097052 
               -2.609813  0.572332   -8.285189 
               -2.609813  1.629998   -7.473326 

               v 0     v 1     v 2     v 3       # vertices
               v 4     v 5     v 6     v 7 
               v 8     v 9     v 10    v 11 
               v 12    v 13    v 14    v 15 

               surface "surf1" "material" 
                       "bez3"  0.0 1.0   0.0 1.0 
                       "bez3"  0.0 1.0   0.0 1.0 
                       0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
          end group 
     end object 
</pre>


<p>First, 16 vectors are defined, each of which is used to build one vertex (control point). Next, a surface is defined that uses basis <tt><b> </b></tt> bez3 for both the U and V parameter directions. Since the surface is built from only one <i> 4 *4</i> B&eacute;zier patch, the <a name=iGJD></a><u>parameter vector</u> after the basis range has only length 2. If there had been two patches in the U direction and three in the V direction, the bases would have been referenced as<a name=iGJE></a> 

<p>
<p><pre><tt><b> </b></tt>               "bez3"  0.0 1.0 0.0 0.5 1.0 
                "bez3"  0.0 1.0 0.0 0.33333 0.66667 1.0 
 
</pre><p> 

<p>Alternatively, the parameter vector may be given as 

<p>
<p><pre><tt><b> </b></tt>               "bez3"  0.0 2.0 0.0 1.0 2.0 
                "bez3"  0.0 3.0 0.0 1.0 2.0 3.0 
 
</pre><p> 

<p>by changing the parameter range of the basis. This has no influence on the geometry of the surface, but generates UV texture coordinates in a different range (here, <i>[0.0, 2.0] *[0.0, 3.0]</i>).  However, a different parametrization does affect the texture surface range (see below), and the range of trimming, hole, and special curves (which do not define their own ranges but borrow the range from the surface they apply to). 

<p>The optional <i>surface_specials_list</i> that completes the surface definition is a sequence of trimming curves, hole curves, special curves, and special points as described in the next section. 

<p>For a complete example including approximations and connections, refer to the end of this chapter. 

<p>

<p><p><a name=cBD><h4>Texture Surfaces</h4></a> 

<p>A plain <tt><b>surface</b></tt> statement defines the geometry of the surface. If a texture is to be mapped on the surface, it is necessary to include <a name=iGJF></a><u>texture surface</u>s.  A texture surface defines a mapping from raw UV coordinates to texture coordinates as used by shaders. A vector texture is a variation of a texture surface that additionally defines basis vectors; it is used for bump mapping.   Vector surfaces normally come in pairs because bump mapping normally needs perturbation directions for U and V. 

<p>The texture or vector texture directly following a surface defines <a name=iGJG></a><a href=scene.html#iGJI>texture space</a> number 0, the next defines texture space number 1, and so on, exactly like the first <tt><b>t</b></tt> statement after the <tt><b>v</b></tt> statement in a vertex used for building polygonal geometry defines texture space number 0, the next <tt><b>t</b></tt> defines texture space number 1, and so on. Basically, texture and vector texture surfaces replace the <tt><b>t</b></tt> statements used by polygonal geometry, because attaching textures to control points that usually are not part of the surface is not useful. 

<p>Texture spaces is what ends up in the <i>state-&gt;tex_list</i> array where it can be accessed by texture shaders to decide which texture is mapped which way. Texture space 0 is the first entry in that array, which is used by the shader for the first texture listed in the texture list in the material definition. In general, there is one texture space per texture on a material, although shaders making nonstandard use of texture spaces could be written. 

<p>The syntax for texture surfaces is a simplified version of geometric surfaces. The <i>texture_surface_list</i> in the grammar summary at the beginning of the ``Surfaces'' section above expands to zero or more copies of the following block: 

<p>
<p><pre>        [ <tt><b>vector</b></tt> ] <tt><b>texture</b></tt> 
            <tt><b>"</b></tt><i>u_basis_name</i><tt><b>"</b></tt> <i>u_param_list</i> 
            <tt><b>"</b></tt><i>v_basis_name</i><tt><b>"</b></tt> <i>v_param_list</i> 
            <i>vertex_ref_list</i> 
 
</pre><p> 

<p>Unlike geometric surfaces, no surface name and material name is given. Bases are given like in geometric surfaces. Texture surfaces use the ranges of the geometric surface they are attached to, they are not repeated in the texture surface basis statements. The <i> </i> vertex_ref_list follows the same rules as the geometric surface's <i>vertex_ref_list</i>.  Texture surfaces have no specials such as trimming curves or holes. 

<p>The optional <tt><b>vector</b></tt> keyword in the texture surface definition is a flag that causes <a name=iGJH></a><u>bump basis vectors</u> to be calculated during tessellation. This flag must be used if the texture surface is used for a bump map; all built-in shaders supporting bump maps expect a pair of bump basis vectors and thus, a pair of vector texture surfaces. 

<p>This is an example for the simplest of all texture surfaces, a bilinear mapping: 

<p>
<p><pre><tt><b> </b></tt>   object "mysurface" 
        visible 
        basis "bez1" bezier 1 
        basis "bez3" bezier 3 
        group 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           <i>16 vectors used for the surface</i> 
            0.0 0.0 0.0         # vector number 16 
            0.0 1.0 0.0         # vector number 17 
            1.0 0.0 0.0         # vector number 18 
            1.0 1.0 0.0         # vector number 19 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           <i>16 vertices used for the surface</i> 
            v 16                # vertex number 16 
            v 17                # vertex number 17 
            v 18                # vertex number 18 
            v 19                # vertex number 19 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           surface "surf1" "material" 
                "bez3"  0.0 1.0 0.0 1.0 
                "bez3"  0.0 1.0 0.0 1.0 
                0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
 
</pre><p> 
<p><pre><tt><b> </b></tt>               texture 
                    "bez1"  0.0 1.0 
                    "bez1"  0.0 1.0 
                    16 17 18 19 
        end group 
    end object 
 
</pre><p> 

<p>This texture surface defines a bilinear mapping from the UV coordinates  computed during surface tessellation to the texture coordinates.  To define other than bilinear mappings, the texture surface needs to have  more control points than just one at every corner of the surface.  Whenever the surface tessellator generates a triangle vertex, it uses the  UV coordinate of that vertex to look up the texture surface and interpolate  the texture coordinate from the nearest four points of the texture surface.  The resulting texture coordinate is stored with the vertex and becomes available in <i>state-&gt;tex_list</i> when the material shader is called because a ray has hit the surface. 

<p>If more than one texture surface is given, one texture coordinate is computed for each texture surface and stored in sequence in the generated triangle vertices. Each texture surface is said to define a ``<a name=iGJI></a><u>texture space</u>''. They are available in the <i>state-&gt; tex_list</i> array in the same order. The number and order of texture surfaces should agree with the number and order of textures given in the texture list in the material definition. (Note that not all material shaders support multiple textures.) 

<p>

<p><p><a name=cBE><h4>Curves</h4></a> 

<p>Curves<a name=iGJJ></a> are two-dimensional parametric curves which are referenced by surfaces. They are used as <a name=iHAA></a><a href=scene.html#iHAD>trimming curve</a>s, <a name=iHAB></a><a href=scene.html#iHAE>hole curve</a>s, and <a name=iHAC></a><a href=scene.html#iHAF>special curve</a>s.  They must be defined before the surface which references them. A curve is defined as: 

<p>
<p><pre>        <tt><b>curve "</b></tt><i>curve_name</i><tt><b>" "</b></tt><i>basis_name</i><tt><b>"</b></tt> 
            <i>parameter_list</i> 
            <i>hom_vertex_ref_list</i> 
            [ <tt><b>special</b></tt> <i>special_point_list</i> ] 
 
</pre><p> 

<p>The <i>parameter_list</i> of a curve is a list of monotonically increasing floating-point numbers that define the number of segments of the curve and the number of control points. Curve parameter lists work very much the same way as surface parameter lists except that no range needs to be provided, because they are supplied by the surfaces that reference the curve under consideration as explained in the next section.  For details on parameter lists, see the  sections on bases and surfaces above. 

<p>Each vertex reference in the <i>hom_vertex_ref_list</i> is an integer index  into the vertex list of the current group in the object (index 0 is the first vertex), optionally followed by a floating-point weight. Weights are used only if the curve is rational, they are ignored otherwise. If a weight in a rational curve is missing, it defaults to 1.0. The vertices indexed by the integers in the <i>hom_vertex_ref_list</i> should have no normals or textures (no <tt><b>n</b></tt> and <tt><b>t</b></tt> statements), and the third component of the vector (<tt><b>v</b></tt> statement) should be <i> 0.0</i> because curves are defined in UV space, not 3D space. 

<p>The optional <i>special_point_list</i> specifies points that are included in the approximation of the curve. After the <tt><b>special</b></tt> keyword, a sequence of integers follows that index into the vertex list, just like the integers in the <i>hom_vertex_ref_list</i>. The first component of the vector is used as the <i>t</i> parameter; it forces the point  on the curve at parameter value <i>t</i> to become part of the curve  approximation. Of course <i>t</i> must be in the range of parameters  allowed by the surface definition. 

<p>

<p>

<p><p><a name=cBF><h4>Trimming, Hole, and Special Curves; Special Points</h4></a> 

<p>A surface may reference curves to trim the surface, to cut holes into it,  and to specify ``special curves'' that become part of the tessellation of  the surface. Special points in surfaces work like special points in curves,  except that they provide a point in the parameter range of the surface,  i.e. a two-dimensional UV coordinate, rather than a one-dimensional curve  parameter. They specify single points on the surface that are to be included  in the tessellation.  As all curves and points are in UV space, the third  component of the vectors provided for them is ignored.  None of the above types of curves and points may exceed the range of <i>(0.0, 1.0)</i> at any point.  

<p>No two curves may intersect each other, and no curve may self-intersect. This is an important point, because trimming curves and holes that are not closing or intersecting themselves or other loops are hazardous for the tessellation routines. 

<p>Trimming, hole, and special curves and special points are defined at the end of the surface definition.  The curves are composed of segments from the list of curves of the surface's group. The <i>surface_specials_list</i> given in the previous section is a list of zero or more of the following four items:<a name=iHAD></a><a name=iHAE></a><a name=iHAF></a><a name=iHAG></a> 

<p>
<p><pre>    <tt><b>trim</b></tt>    <tt><b>"</b></tt><i>curve_name</i><tt><b>"</b></tt> <i>min max</i> 
            ... 
    <tt><b>hole</b></tt>    <tt><b>"</b></tt><i>curve_name</i><tt><b>"</b></tt> <i>min max</i> 
            ... 
    <tt><b>special</b></tt> <tt><b>"</b></tt><i>curve_name</i><tt><b>"</b></tt> <i>min max</i> 
            ... 
    <tt><b>special</b></tt> <i>vertex<sub>int</sub></i> 
            ... 
 
</pre><p> 

<p>The dots indicate that each trim, hole, and special statement may be followed by more than one curve segment resp. vertex.  

<p>The <i>vertex</i> integers specify vertices from the vertex section  of the current group in the current object.  Such a vertex specifies the  UV coordinate of the special point that is to be included in the tessellation. 

<p>Each of the three types of curves references a curve that has been defined earlier with a <tt><b>curve</b></tt> statement. If a single <tt><b>trim</b></tt>, <tt><b>hole</b></tt>,  or <tt><b>special</b></tt> statement is followed by more than one curve, the resulting trimming, hole, or special curve is pieced together by concatenating the given curves. The <i>min</i> and <i>max</i> parameters allow using only part of the curve referenced. <i>min</i> and <i>max</i> must  be in the range of the parameter vector of the curve which in turn must be mapped into the parameter range of the surface. The <i>min</i> and <i>max</i> parameters of two different curve pieces are independent, they only depend on the curve parameter lists. For example, a trimming curve can be built from two curves, using the first three quarters of the first curve and the last three quarters of the second curve: 

<p><pre>
    curve "trim1"
            "bez1" 0.0 1.0 2.0 3.0 4.0
            0 1 2 3 4

    curve "trim2"
            "bez1" 0.0 1.0 2.0
            3 5 0

    surface "patch1" "mtl"
            "bez3" 0.0 1.0        0.0 1.0
            "bez3" 0.0 1.0        0.0 1.0
            6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
            trim "trim1" 0.0 3.0
                 "trim2" 0.5 2.0
</pre>


<p>Both trimming curves use the basis <tt><b>bez1</b></tt>, which is assumed to be a degree-1 linear curve. Hence, <tt><b>trim1</b></tt> connects the UV vertices 0, 1, 2, 3, and 4 with straight lines, and <tt><b>trim2</b></tt> connects the vertices 3, 5, and 0. If these two curves are put together by the <tt><b>trim</b></tt> statement in the surface definition, all parts of the surface that fall outside the polygon formed by the UV vertices 0, 1, 2, 3, and 5 are trimmed off. The <tt><b>trim2</b></tt> curve includes vertex 0 to close the trimming curve. Holes<a name=iHAH></a> (see <a href=scene.html#iHAE>hole curve</a>)  and <a name=iHAI></a><a href=scene.html#iHAF>special curve</a>s are constructed exactly the same way.  Trimming curves and holes must form closed loops but special curves are not restricted in this way. 

<p>This example omits the vector and vertex parts of the group in the object. Here is an example that defines a complete object containing a surface with a <a name=iHAJ></a><a href=scene.html#iHAD>trimming curve</a> that precisely follows the outer boundary.  A trimming curve that follows the outer surface boundary does not actually clip off any part of the surface, but it is still useful if surfaces are to be connected, because connections work on trimming curves. 

<p>
<p><pre><tt><b> </b></tt>   object "mysurface" 
        visible 
        basis "bez1" bezier 1 
        basis "bez3" bezier 3 
        group 
            <i>16 vectors used for the surface</i> 
            0.0 0.0 0.0         # vector number 16 
            1.0 0.0 0.0         # vector number 17 
            1.0 1.0 0.0         # vector number 18 
            0.0 1.0 0.0         # vector number 19 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           <i>16 vertices used for the surface</i> 
            v 16                # vertex number 16 
            v 17                # vertex number 17 
            v 18                # vertex number 18 
            v 19                # vertex number 19 
 
</pre><p> 
<p><pre><tt><b> </b></tt>           curve "trim1" 
                "bez1" 0.0 0.25 0.5 0.75 1.0 
                16 17 18 19 16 
            surface "surf1" "material" 
                ... 
                trim "trim1" 0.0 1.0 
        end group 
    end object 
 
</pre><p> 

<p>The trimming curve in the example is linear, using a degree-1 B&eacute;zier basis. This means that the <a name=iHBA></a><u>parameter vector</u> has five equally-spaced parameters, one for each corner in counter-clockwise order and back to the first corner to close the trimming curve.  Trimming and holes always require a closed curve or sequence of curves  (they can be pieced together by multiple curves as long as the pieces form  a closed loop together). The results are undefined if trimming or hole loops are not closed, or intersect. 

<p>If the trimming curve would be a degree-3 B&eacute;zier going through four corner points, a parameter vector with <i> 3 *5 + 1 = 16</i> parameters would be required (again, the <i> 5</i> is the number of corners visited including the return to the first to close the curve). 

<p>For details on the parameter vector following the basis name in the definition of the curve, refer to the section on curves above. The bases and parameter  vectors for curves and surfaces follow the same rules, except that curves have  no explicit range; they always use the implicit range given by the parameter list. 

<p><p><a name=cBG><h4>Approximations</h4></a> 

<p>Approximations<a name=iHBB></a> are defined within a <a name=iHBC></a><u>group</u> and they specify how previously defined surfaces and curves should be tessellated. Approximation statements are given separately for the surface itself and for the trimming curves used by the surface. In both cases, the names of one or more surfaces are named; ``trim'' approximations apply to all trimming, hole, and special curves used by the named surface. Approximation statements never name a curve directly. There are three surface and three trim approximation methods: 

<p><a name=iHBD></a><a name=iHBE></a><a name=iHBF></a><a name=iHBG></a><br> 
<p><pre>     <tt><b>approximate surface parametric</b></tt> <i>u_subdiv</i> [ <i>v_subdiv</i> ] <tt><b>"</b></tt><i>surface_name</i><tt><b>"</b></tt> ...
     <tt><b>approximate surface spatial</b></tt> [ <tt><b>view</b></tt> ] <i>edge</i> [ <i>min<sub>int</sub></i> <i>max<sub>int</sub></i> ] <tt><b>"</b></tt><i>surface_name</i><tt><b>"</b></tt> ...
     <tt><b>approximate surface curvature</b></tt> [ <tt><b>view</b></tt> ] <i>dist angle</i> [ <i>min<sub>int</sub></i> <i>max<sub>int</sub></i> ] <tt><b>"</b></tt><i>surface_name</i><tt><b>"</b></tt> ...
 
</pre><p> 

<p>
<p><pre>     <tt><b>approximate trim parametric</b></tt> <i>subdiv</i> <tt><b>"</b></tt><i>surface_name</i><tt><b>"</b></tt> ... 
     <tt><b>approximate trim spatial</b></tt> [ <tt><b>view</b></tt> ] <i>edge</i> [ <i>min<sub>int</sub></i> <i>max<sub>int</sub></i> ] <tt><b>"</b></tt><i>surface_name</i><tt><b>"</b></tt> ...
     <tt><b>approximate trim curvature</b></tt> [ <tt><b>view</b></tt> ] <i>dist angle</i> [ <i>min<sub>int</sub></i> <i>max<sub>int</sub></i> ] <tt><b>"</b></tt><i>surface_name</i><tt><b>"</b></tt> ...
 
</pre><p> <br> 

<p>The dots indicate that there may be more than one <i>surface_name</i> following the approximation statement. The given approximation is then used for all named surfaces. 

<p><b>Parametric approximation</b> subdivides the surface into <i>u_subdiv *degree</i> equal-sized pieces in the U parameter direction, and <i>v_subdiv *degree</i> equal-sized pieces in the V parameter direction. If <i>v_subdiv</i> is omitted, it defaults to <i>u_subdiv</i>. Note that the factor is a floating point number, although a patch can  obviously only be subdivided an integral number of times.   For example, if a factor of 2.0 is given and the surface is of degree  three, each patch will be subdivided six times in each parametric direction.   If a factor of 0.0 is given, each patch is approximated by two triangles. 

<p>Curves are subdivided in <i>subdiv *degree</i> equal pieces. 

<p>

<p><b>Spatial approximation</b> subdivides the surface or curve such that no edge length of the tessellation exceeds the <i>edge</i> parameter. <i>edge</i> is given as a distance in camera space, or as a fraction of a pixel diagonal in raster space if the <tt><b>view</b></tt> keyword is present.  The <i>min</i> and <i>max</i> parameters, if present, specify the minimum and maximum number of recursion levels of the adaptive subdivision. 

<p><b>Curvature-dependent approximation</b> specifies the maximum distance <i>dist</i> between the tessellation and the actual curve or surface, and the maximum angle <i>angle</i> between normals of adjacent tiles of the  surface tessellation or between tangents of adjacent segments of the curve  approximation. As a starting point, a small distance such as 0.1 and a large angle such as 45.0 is recommended. The value of <i>dist</i> is a distance in camera space, or a fraction of a pixel diagonal in raster space if the <tt><b>view</b></tt> keyword is present. The <i>min</i> and <i>max</i> parameters, if present, specify the minimum and maximum number of recursion levels of the adaptive subdivision. 

<p>If no approximation statement is given the parametric technique is used as a default with <i>u_subdiv = v_subdiv = 1</i> for surfaces, or <i>subdiv = 1</i> in  the case of curves. 

<p>

<p><p><a name=cBH><h4>Connections</h4></a> 

<p>Connections may be defined within a group to specify the <a name=iHBH></a><u>connection</u>  between two surfaces along intervals of their respective <a name=iHBI></a><a href=scene.html#iHAD>trimming curve</a>s.  They may be used in place of or in addition to the <a name=iHBJ></a><u>edge merging</u> performed  on the group level.  A connection is defined as: 

<p>
<p><pre><tt><b> </b></tt>   connect "<i>surface_name<sub>1</sub></i>" "<i>curve_name<sub>1</sub></i>" <i>min<sub>1</sub></i> <i>max<sub>1</sub></i> 
            "<i>surface_name<sub>2</sub></i>" "<i>curve_name<sub>2</sub></i>" <i>min<sub>2</sub></i> <i>max<sub>2</sub></i> 
 
</pre><p> 

<p>This statement connects two surfaces <i>surface_name<sub>1</sub></i> and <i>surface_name<sub>2</sub></i> by connecting their trimming curves <i>curve_name<sub>1</sub></i> and <i>curve_name<sub>2</sub></i>. The curves are connected only in the range <i>(min<sub>1</sub> ...max<sub>1</sub>)</i> and <i>(min<sub>2</sub> ...max<sub>2</sub>)</i>, respectively. Only surfaces that have trimming curves can be connected by an explicit connect statement; for an example for a simple trimming curve that goes around the edge of a surface see the section on  curves above. Trimming curves used in connections must satisfy three conditions: 

<p> 
<ul>

<li>  The trimming curve or sequence of trimming curves must be closed. 

<p>
</ul>

<ul>

<li>  It does not matter whether the trimming curve is oriented clockwise or counterclockwise, but if a sequence of trimming curves is used all pieces must have the same direction. 

<p>
</ul>

<ul>

<li>  The trimming curves along the connected range must run in the same direction in 3D space. 

<p>
</ul>
The range values <i>min<sub>1,2</sub></i> and <i>max<sub>1,2</sub></i> must not exceed the range of the trimming curve segment as referenced by a <tt><b>trim</b></tt> statement of the corresponding surface.  The minimum value must be less than the maximum value; it is not possible to  satisfy the third condition by inverting the range. 

<p>

<p><p><a name=cBI><h4>Example</h4></a> 

<p>Here is an example of two surfaces that meet along one of their edges such that a gap remains. A connection is used to close the gap. The four control points defining the straight trimming curves that are connected are marked as #0, #1, #2, and #3; the control points of the second surface marked <tt><b>(*)</b></tt> have been modified slightly to create the gap. This is a complete .mi file that can be rendered directly. 

<p><pre>
    verbose on
    $include &lt;softimage.mi&gt;
    frame 1
    
    light "point" "soft_point" (
         "color"  1.0 1.0 1.0,
         "factor" 1.0)
         origin   140.189178 83.103180 50.617714
    end light
    
    view
         output "pic" "x.pic"
         focal 50.000000
         aperture 44.724029
         aspect 1.179245
         resolution 500 424
    end view
    
    material "mtl" opaque
        "soft_material" (
            "mode"          2,
            "shiny"         50.000000,
            "ambient"       0.500000 0.500000 0.500000,
            "diffuse"       0.700000 0.700000 0.700000,
            "specular"      1.000000 1.000000 1.000000,
            "ambience"      0.300000 0.300000 0.300000,
            "lights"        ["point"])
    end material
    
    object "obj"
        visible shadow trace
        basis "bez1" bezier 1
        basis "bez3" bezier 3
        group "example"
            0.314772    -3.204608   -7.744229
            0.314772    -2.146943   -6.932366
            0.314772    -1.089277   -6.120503
            0.314772    -0.031611   -5.308641    #0
            -0.660089   -2.650739   -8.465791
            -0.660089   -1.593073   -7.653928
            -0.660089   -0.535407   -6.842065
            -0.660089   0.522259    -6.030203    #1
            -1.634951   -2.096869   -9.187352
            -1.634951   -1.039203   -8.375489
            -1.634951   0.018462    -7.563627
            -1.634951   1.076128    -6.751764    #2
            -2.609813   -1.543000   -9.908914
            -2.609813   -0.485334   -9.097052
            -2.609813   0.572332    -8.285189
            -2.609813   1.629998    -7.473326    #3

            0.000000    0.000000    -5.000000    #0 (*)
            1.224400    0.561979    -6.081950
            2.134028    1.155570    -6.855258
            3.043655    1.749160    -7.628566
            -0.500000   0.700000    -6.000000    #1 (*)
            0.249538    1.115849    -6.803511
            1.159166    1.709439    -7.576819
            2.068794    2.303029    -8.350128
            -1.200000   1.000000    -7.000000    #2 (*)
            -0.725323   1.669719    -7.525073
            0.184305    2.263309    -8.298381
            1.093932    2.856899    -9.071690
            -2.000000   2.000000    -7.500000    #3 (*)
            -1.700185   2.223588    -8.246634
            -0.790557   2.817178    -9.019943
            0.119071    3.410769    -9.793251

            0.0     0.0     0.0
            1.0     0.0     0.0
            1.0     1.0     0.0
            0.0     1.0     0.0

            v 0  v 1  v 2  v 3  v 4  v 5  v 6  v 7
            v 8  v 9  v 10 v 11 v 12 v 13 v 14 v 15

            v 16 v 17 v 18 v 19 v 20 v 21 v 22 v 23
            v 24 v 25 v 26 v 27 v 28 v 29 v 30 v 31

            v 32 v 33 v 34 v 35

            curve "curve1"
                 "bez1" 0.0 0.25 0.5 0.75 1.0
                 32 33 34 35 32

            curve "curve2"
                 "bez1" 0.0 0.25 0.5 0.75 1.0
                 32 35 34 33 32

            surface "patch1" "mtl"
                 "bez3" 0.0 1.0        0.0 1.0
                 "bez3" 0.0 1.0        0.0 1.0
                 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
                 trim "curve1" 0.0 1.0

            surface "patch2" "mtl"
                 "bez3" 0.0 1.0        0.0 1.0
                 "bez3" 0.0 1.0        0.0 1.0
                 16 17 18 19 20 21 22 23
                 24 25 26 27 28 29 30 31
                 trim "curve2" 0.0 1.0

            approximate surface parametric 1.0 1.0 "patch1"
            approximate surface parametric 1.0 1.0 "patch2"
            approximate trim    parametric 1.0     "patch1"
            approximate trim    parametric 1.0     "patch2"

            connect "patch1" "curve1" 0.25 0.5
                    "patch2" "curve2" 0.0  0.25
        end group
    end object
    end frame
</pre>


<p>Note that the trimming curves <tt><b>curve1</b></tt> and <tt><b>curve2</b></tt> have a different orientation, one clockwise and one counterclockwise, because their control point lists are in a different order. This means that where both trimming curves run in parallel, they run in the same direction in 3D space, which is a required condition for trimming curves to be connected. The trimming curves must be closed (another condition) and so run around all four edges of the (square) surfaces. Since only one edge of each surface is connected to the other, the connection ranges select only one quarter (<i> 0.5 ...0.25</i> and <i> 0.25 ...0.0</i>) of each curve. 

<p><br>
 

<p><br> The example produces the following image, once rendered without and then with the <tt><b>connect</b></tt> statement: 

<p>    <img src="unconn_pic.ps.gif" alt="unconn_pic.ps.gif">
  <img src="conn_pic.ps.gif" alt="conn_pic.ps.gif">
  <br> 

<p><br>
 <p><hr>
<a href=index.html#contents>Table of Contents</a>
</body>
</html>
