Keywords: main

Next: 1.13 Memory-mapped Textures Up: 1. Functionality Previous: 1.11 Shadow Maps

# 1.12 Texture Mapping and Texture Files

mental ray supports texture, bump, displacement and reflection mapping, all of which may be derived from an image file or procedurally defined using user-supplied shaders. Although there are various support functions provided by the mental ray shader interface, all these functions are fully implementable in shaders.

Procedural textures are computed by shaders, while image textures are read from image files. In practice, textures are a combination of both methods: a procedural texture shaders accepts an image texture parameter, which it accesses to read and filter pixels, and then modifies it according to other parameters to implement projections, scaling, cropping, replication, and other common operations on texture images. Purely procedural texture shaders that do not rely on texture images at all also exist, for example marble or cloud shaders. Some shaders use textures for special purposes; for example, a fur shader that computes hair in a volume might use a texture image to control the hair length or brushing direction.

The following table lists the file formats accepted by mental ray for reading texture image files:

format | description | colormap | compress | comp. | bits/comp.
rla/rlb | Wavefront image | -- | RLE | 3, 4 | 8, 16
pic | Softimage image | -- | RLE, -- | 3, 4 | 8
alias | Alias image | -- | RLE | 3 | 8
rgb | Silicon Graphics color | -- | RLE, -- | 3, 4 | 8
jpg | JFIF image | -- | JPEG | 3 | 8
tif* | TIFF image | -- | RLE, -- | 1 | 1, 4, 8
|  | -- | RLE, -- | 3, 4 | 8, 16
|  | -- | -- | 3, 4 | float3.x
|  | yes | RLE, -- | 3, 4 | 4, 8
iff | Maya IFF image3.1 | -- | RLE, -- | 3, 4 | 8, 16
picture | Dassault Systèmes PICTURE | -- | RLE | 3 | 8
hdr | Radiance RGBE3.1 | -- | -- | 4 | 8
ppm | Portable pixmap | -- | -- | 3 | 8, 16
tga | Targa image | -- | RLE, -- | 1, 3, 4 | 8
|  | -- | RLE, -- | 3 | 5
|  | -- | RLE, -- | 4 | 5/1
|  | yes | RLE, -- | 3, 4 | 8
bmp | MS Windows/OS2 bitmap | -- | -- | 3, 4 | 8
|  | yes | -- | 3, 4 | 1, 4, 8
qnt | Quantel/Abekas YUV image | -- | YUV | 3 | 3
ct* | mental images texture | -- | -- | 4 | 8, 16, float
st* | mental images alpha texture | -- | -- | 1 | 8, 16
|  | -- | -- | 1 | float3.1
vt/wt | mental images basis vectors | -- | -- | 2 | 16
zt | mental images depth channel | -- | -- | 1 | float
nt/mt | mental images vectors | -- | -- | 3 | float
tt | mental images tag channel | -- | -- | 1 | 32
bit | mental images bit mask | -- | -- | 1 | 1
map | memory mapped textures | -- | -- | any | any

In the table, any combination of comma separated values determines a valid format subtype. For example, the SGI RGB image format will be read when the data type is 8 bits per component with or without alpha, either RLE compressed or uncompressed. The actual image format is determined by analyzing the file content, not just by checking the filename extension. This allows replacing texture files with memory-mapped textures without changing the name, for example. The asterisk (*) indicates omission; for example, ct* includes ctfp and ct16.

Typical image types like black/white, grayscale, colormapped and truecolor images, optionally compressed, are supported. Some of them could be used to supply additional alpha channel information (number of components greater than 3). The collection covers most common platform independent formats like TIFF and JFIF/JPEG1.3, special UNIX (PPM) or Windows bitmap (BMP) types and well known application formats. The mental images formats, normally created by mental ray itself, are mainly available to exchange data not storable with other formats. As a special case, mental ray allows storing RGBE3.1 data into file formats that accept RGBA.

A user-defined material shader is not restricted to the above applications for textures. It is free to evaluate any texture and any number of textures for a given point, and use the result for any purpose.

In the parameter list of the standard material shaders, a list of texture maps may be given in addition to, for example, a literal RGB value for the diffuse component of a material. The color of the diffuse component will then vary across a surface. To shade a given point on a surface, the coordinates in texture space are first determined for the point. The diffuse color used for shading calculations is then the value of the texture map at these coordinates. The SOFTIMAGE-compatible material shader uses a different approach; it accepts a single list of textures, with parameters attached to each texture that control the way the texture is applied to ambient, diffuse, and other parameters. The shader interface is extremely flexible and permits user-defined shaders to use either of these approaches, or completely different formats. The remainder of this section describes the standard shader parameters only.

The standard material shaders support texture mapping for all standard material parameters except the index of refraction. Shinyness, transparency, refraction transparency, and reflectivity are scalar values and may be mapped by a scalar map. Most shaders use color maps to implement bump mapping by sampling the color map three times, but some shaders such as the Wavefront material shader accept a vector map that requires only a single sample.

Color textures are normally not implemented in the material shader but in a separate texture shader, which is then referenced by the material shader. This separation of work between material and texture shaders allow more flexibility because any texture shader to be combined with any material shader, without having to program any new combination in a new material shader. Also, texturing does not have to be programmed into every material shader parameter. Instead, the material shader offers simple parameters like ``diffuse'', ``ambient'', ``transparency'', ``shinyness'', and so on. Each parameter may be assigned a static color such as ``white'', or it may be attached to a texture shader. Even if the material shader was never programmed to accept textures, all aspects of its operation for which it has a parameter become texturable. In fact it is possible to build whole multilevel graphs of shaders using parameter assignment.

Shaders that do all the work internally are called monolithic shaders, while shaders designed for easy graph building are called base shaders.

Determining the texture coordinates of a point on a surface to be shaded requires defining a mapping from points on the surface to points in texture space. Such a mapping is itself referred to as a texture space for the surface. Multiple texture spaces may be specified for a surface. If the geometry is a polygon, a texture space is created by associating texture vertices with the geometric vertices. If the geometry is a free-form surface, a texture space is created by associating a texture surface with the surface. A texture surface is a free-form surface which defines the mapping from the natural surface parameter space to texture space. Texture maps, and therefore texture spaces and texture vertices, may be one, two, or three dimensional.

Pyramid textures are a variant of mip-map textures. When loading a texture that is flagged with the `filter` keyword, mental ray builds a hierarchy of different-resolution texture images that allow elliptical filtering of texture samples. Without filtering, distant textures would be point-sampled at widely separated locations, missing the texture areas between the samples, which causes texture aliasing. Texture filtering attempts to project the screen pixel on the texture, which results in an elliptic area on the texture. Pyramid textures allow sampling this ellipse very efficiently, taking every pixel in the texture in the ellipse into account without sampling every pixel. Pyramid textures are not restricted to square and power-of-two resolutions, and work with any RGB or RGBA picture file format. The shader can either rely on mental ray's texture projection or specify its own. Filter blurriness can be adjusted per texture.

A procedural texture is free to use the texture space in any way it wants, but texture files are always defined to have unit size and to be repeated through all of texture space. That is, the lower-left corner of the file maps to (0.0, 0.0) in texture space, and again to (1.0, 0.0), (2.0, 0.0), and so on; the lower-right corner maps to (1.0, 0.0),(2.0, 0.0),... and the upper right to (1.0, 1.0),(2.0, 2.0),....

#### Footnotes

... JFIF/JPEG1.3
  The JPEG software is based in part on the work of the Independent JPEG Group.

Next: 1.13 Memory-mapped Textures Up: 1. Functionality Previous: 1.11 Shadow Maps