MantraOptimizations

From Odwiki

Jump to: navigation, search


Contents

How to speed up your Mantra renders

If you have a particular scene that renders very slowly, please write down your case here and we'll add advice to how to speed up your renders.


Scene: Lots of semi-transparent objects stacked up on one another.

Optimization: Mantra supports an opacity limit, which is an opacity value to stop accumulating at (for each ray from the camera). Why is this important? If you have many planes of 50% opacity stacked up on each other, the opacity will never truly reach 1 (full opacity). It will get closer and closer but never quite get there. Mantra, by default cannot rightly bail out just in case you have a really really bright object behind these planes which might show through them. If you know you don't have such a case, set your opacity limit in your MantraROP to something like .98 and you could speed up your renders substantially.

Scene: Raytracing (even FastShadow raytraced shadows) in a scene with objects which have displacement shaders.

The nature of RayTracing differs from MicroPolygon rendering in that it cannot perform smart view-based displacements - it has to be cautious and tesselate displacement-mapped geometry being traced against probably more than what is ultimately needed. This happens more often than not when you are displacing already-complex polygonal models.

Optimization: The first thing to do is to ask mantra to tesellate less by adjust the displaced objects' Raytraced LOD parameter in it's Objects Render tab. Set it way down to something like 0.1 and then adjust it up until you are getting the quality of result you are content with. This can speed up raytracing against these objects many times. The eye has a hard time figuring out whether reflections are valid anyway (hence the success of ReflectionMapping for so many years), but you might notice it more in crisp raytraced shadows. This might warrant switching your shadows to ShadowMapping.

General: Use bigger primitives

If you make an object using lots of polygons, mantra has to render _all the polygons. Even if you have 2,000 polygons which are crammed into 2 pixels by 2 pixels, mantra still needs to render all of those polygons.

Optimization: By using a higher order surface (i.e. one NURBs patch), mantra can adjust the Tesselation of the surface to better approximate the screen space real estate that the object occupies. If possible, use very simple primitives like spheres, tubes or circles over even NURBs surfaces.

Even if you are forced to use polygonal models, generating larger polygons and then rendering the surface as a SubdivisionSurface can be advantageous.

Caveat: If you have a very large single primitive (i.e. a big NURBs surface for a ground plane), mantra needs to split this primitive multiple times to get it to something it can handle in screen space. Occassionaly, if the geometry crosses the camera plane (like a ground plane would), mantra can run out of splits. This can cause rendering artifacts. To reduce these artifacts, you can use the CarveSOP to Tesselate the geometry into slightly smaller NURBs patches.

Scene: Lots of identical or similar objects

Take advantage of Instancing. If you have identical geometry all the better, but if you have similar objects like a flock of birds (where different birds flap at different rates), or field of trees or something then you should choose a few variations and randomly orient them using instancing. This takes a load off mantra and you will have faster renders (in the case of RayTracing - mantra is very efficient at raytracing against instances) and a much lower RAM usage. Please read more at MantraInstancing. Steer away from CopyStamping if you can.

General: Heavy RAT Image usage

If you use a lot of textures, the default texture memory of 32mb will be too low and you'll be wasting time reloading textures a lot. Increase it! See Rat for more info.

General: Several Flags that will Make Your Day

There are several options to Mantra that will speed things considerably, depending on the scene. The only caveat is, you have to balance things to make sure memory usage doesn't get out of control, which of course will then slow things back down.

Optimization: The -G flag.

This is the micro-polygon cache size. Basically, after micro-polygons have been created, if they are not needed they are thrown away. However, there are cases where even after they are thrown away, they are needed again. By increasing this value, you keep more micro-polygons around in memory so if/when they are needed again, they don't have to be recalculated. In some tests, making the -G value very large (1000000 or higher) shaved 20-30% off render times. WARNING This will use more memory! If you are using other memory-intensive options like the -M flag (see below) you will need to balance things.

Optimization: The -M flag.

This is the Ray Mesh Cache Size. When raytracing is used, Mantra has to calculate meshes to raytrace against. See the LOD info above. The -M flag allows you to keep in memory more of the pre-computed meshes, reducing the time needed to recalculate them if/when they are needed again. The default value is very low, you should almost always make this higher. Value above 65536 are not uncommon if you have a lot of memory on your computer. Some tests have shown a 2x-4x speed increase depending on the scene.WARNING This will use more memory! If you are using other memory-intensive options like the -G flag (see above) you will need to balance things.

Optimization: The -Q flag.

The -Q flag allows you fine control over what Mantra is doing. The most important and most commonly used flag is -QB which turns off raytraced motion blur. In scenes where you have a lot of motion blur on an object, and you are raytracing against it (shadows, ambient occlusion, reflections etc) setting this flag will result in a large speed increase with (usually) no noticable difference in the image. There are times when you want to turn this off, but usually you want it turned on.

© 2009 od[force].net | advertise