Memory management is often forgotten in today’s high speed multi core & high RAM systems, but it still plays a crucial role in the optimization of rendering 3D animations. It is a very important factor in the process of animation, especially with more complex lighting, material solutions and high poly scenes (inc. bump/displacement maps). Its something that isn’t easily approached by the casual 3d modeler/animator, but luckily, the Gnomon Maya Mental Ray Fundamentals educational DVD shed some light on some memory management methods and techniques, and now I’ll record them here for my own memory (and potentially your education!
).
What is BSP and how do I find out how it affects my scene?
The controls for Mental Ray’s memory management fall under something called BSP – Binary Space Partition. Basic explanation of BSP is the breaking up of the models polygons to be managed more efficiently by Maya’s render engine to optimize the RAM usage, therefore increasing efficiency on rendering and therefore SPEED. This alone is worth the effort to learn how to use the BSP settings to your advantage… Before you start tweaking with the BSP settings, you need to see how efficient your scene file is in the first place.
To do a diagnosis, jump into the mental ray settings in the render settings window, expand “Diagnostics” and change the dropdown box “Diagnose Bsp” from Off to Depth. Open up the Mental Ray Globals tab (type ‘select mentalrayGlobals;openAEWindow‘ in script editor and run the script), and change “Render Verbosity” dropdown to Progress Messages. This just ensures you get the correct feedback in the Output Window. Keep in mind that all of your output information will be displayed in the Output Window – for some reason I thought everything was displayed in the script editor, so be aware of this. You need to look for what is displayed below in the Output Window…
RCI 0.3 info : main bsp tree statistics:
RCI 0.3 info : max depth : 35
RCI 0.3 info : max leaf size : 7583
RCI 0.3 info : average depth : 21
RCI 0.3 info : average leaf size : 111
RCI 0.3 info : leafnodes : 3284
RCI 0.3 info : bsp size (Kb) : 865
This information will be what you will be basing your decisions and tweaks on. So now you know how to access your BSP statistics to tweak the settings, we can start tweaking and optimizing the memory usage for the scene. Just before we move on, the parts of the statistics shown that we will be focusing on with our tweaking is the average depth and average leaf size, this will be explained more in the next coming paragraphs.
Tweaking BSP Settings to decrease render times
You may ask: ‘how do I know if I need to tweak the BSP settings?’. My response is, it doesn’t harm to have a look at the settings already. The settings of the BSP can be found in the mental ray tab of the render settings under > Raytracing > Acceleration. To answer the question anyway, generally if the ‘average leaf size’ in the render output (as shown above) is much higher than the leaf size specified in the Acceleration (BSP settings) section, then tweaking will most likely be needed.
Generally, the lower the value of the BSP Size (leaf size), the faster the render will go. Although, this will mean that there is more memory usage, and it works vice versa (higher BSP size, slower render but less RAM use). If the average leaf size in the output window is relatively large, this is an indicator that the BSP depth in the render settings is too low. If the BSP depth value is too low, it will SLOW the render down. Be aware of this – try and increase the BSP depth and lower the BSP size (leaf size), for example if you were on 15 & 30, try 10 & 40 in the boxes and run the render again.
Be aware you will not notice any big differences on simple scenes!!
Keep playing with these settings and keep an eye on the render time displayed. There will come a point where there is no major change in render time taken, or that you are actually INCREASING render time. This is your indicator that you have reached the correct values, so revert back to the lowest render time values if the time does increase after new settings. Rough rule is: For small scenes, use BSP Depth of 30, medium scenes use BSP Depth of 40, and for large scenes use BSP Depth of 50-60. Example outputs which look better than previous outputs:
RCI 0.3 info : main bsp tree statistics:
RCI 0.3 info : max depth : 45
RCI 0.3 info : max leaf size : 3376
RCI 0.3 info : average depth : 40
RCI 0.3 info : average leaf size : 28
RCI 0.3 info : leafnodes : 29807
RCI 0.3 info : bsp size (Kb) : 311
The average leaf size is much smaller than before, therefore render speed is increased as the memory management is more efficient. This post may sound a little confusing but have a play with the settings, and watch the changes. Don’t forget once you have optimised the render times to turn off Diagnose BSP in Diagnostics in MR render settings. PLEASE MAKE SURE YOU CHECK THE RENDER TIMES OF THE ACTUAL FRAME. You may notice your BSP tweaks aren’t reflecting the render time of the actual image, so make sure you check all of the render times.
Last note – in the “Acceleration Method” in the Acceleration section of MR render settings, Regular BSP is used mostly for normal scenes, if you have intense scenes use Large BSP, it creates a larger BSP tree but will allow you to render extremely complex scenes.
Last tip is to make sure your Mental Ray is taking advantage of the most memory you can – Open mental ray globals (script editor code as before), expand Memory and Performance, and Memory Limits. Have a look at the physical memory in the box, and make sure it is taking advantage of the memory you have installed on your system. If you change the value to a higher value, make sure you leave at least 1 gig of RAM for the operating system. I have 8gb in my system, and the Physical Memory value written is 5821 – I’ll leave it as this as I do like to use other programs while rendering…
I will revisit this post with an extra couple of tips for memory management including the use of .map texture files. For now I’ll leave it here!!!
Good luck!
- Jarrad
Resources to enhance – explains graphically the job of BSP
http://toi.bk.tudelft.nl/toi-pedia/index.php?title=MR_Using_BSP_Diagnostics
http://www.animationxpress.com/anex/y2k8/headlines/anex3941.htm