mip_gamma_gain and mentalRaySwatchGen

david | dj mod,mentalray,rendering | Wednesday, October 22nd, 2008

Using a linear workflow always requires some gamma correction somewhere. If its within a maya shader network then you have some choices. The most obvious is maya's standard gammaCorrect node.

If you have maya2008 or 2009 then there is also mentalray's mip_gamma_gain node (which is hidden by default, but is easy to expose).


These two nodes perform the same basic function, with a few differences.

Maya's standard gammaCorrect enables independant gamma control of the three color channels.

While mr's mip_gamma_gain offers the simplicity of a single value gamma and throws in a gain control and a reverse switch for inverting the gamma value (saves you having to get the calculator to figure out the inverse of 2.2).

Until very recently, I had always used maya's gammaCorrect. And for one reason only - I like its colorful and meaningful hypershade swatch because it is easy to see in a busy hypershade window.


Now I'm starting to use mip_gamma_gain instead because it occured to me that I can modify mentalrayCustomNodeClass.mel ( in C:\Program Files\Autodesk\Maya2008\scripts\others) and get it to display a swatch that has one of those updating shader balls. That means I can see the actual result of the gamma change.

Although it makes the gamma nodes harder to find in the hypershade window, I'm finding the visual feedback useful.

If you want to try this, make a copy of mentalrayCustomNodeClass.mel into your local scripts folder and edit your local copy. The file has an obvious structure, so look for the "Internal MentalRay Nodes" section and add these lines after it.

if ($nodeType == "mip_gamma_gain" )
return "rendernode/mentalray/material:shader/surface:swatch/mentalRaySwatchGen";

You should also comment out the original reference to mip_gamma_gain.


  1. Thank you, David. will try!!

    Comment by jasonhuang1115 — October 24, 2008 @ 1:58 am

  2. Excellent Post, I will be trying this out. Like how you figured out how generate swatches.

    Comment by AlexPummer — October 30, 2008 @ 7:54 am

  3. David, excellent information as usual greatly appreciated.
    I am using Maya 2009 x64 but all of my swatches are static. (very boring)
    I checked the mentarayCustom NodeClass file copied it like you suggested,
    revealed the internal shaders (excellent) but none of them have icons and they
    are all static. I put the line after them:
    return "rendernode/mentalray/material:shader/surface:swatch/mentalRaySwatchGen";
    But ALL mental ray swatches seem static.
    Do you have any suggestions?

    Comment by ozone1970 — December 17, 2008 @ 3:00 pm

  4. Paul, I'm not sure why those swatches are not updating. Are you refering to the mip's or all mr shaders? Things like mia_material_x should certainly update, but the mip's do not, unless you modify mentalrayCustomNodeClass.mel
    Since you tried that already, it seems that you maybe introduced an error, which is very easy to do, believe me. Try renaming your modified file to hide it and see if the default shaders work correctly again when you restart maya. If you do suspect your edited file, feel free to email it to me and I will see if anything looks strange.

    There is a link to some unofficial mip hypershade icons on my downloads page - http://www.djx.com.au/blog/downloads/ Just copy them to your icons folder and restart maya.

    Comment by david — December 17, 2008 @ 11:10 pm

  5. Hello david , my question is whether the mip _gamma _gain shader could not connect a file texture and only could connect procedure textures? if it could,how to do?

    And another thing is i want to use the mip_shadow _reflection shader and other "hide" shaders in maya 2008,could you sent me a mental ray customNodeClass. mel of maya 2008 ,thank you very much!

    Comment by alucard_cg — February 6, 2009 @ 9:31 pm

  6. mip_gamma_gain can be used for maya fileTextures and procedurals. For example if you want to use a fileTexture for diffuse color in a mia_material_x then connect the fileTexture.outColor to mip_gamma_gain.input, and then connect mip_gamma_gain.outValue to mia_material_x_diffuse

    You can also use it when using maya shaders like blinn and phong, but then the hypershade swatch display will be incorrect. It still renders ok, but you would probably wan to to use maya's gammaCorrect instead in this case.

    Comment by david — February 6, 2009 @ 11:51 pm

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck