MipMapping

Perspective Checkered Floor
Checker floor

Why filter file textures?

In a Perspective view of a plane (receding to a vanishing point), a single pixel in the final image may correspond to thousands of pixels in the source checker pattern. Determining the final color for a single pixel would require an immense computation. To reduce the amount of work required to compute the final pixel color, a technique called MipMapping was developed to produce quicker filtering.

MipMap filtering in Maya means that Maya stores multiple resolutions of the same texture. For example, if you have a 512x512 image, Maya stores the 512x512, then 256x256, then 128x128, then 64x64, then 32x32, etc.

Note: Storing such multiple resolutions means that it is most optimal for the MipMap to deal with square resolutions that are a multiple of 2 (meaning 2Ax); i.e. 1024x1024, 512x512, 256x256, etc. This is particularly truc for Bump Maps, though close to square resolutions still produce very respectable results. Extreme non-square ratio textures may cause problems.

The renderer chooses the appropriate level of file texture image to use based on how much screen coverage there is and how obliquely the object is being viewed. The further away or more oblique, the more the Tenderer tends to use a lower-res/blurry version of the texture. (In general the Tenderer is getting texture values by interpolating between two levels of the MipMap). This helps the renderer by reducing the amount of work it needs to do to resolve the final color of a pixel.

How does it affect the image quality?

In terms of quality, the filtering acts like a form of anti-aliasing for textures. By using lower resolution versions of a texture, the resulting pixel colors are more of an average of the surrounding colors on that texture map. This lends to a somewhat blurry look to the receding parts of the textured surface in the rendered image.

However, the upside is that this "averaging" prevents detectable shifts in color for a single pixel from frame to frame. If the resulting distant pixel colors were very precise at all times, you would see very noticeable texture crawl or shimmering during animation because the same pixel could have very different colors from frame to frame, depending on the viewing angle.

The trick is to strike the right balance between the sharpness of the texture in the final render vs. the amount of crawling in the texture during animation.

Tip: When particular file textured surfaces are crawling, shimmering, flickering, etc. over an animation, it is best NOT to play with the antialiasing shading samples first. The first choice would be to play with the file texture's filter attribute values.

The Filter Size is internally computed by Maya based on the above mentioned criteria (how much screen coverage there is and how obliquely the object is being viewed). The Filter and Filter Offset under the Effects section are attributes that can be used to alter the results that Maya calculates.

Tip: It is not recommend that the Filter be set to 0. Setting Filter to 0 or a very small value will tell the renderer to ignore the internal filter size computation. This will force the renderer to use the highest level of the MipMap.

Higher order filter types

In some situations, adjusting the Filter attribute values will not help. When this situation occurs, the more optimal solution would be to employ a higher order filter, such as the Quadratic Filter. The Quadratic Filter does more computations in projecting screen pixels to texture space, thus resulting in much cleaner results. This is the Maya default filter type.

Pre-Filtering file textures

The Pre-Filter and Pre-Filter Radius attributes found under the File Attributes Editor, are used to correct file textures that are aliased or contain noise in unwanted areas. When Pre-Filtering is on, the image file uses a Gaussian type filter to get rid of noise and aliasing, contributing to a better quality image. The Pre-Filter Radius will determine the size of the filtering radius. The default value of 2.0 works for most images, but you can increase the radius to provide even smoother results. This can be particularly useful when Bump or Displacement Mapping.

Block ordered textures and caching

In the Attribute Editor for file textures, there is an attribute called Use Cache. This attribute can be used as an optimization if you are finding that your renders are running into swap space. Using swap is very slow so you want to avoid this.

By turning Use Cache on, you use a lot more disk space but less memory. This is because the renderer does not need to keep whole textures in RAM during the render. Instead, it uses tiles of the texture called BOT files as it needs them. BOT stands for Block Order Textures.

BOT are enabled by turning Use Cache on for each file texture. If this flag is on and the file textures are not already BOT format files, then Maya will automatically create BOT textures from the image files and store them in the TMPDIR at render time.

The file textures can be pre-converted to BOT by using the makebot MEL command:

makebot -i "in_image" -o "out_bot_file";

Chapter 2

Block ordered textures and caching

In this case, the resulting BOT files can be stored in a directory you specify. For example:

makebot -i "in_image" -o "/usr/tmp/out_bot_file";

Once the BOT files are created, you need to change the path and name in the file texture's Attribute Editor to point to the BOT files. If the textures are already in BOT format, this saves time at the start of the render. It also allows you to know how much disk space is being taken up by the BOT files on disk before you start rendering.

Technical details

A BOT texture on disk is a compressed MipMap structure with 8x8 texel pages. A texel is a texture element derived in much the same way as pixel is a picture element. The textureCache is a 256 texel page cache in memory; that is, it can hold 256 of the 8x8 texel pages. There is only one textureCache for the entire rendering session and the cache is shared between all file textures.

TVrK

BOT file (on disk)

A

A

256 slots

textureCache (in Memory)

BOT files and texture caching textureCache (in Memory)

BOT files and texture caching

The textureCache is demand loaded. When part of a texture is required, if it is not already in the cache, it is loaded from disk. If the textureCache is full, the least recently accessed pages are removed and replaced with the pages being loaded.

BOT textures have the advantage of reducing the amount of memory required to keep textures in memory. If the image file has already been converted to a BOT texture file, the Maya renderer can use it much more quickly than when it has to convert the file to BOT texture on its own.

BOT textures do have some limitations as well. If multiple Tenderers/ processors are using the same BOT file, there can be an I/O bandwidth problem which will cause all the Tenderers to slow down (having a copy of the BOT texture for each processor is about the only work-around). If the image files are not BOT texture files to begin with, then TMPDIR can get full quickly with all of the temporary BOT files.

If different shading networks reference the same file texture image, a single copy of the image is kept in memory and shared by all the shaders.

BOT files and pre-render optimization

There is a command that creates smaller and more efficient Maya binary files reserved for rendering. By deleting information not relevant to the renderer, these "leaner" files can help reduce overall memory used and decrease render times. To do this, run your files through Optimize Scene Size with all the flags checked On. BOT files are created and relinked (texture assignment). Information used to edit the scene is deleted.

Tip: For Maya files with file referencing, it is best to export all first otherwise some optimizations may be missed.

The usage for this pre-render setup is straightforward. Use maya -optimizeRender -help, for a list of flags and descriptions for this command.

DISPLACEMENT MAPPING

Sometimes, rather than modeling the details of a surface, it is more convenient to use a Displacement Map. Displacement Mapping uses a texture to alter the shape of geometry. This is different than a Bump Map which simply alters the surface normals to create the illusion of surface relief.

Displacement

Displacement vs. Hump Map

Chapter 2

Displacement Mapping in Maya

0 0

Post a comment

  • Receive news updates via email from this site