< PREVIOUS - TEXTURING

Rendering - with Mentalray

It's not just a click and let the computer do the calculations. Whey you create the complex scenes like this one many difficulties and problems may come. Not enough memory to render the scene was one of the main with this one. I have had 1 gb of memory in my comp which is not so small, but it was not enough ... specially when you try to render from maya. Scene, when loaded in maya took about 400 mb of ram, so in such cases forget about rendering directly from maya and stick to the command line. Let's pass through some usefull rendering stuff...

 

Resolution

It is up to you to pick the final resolution of the image, but remember, the higher the resolution, the more details will be visible. So this should be one of the first decisions that you have to make when creating 3d pictures. For this one I have used 1280x960 resolution which is pretty big since the target media is internet. Why 960 you ask and not 1024... well because the proportions of this resolution is standard 4:3, like 800x600, or 1600x1200. If you want to work in some other resolution like 1280x600, when you type this resolution in mentalray tab the pixel aspect ratio will automaticaly change, which is what we don't want, and since it is faded you can not set it back to 1. But there is a little trick .... switch to maya render, then set the pixel aspect to 1 and then go back to mentalray.

The usual problem, when using higher resolution to render image, can appear in the textures that you use. I don't mean procedural ones, but image maps. If they are low resolution then they can apear blurry with lack of details. That's why you have to have this in mind when creating image maps.

 

Samples and Filtering

In this particular image I have set the sampling to min 0 and max 2 . This means that mentalray will take minimal 1 sample per pixel and maximum 16. Since this is the still picture it is enough. One more thing that is tightly connected to the sampling is the contrast threshold value. By setting the lower threshold value you tell renderer to use more samples when needed. For example if the value difference between two nearby samples is 0.2 and the threshold is set the 0.1 then mentalray will use more samples to sample this area until the difference drops below 0.1. But, the depth of this division is bounded by the max samples value. So if the threshold value is not reached and mentalray already sampled the pixel with 16 samples then it will stop and go to the next pixel. That's how these things work.

In my case, as I mentioned before, max sampling set to 2 is enough for final render. But in cases where you do the test render you can drop this to min -1 and max 1, and set the threshold to 0.2 This will save a lot of precious (my precious ;) ) time when rendering.

The filtering is another very usefull and evident thing. What it does is that it, as the name says, filters samples collected when reconstructing one pixel of the image. There are five types of filter in mentalray. The default one is box... the faster of these ones but not so good like some others. For my image I have used the Mitchell filter. The image rendered with this filter will look a little sharper compared to gaussian but less sharper compared to Lancos. There is fine explanation in mentalray manual about these filters.

 

Raytracing

This is not very raytracing intensitive scene when it comes to reflection and refraction. There are only few refractive and reflective elements in the scene, but there are many lights that uses raytraced shadows, so this will be the main concern of raytracing engine. Because of that I have set the reflections to 1 and refractions to 2. This means that when the light is shot from the camera to trace the value it can be refracted two times until it returns the value. This will not be enough in cases when you have the scene with lots of refractive glass objects, but in this situation it is enough.

 

BSP acceleration

The binary space partitioning is mentalray algorithm to accelerate the raytracing calculations in the scene. It consumes memory but the speed increase, when using it, can be drastically. The BSP algorithm, as I understand, divides the scene with the bounding boxes or voxels that are recursively created around the bunch of polygons. So, for example when you set the BSP size to 10 that means that mentalray will try to divide the space with voxels so many times needed to bound the 10 polygons in one of these voxels. The other value, BSP Depth limits the depth of that BSP divisions. So for example if BSP Depth is set to 50, and BSP has divided the space 50 times but it still has the 40 polygons in one voxel it will not divide it further since it reached max depth which was limited to 50.

The values that I have used in my image were 16 for the Size and 45 for the Depth. This means that BSP will be subdivided maximal 45 times to try to reach the 16 polygon in one BSP Box. I have also set the Large BSP options for the memory sake reasons. The BSP when it is created takes a lot of memory, and what Large BSP does, is that it caches some part of that BSP tree on the hard disk and frees up the main memory to do the other calculations. Once the renderer needs the information about the part of BSP Tree in rendering process it will load the cached BSP from drive to the memory and use it. According to mentalray manual this makes render a 20% slower, but it is necesary for the scenes like this one.

It's best to experiment with these values. For one scene, for example, the best values will be 10 50 ... in some other maybe 14 45 or 8 40 ... you will never know if you don't try it. But remember, the BSP takes memory so don't go too low with size and too high with depth.

 

Memory Limit

In the same section (Memory and Performance) where BSP stuff is the memory limit needs to be set. Since I had 1 gb of ram I have set the limit to 800 MB. Do not let mentalray use all of your memory, since if it takes all of it, the memory segmentation problems may occur and mentalray can crash. That's why it is recomended to use the lower size of memory limit than the size of your memory.

 

Memory Mapped Textures

Another thing that I started to use when rendering with mentalray are memory mapped textures. This is nothing else but the textures converted to special mentalray image format which can be internaly read by mentalray without the need to convert it. For example if you have 10 textures in jpg format which are applyed to the object you are rendering, all of these textures need to be loaded to main memory and decompressed, and then mentalray can use them. But when you do the conversions by yourself, then try to render the image, mentalray will directly acces these textures without the need for the task of decompressing, and save a lot of memory and time. There is a simple script that my friend Tom created at the company I am working in ... and what this script does is that it collects all information about the image textures in the scene, converts them to the .map format and copies them to the sourceimages/ directory.

DOWNLOAD THE SCRIPT

Just copy the script to the Maya/Scripts/others directory. Once you need it just go to the script editor, click file > source script and '2map.mel'... this will ignite the conversion process of all image maps that you have in scene. I don't know for sure from which format can be converted to map, but I know that it can handle JPG, TGA and TIFF. You can also do the conversion manually. Just go to the directory where your image is (jpg, tif, tga...) and type:

imf_copy imagename.jpg newimagename.map

... and you will get the converted texture in the same directory with the .map extension.

 

Z Depth Chanel

To turn on the Z depth rendering, just go to the MentalRay render globals and in Common menue check the Depth Chanel flag. If you are rendering in the IFF format then the Z depth chanel will be created within the image file, but if you are rendering in some other format then the separate image file with z depth will be created. For this situation, and every other before I have used the standard IFF file format, which can be read by all respectable postprocessing softwares.

 

Rendering from Command Prompt

When you prepare the scene for rendering, quit the maya and jump to the command line. I would suggest, when rendering scenes that eats memory, close every program that you can, to free up some mem. When you are in the directory where your maya scene is just type:

mayarender_with_mr scenename.mb

and the rendering process will start. When it does you can follow the rendering process by going in the directory where you rendered picture will be, find the file in which mentalray is rendering ... this file usually has 128bytes size and type:

imf_disp nameoftheimage.iff

and it will display the rendering progress of the image.

< PREVIOUS - TEXTURING