Mental Ray Notes For Maya

Home 
 3D Art 
 2D Art 
 Contact 
 Resume 
 Bio 
Work In Progress
Rigging Demo

Hey.  When I learn new stuff I take pretty detailed notes to remind myself of what I learned from all the sources I will never be able to find again. I also prepare these notes to teach my co-workers what I have learned so the notes are pretty readable.

As you probably have found out for yourself maya’s documentation of mental ray, is… well … inconsistent. 

The notes are written as I learn what I am doing so they will have both advanced and rudimentary information.  I will be updating them as I learn more. Let me know if anything is unclear or needs more info Email Me


Enjoy the fruits of my labor you thankless bastards.

 




 

Baking Mental Ray Information
Lighting/Shading menu  Batch Bake (mental ray)
Bake Shadows and Use Face Normals
What this does is just create a new shading network that has all of the light info copied into the image file.  You may need to create a 2d placement node and adjust the mapping

 

Mental Ray Render Global Menu:

General Notes:For render verbosity, or to get progress reports on your render you need to go to the batch render menu and select the level of verbosity you want.

Diagnostics tab
The purpose of this is to get a visual representation of just what Mental Ray is thinking. 

 

Anti-Aliasing Quality Tab

Sampling Quality:  This effects not just the antialiasing of an image, but all things that must be calculated to create your render.  Mental Ray has the ability to adaptively sample an image to save time on rendering. That is to say that in areas of less detail or contrast the image will be sampled less because Mental Ray Recognizes that the area has little variation and so it will sample it less.  In areas of higher detail and contrast Mental Ray recognizes that there needs to be more sampling so it will up the amount of sampling. 
The values in the Number of Samples tab control the minimum amount of times and the area of the image that is sampled.  So what the values do is define the bracket that Mental Ray can span during the sampling process.  If Mental Ray looks at an area and decides it has little contrast (defined by the contrast value*) then it will use the Min sample level.  If Mental Ray looks at an area and decides that the area is of high detail and contrast then it will sample at the next higher value and again and again until it get to the Max sample level.

What is Sampling?
Sampling is the process of looking at the scene as the image is drawn during render. 
Think of it like taking tiny photographs of a little portion of your scene and then laying the photographs next to each other.

What do the Sampling Values do?
In order to understand sampling values we must understand sampling blocks.
Sampling Blocks are simply the regions that are being sampled. Think of it as the framing of a photograph that is taking the picture of a small region of your scene.
The sampling value defines the size of the region that is sampled.  Positive values translate to mean that a single pixel is sampled numerous times. The value that you give Mental Ray will define the amount of samples as the inverse of the given value squared. Negative numbers translate to mean that more than one pixel is sampled with a single sample. This region can range from 256 pixels per sample (-4) to 256 samples per pixel (4). 
This expression looks like this: if X is the value that you give Mental ray and Y is the number of samples (remember that negative values for Y will mean a broader frame or multiple pixels)
Y = - X2
So lets say that the value that Mental Ray is using is -2
So X = -2
So enter that into the function:    Y = -(-2)2
Y = - (4)
Y = -4 Here the negative value will have the effect of reducing the amount of times a single pixel is sampled below 1.  This translates into sampling a block of pixels that is 4X4 pixels.  If that didn’t make sense, don’t worry, you’re stupid, but that doesn’t mean you can’t use mental ray because the following is a breakdown of this concept.

The upshot is that your image will be smoother the higher this value is but will take longer to render. You should try to keep the min and max values as low as possible.  A good way to find the optimal setting for your scene is to start low, put your min sample at -4 and you max to 0.  Shoot a render.  If banding occurs in areas that should be smooth gradients you need to increase your min value, just go up until those areas are smooth.  Then look at areas that are high in detail and contrast, if you see jagged edges up your max value till they become smooth. (dua)

 

Contrast Threshold tab
are values that dictate at what level the image is sampled within the bracket of the Min and Max sample levels.  This process works by looking at the corners of the sampling block and comparing their color values with that of the surrounding blocks and if the difference between their values exceeds the threshold then the block is sampled at the next level and again and again until either the threshold is satisfied or the sampling reaches the Max sample level.
The higher this value the less likely a resampling is to occur.  If you find that your image does not seem to be dividing enough in places of high contrast then lower this value.  If your render is taking too long you may be able to cut time by increasing these values.

 

Shadows:
Raytraced shadows

Simple: This samples the objects and just applies a simple shadow to them, if overlapping shadows are present they will not be differentiated
Sort:  This will calculate objects closer to the light source first, overlapping will be considered
Segment:  This will calculate volume and particles as well as the sort features

 

Soft Ray Traced Shadows in Mental Ray:

There are a few ways to soften your raytraced shadows in MR. 

Light Radius:
On the light you can specify a light radius, the larger the radius the more falloff you will have in the shadow.  If the shadow is grainy you can increase the shadow rays.  This does not significantly increase render time and higher values definitely look better, you want to just go to the value that the image looks good at though, don’t go overboard for no reason.  Getting values up around 50 will yield some really great results, and by that time you will be looking at render times that near the following option, Area Lights:

Mental Ray Area Lights:
You can also use the mental ray area light option, you will take an immediate render hit when you check this, but your shadows will look pretty good with just the default settings and your object will be illuminated softly.  Increase the high samples to loose graininess.  You will basically double your render time with area lights and then increasing the samples will be a noticeable increase in render time each time you bump it.  You can drop it again by playing with the low samples and the high sample limit.  Putting a value of one in the High Sample Limit box will drop your render time a lot, however, putting it to two brings it back up.  Dropping your low samples will take a bit more time off your render.  I have no fucking clue what this is really about.  Go ahead and read the documentation on it, maybe you can understand what the hell they’re talking about, but I read it like 5 times and still don’t get it.  What I do get (by shear experimentation) is that if you have refractions in your material and your shadow is being cast back through it then having the low samples down will decrease the detail for the refracted shadow, but not to such a degree that you wouldn’t want to have low-low samples. 

Other things about the Area Light.  You can choose your shape, but I just use the rectangle.  The sphere has a noticeable effect, it seems to tighten your shadows a bit aside from that there’s really no difference between the shapes.  You can check visibility on, which in my experience just turns on a big black shape in your scene and you see it in the reflections, No real use there, you would be better off making a fake light box and just putting it behind your light. The main adjustments to be made with this kind of light are done with the size of the light and it's proximity to your illumitated object. You will see things like Cone Angle and penumbra as functional values in this light. You will find that you get a pattern on your objects as a result of shadows cast with an area light, you can loose this by increasing your antialiasing samples and bumping your light samples up. (Specific to maya 8.5, I have found that adaptive sampling will not give you enough samples to rid you of the pattern that you get with arealight shadows. set your antialiasing to custom and play with the values to get rid of the artifacting, curiously I have noticed a drop in render time when I do this and the image looks better.)

You can also use light radius and area lights together, but that’s just sort of making it more complex than it needs to be because you can get the same results with one or the other.  Combining them increases render time too.

I've used these both now for a while and really, I think that given the time it takes to get the area lights looking good and the render hit that you get with them that the light radius is really the best solution for soft shadows. However if you want to diffuse your specular highlights and get some nice soft shadows in the same render then the area light is your option.

 

Reflections and Refractions:

Global Illumination:
GI is all about casting light beams around in your scene to get caustics and other light effects.

Settings for the Light:

Emit Photons on, Photons are all about caustic light. You know that light that appears as bands of intense light on the bottom of swimming pools, that's caustic light. If you are not specifically wanting caustic light then don't use Photons.
Emitting photons
casts little balls of energy out from your light that will pass through and bounce off objects and simulate reflected light at varying intesity dependent upon factors like suface material, thickness, light intesity and so on.
You will notice as soon as you check photons on you get all this extra light in your scene. Photons are an additon to the regular light you are emmiting. The photons that you are emmiting from your light are not related to the regular light you are emitting from the light. You can turn the intesity of your light to 0.0 and if you are emitting photons you will still have light in your scene generated exclusively from the photons. Soooo. don't light your whole scene with photons if all you want are caustics on a single object. Related to that concept is that apparently photons are cast from the light multidirectionaly, even if it is a spot light with a tight cone angle, your whole scene will be illuminated by the photons even if you are only looking for it to hit a small area. Kind of weak, I know.

Photon Intensity: The initial energy emitted by the light.  The larger this number the more render time, cut render time by decreasing this number.  You don’t need to worry about subtle changes here.  Depending on your scene you can drop this value a whole lot.  The default is 8000, I have had great results with values around 200.

Exponent:  The falloff of the energy emitted by the light, the higher the number the greater the falloff.  If you have a low value in photon intensity you will need to reduce this to get enough light casting through your object. Likewise if you're caustic light looks to be too intense up this value. Very small incriments have big effects.

 

Render Global Settings-
Global Illum Accuracy and Global Illum Radius are smoothing agents for the photons, if you have blotchy light increase these.

 

Final Gather-

Render Global Settings-

Turn enable default light off, Default light is the Light that is automatically placed in scene when there are no lights present.

The camera background color has an effect on the light absorption in the scene.  Turn the bg color up or down to get more ambient light in your scene.

Irradiance: In the material of the object that is illuminating, in the mental ray tab increase irradiance

Final Gather Rays: The more rays you have the smoother the shading will be.
The more rays you have the more time it takes to calculate.

Min Radius:  should be 10% of your max radius

Max Radius:  Should be 10% the size of the largest item in your scene.

Min and Max settings cut render time. Min and Max radius are filters that tell Maya to bracket the rays in your scene and only calculate the rays in that bracket. 

Make sure you check in on your reflections and refractions settings. You will need to set these high enough to make sure that you are getting all the light bouncing around all the surfaces, but that's it. Don't have it any higher than you need. If you have inexplicable black spots in your transparent surface, its likely that your refractions are set too low. You have to up them in both in the inderect lighting tab and the Quality tab in render globals. Refractions only need to be as high as the number of times the light actually passes through surfaces, so unless you have a really complex object that folds over its self a bunch or you have layers of transparent objects you probably only need your refractions at 2 or 3. Reflections on the other hand are really complex and adding more of these can really change an image particularly if it is highly reflective.

For Spill light, create a light, turn off illuminates by default, but turn on emit photons.

 

HDR images-
High Dynamic Range Images.  These images contain light data that will actually simulate directional light emitted from the position of the hotspots in the image..  This effect will not work with a normal image.

You can create HDR images with a program called HDR Shop, lots of tutorials on this program’s website

 

Contour Rendering-

Ramp Shader- (makes a good toon shader)

 

Caustics-

Render Global settings:
Caustic Filter Type to cone will soften the edges of your caustics

Ray tracing and refractions obviously need to be turned on

The refraction number needs to be as high as the number of surfaces that the ray needs to penetrate the max trace depth is apparently whatever the refraction number is plus two.

Light; emit photons has to be on, caustics has to be on

Material Settings:  Under the material-mental ray tab there are settings for the photon attributes.  Derive from Maya is default.  You will want to change these settings.  Absorbs is a key feature here

 

Mentalray Materials

Dielectric materials, getting good reflections and refractions:

 

I usually create a blinn or phong and quickly get its settings to be the best estimate of what I am going for in Mental Ray, and then use this (phong or blinn's) shader group to plug my Mental Ray shaders in. In this way if you ever render in Maya you will at least have something that resembles your Mental Ray Shader.

Create a blinn and graph it in the hypershade. Under the mental ray tab of a material shading group you will find a custom shaders tab. 

Material Shader: This is a box in which you can plug any mental ray shader.  This will nullify the attributes of the blinn (or whatever material) as long as your rendering in mental ray.

plug the mr dielectric material into your material shader box you will find some somewhat abstract material attributes in the dielectric material

Dielectric Material:
Coll:  This value is represented as a color, now the hue and saturation of this color tell the material what color it is, but the value tells the material how much light it absorbs or how transparent it is depending on how you want to think of it.  So if you shoot a render of your object and it looks black this value is too low.  A Good range for a clear object is .9 and above.  The closer you get to a value of 1 the more transparent the material is.
Ior  stands for index of refraction, which is how much the light is distorted by the material, however this value controls more than that, it is apparently responsible for the size of the specular highlight as well, a higher value intensifies the refraction of the light, but creates a more intense bounce back of unrefracted specular light as well.  The higher this value the more light will be distorted.  1 is no distortion, 1.65 is standard glass is so you can probably figure out what your material is from there.
Col_out is inappropriately named because it is in fact the color of the refractions within the object  
Ior_out is apparently associated with Col_out, but has no apparent effect on anything that I can see.
phong_coef is how diffused the specular highlight will be.

 

 

Photon Shader:  This is a shader that works with your lights to project caustic light out from the object.
Under Photonic Materials create a dielectic_material_photon plug this into the SG’s Photon Shader box. 

Col is the Hue of the caustic light that will be projected out onto other surfaces from the light source.
Ior  stands for index of refraction, which is how much the light is distorted by the materialThe higher this value the more diffused the light cast from the object will be.
Col_out  is the intensity of the light that is cast from the object
Ior_out is apparently associated with Col_out, but has no apparent effect on anything that I can see.

 

 

Mental Ray Features

Displacements:

Create a material and assign it to a surface. Map the material in the hypershade and get on the shader group node. Click on the arrow for the Displacement Mat and browse for your image map. Select your surface and go to Window > Rendering Editors > Mental Ray > Approximation Editor. This opens a window. Click on Displacement Tesselation to create a displacement approximation.

Approximation Editor Settings:

Presets:
Regular Grid settings just subdivide the whole mesh equally.
Angle Feature only divides the surface where it finds it necessary
.

I get good results with Length/Distance/Angle set to: 0.1, 0.1, 10.0

A note about 32 Bit images. You may have noticed that when you dropped your 32 bit image into the displacement node that you got a message that said something to the effect of this :
// Warning: Failed to open texture file E:/prj/Built/sourceimages/U_Displ.tif

This is because as mental ray will tell you, it doesn't support 32 bit tiffs. However, it will use them to render. Yes, you will get a solid render out of mental ray using your 32 bit image and it will look good and true to your expectations. However, keep going, keep shooting renders and eventually mental ray will throw a render and deliver this message in your output window:
ERROR, E:/prj/Built/sourceimages/I_Displ.tif: TIFF image class not supported (must be 8 or 16 bits)
IMF did not recognise image file E:/prj/Built/sourceimages/I_Displ.tif.
initMPS with licenseOption 0
mental ray: got 8 satellite CPUs.
mental ray: out of memory
mental ray: out of memory
mental ray: out of memory
mental ray: out of memory
mental ray: out of memory
mental ray: out of memory
MEM 0.3 fatal 031008: can't allocate 67175820 bytes.
MEM 0.3 fatal 031008: can't allocate 67175820 bytes.

WTF? you may say
. Well I'm not entirely sure of the innerworkings that explain exactly why this happens. But, I think it is that the 32 bit image takes a bunch of memory each time you render with it and for some reason maya doesn't let it go. I doesn't even let it go after you shut maya down. You have to restart your computer to get the memory back. This problem is reduced in batch renders from the command line and you may just get your entire sequence out without ever getting the error.

Displacement maps are used to make large mouldings of your surface. You don't need a displacement map for every pore on your modle's skin or grain of wood or whatever it is. I had this supervisor will call him Randy ('cause that was his name) and he would spend days creating these amazingly detailed displacement maps in mudbox and then bring them into maya (occasionally with success) and put them on these ridiculously over tesselated models that had all this detail that took 10 min. a frame to render and periodically would throw the error and he would loose his fucking mind.

Now if you have a shitload of rendering resources, and don't mind restarting your render at whatever frame it died on, go ahead, Use 32 bit images, be like Randy, see if I care, you're a douchebag too! But I suggest going with a different philosophy. Make less detailed displacement maps and just use bump, color and spec to get the fine detail. I use this rule of thumb: if you can't see it in profile then it doesn't need to go into the displacement map.

Or, you could just use 16 bit images. "But I need the deep resources of the 32 bit image!" you may say. No you don't, you probably don't even need the 16 bit, 8 bit would probably work just fine for your hack ass work... Looser! Just kidding I'm sure your suff is great. Like I know who reads this anyway.

Lighting:

Mental Ray Lights:
Area Lights:  to make a light a area light, just make it an area light in the light type, then go down to the Mental Ray tab on your light and click area light on, increase sampling if you have a grainy shadow.

Physical Lights:
This light automatically falls off, It looks great with shiny materials. 
under the mental ray tab on a light you will find Light Shader load a physical light in.  Change the value for this light in the color channel values.

 

Volume Rendering
Volume Shader:
In the shading group, connect a volume shader, there are three types

The Particle Volume:  Scatter is the color of the cloud,  the extinction is  Min_step_length should be 10% of the Max_step_length these settings control the accuracy of the light.

Photon Volume Shader:
Put the same type of volume in the photon volume shader that you did in the volume shader,

 

 

3rd Party Custom Shaders for Mental Ray

 

The mix8layer or mix20layer method.

You will have to install one of these shaders, you can find the mix8layer by code goddess Fransica at High End 3d and the mix20layer can be found at www.pixero.com. Although Pixaro claims that the mix20 is the same thing as the mix8* with more inputs I'm not so sure. I have been able to successfuly place transparency in the mix8, and cannot find the appropriate input for transparency in the mix20.

make a maya material create your bump in the ususal way and put this material in the base color box for the mix20layer or mix8layer.

You can also get bump using the bumpCombiner shader, which works similar to the mix layers. I'm not going to go into how to do this because there is a great tutorial on how to use this and so much more to be found here bumpCombiner tutorial

You can create a bump for a mr shader without installing anything new by using this method:

Bumpmapping with custom mental ray nodes is a problem.  You have to create a network for them.

Create the following Nodes:

Mib_color_mix (under data conversion)
mib_passthrough_bump_map (under textures)
mib_bump_basis (under textures)
mib_texture_remap (under textures)
mib_texture_vector (under textures)

Make these connections and settings:

Mib_color_mix.outValue into the spec channel of your DGS;
(Color Mix node is essentially the layered texture in maya shading terms.)  Values Number of files to 1 and mode to 1.  Put this node into the spec of the material.

mib_texture_vector.outValue into mib_passthrough_bump_map.coord;

mib_passthrough_bump_map.outValue to Mib_color_mix.colorBase;

mib_bump_basis.u and.v to mib_passthrough_bump_map.u and .v

Mib_passthrough_bump  Mental ray Texture tab, load your image into this node connect it to the color mix node out value to color base.  Values; factor will increase the bump.

 

 

Subsurface Scatter

The overall color is the color of the surface

The front and back SSS colors are mixed in with the overall color to get the final look

Create a SSS shader, you will need to create a Lightmap shader that corresponds to the shader that you have made, drop the lightmap into the lightmap shader tab under your shading group

In your lightmap or your shader you will have an input for lightmap, hit the texture button, it will automatically create a MR texture, make sure it is plugged into both of these inputs.  Make the lightmap writeable, 32 bit, 800x800 is a good size and put a path into image name (make it an absolute path).  Sampling is something you will adjust if you find that your sss is grainy, bump up if grainy.

Unscattered Diffuse Layer is the actual surface quality that you are used to in regular shaders.  The diffuse weight is how much the diffuse will override the front and back sss settings.  1 will all but hide the sss colors. 0 will remove the diffuse layer all together and just render the sss effect.  The Radius is the color bleed across the normals of the surface. SSS Depth Is how deep light penetrates into the surface

Specular Layer
The specular color is the intensity of the highlight, Shinyness is how tight the highlight is, the larger the number the tighter the highlight

SSS attributes.  The recommended workflow is to turn the weight for both front and back to 0 then find the front then find the back.

If you find that you have to put huge values in your sss shader bump your scale conversion under algorithm control

To get alphas in you sss turn on your pass custom alpha in your custom entities tab in mental ray render globals.

Creating A bump map on a SSS
Create a 2D or 3D bumpmap utility (maya).  And just drop the image or procedural into the bump utility default,  pulg bump out normal into normal camera.

 

SSS Fast Skin

Diffuse Layer Tab

Ambient- same as in maya

Overall Color- This would be your normal skin color

Diffuse Color- You would normally use this for like a dirt map or something.  This is a multiplyer for overall color.
*overall and diffuse color could both take your skin texture, one or the other, but not both.

Subsurface Scattering Layer Tab
Epidermal Scatter Layer
Your Radius will be lowest on this compared to all of the other radial settings.

Specularity Tab
Specularity:
The primary speculatity is for a general map, the secondary is for isolated areas of greater specularity.

General Mental Ray Stuff

Hey, have you ever noticed that mental ray renders seem a bit washed out,  Me too!  Weird!  A lot of realist render nerds are going to freak out when they read this, but fuck'um. Duplicate your image and placement node for your color channel. Reconnect the placement node (lame) with a default drop. Now plug that image node into the ambient color channel. I know, CRAZY TALK! now get back on your image node and go down to the Color Balance > Color Gain and increase that value to like 1.25 in each of the r, g, and b channels., then in the Color Offset plug a negative number, like -.25 in each of the r, g, and b channels. Your colors will come out more saturated. The further the distance between the two values (Gain and Offset) the more contrast you will generate. More gain will make brighter colors, Offset will darken them back down, but if you overload the channels then you will get what you are looking for.

All content copyright Seth Meshko 2010. Unless stated. All rights reserved.