Mip Maps in 3DS Max with Mental Ray

by Adnan Hussain

Download maxscript
mg_mr_tools_v02.zip

Mip Maps are pre processed texture maps for use in rendering. They take more hard drive space, but can help reduce processing by storing multiple,
preprocessed resolutions of the same texture in one file. This allows a renderer that supports them to quickly load the file and not waste time on preprocessing/filtering. In addition, renderers such as Mental Ray can load portions of these maps as needed and unload them at render time. In contrast,
3DS Max’s scanline renderer loads all maps into memory at once. Loading maps as needed can add to render times, but loading all maps at once on a scene with many large texture maps will choke or crash your software making it impossible to render the scene.

Mental Ray supports Mip Maps through a “.map” file format that can be converted to from various bitmap files (uncompressed TIF, TGA files, etc) using a utility it ships with called imf_copy.exe.

Unfortunately 3DS Max does not directly support the use of “.map” files in Mental Ray, so below I will describe a work around to use them in 3DS Max 2011.

1. Some Mental Ray Setup changes:

First you’ll need to edit a Mental Ray file called base_mix.mi in order to access the map type needed to use “.map” files. Go to:

C:\Program Files\Autodesk\3ds Max 2011\mentalimages\shaders_standard\mentalray\include\

(path may vary depending where 3DS Max is installed)

Copy the file base_mix.mi and create a backup as seen below:

Next we’ll open up base_max.mi and find the line:

gui_mib_texture_lookup2

Then add a hash or # symbol in front of the word “hidden” below it. This will load the Texture Lookup 2 Map into 3DS Max when you reload the program. We’ll need this to load our “.map” files into.

Note: If you later reinstall 3DS Max or need to render on other machines, be sure and copy this modified file to
the appropriate folder on each machine.

2. Create Mip Maps

Now that the tools we need are accessible in 3DS Max and we have reloaded it, we can create our Mip Maps. For this purpose, you can use a script I created.

Download maxscript
mg_mr_tools_v02.zip”>mg_mr_tools_v02.zip

Locate imf_copy.exe. We need to locate the executable file that comes with Mental Ray to convert maps into the .map (mip map) format used by the renderer.

In 3DS Max 2011, this can be found in:

C:\Program Files\Autodesk\3ds Max 2011\mentalimages\imf_copy.exe

(path may vary depending where 3DS Max is installed)

In older versions it was not available, but I have heard that the XSI and Maya demos come with it. You may be able to get a hold of it by downloading one of those demos.

Now that we have confirmed that we have the imf_copy.exe file and we know the path where it lives, let’s run the script.

Download maxscript
mg_mr_tools_v02.zip”>mg_mr_tools_v02.zip

Just unzip the file and Run it in 3DS Max.

Create Mip Maps

Map Src Path: Path where bitmaps to be converted live and where the new  .map files will be created. Don’t type the filename, just a path.

imf_copy Path: Path where the imf_copy.exe exists. Don’t type the filename, just a path

Filter: You can leave it as “*”, or choose from a number of file extensions in the pulldown to limit what you convert.

Sub Folders Checkbox: When checked, files in subfolders will also be converted.

flags: Add optional flags to be used with imf_copy.exe. Leave the default “-vrp” if you are unsure.

Del Src: Deletes Source files (jpg, tga etc)

Ovw Trg: Overwrites the target file (if map files exists, overwrites them).

Create: With your settings filled in, click Create to start creating .map files for any bitmap files that don’t already have them.

Bitmap to Map Changer

Change: This button goes through all BitmapTexture maps in the scene and replaces them with Mental Ray Texture Lookup 2 maps containing the corresponding .map file if it exists.

Reverse: Changes map files back to bitmaps.

Make Scene Matlib

Make Scene Matlib: This creates a temp material library in the Material/Map Browser containing all scene materials, which you can save manually. Useful for keeping a set of materials with BitmapTexture and one with .map files.

Mat Changer

I use this to take a set of materials made for one character and apply it to another. This is more name dependent so it may not work for everyone. Material libraries need <src_char>_map or <src_char>_bmp names. Swaps the src string for trg string in each filename.

Src Char: Source String

Trg Char: Target String

Mtl_Type: Map or Bmp (Looks for matlibs named <src_char>_<Mtl_Type>)

Mat Path: Folder containing your matlibs.

Render Setup

In your Mental Ray render settings, under Processing set the Memory Options to the following.

This will allow you to take advantage of Mental Rays Object and Texture loading efficiencies. That’s all, now you can render scenes with more textures and geometry than you could before.

In Case you want to know how this works for your own customizations, here are some manual instructions to do what the script does to create .map files. You don’t need to do any of this if you use the script.

Manually Creating Mip Maps

Additional Scripts and Information by
others:

Mip Maps on Wikipedia
Neil Blevins Mip Maps Wishlist

David Baker’s Mental Ray .Map Converter Maxscript
MentalScriptologist’s Swap BitmapToMap Maxscript

Add your thoughts