Maya Gamma Node MEL Script

If you are working linear in Maya, you probably add gamma correct nodes between each texture and it’s material.

This MEL script will add a gamma correct node (set to gamma .45) between a selected texture and it’s selected target material, and it will attach the network to the material’s color attribute.

Before you run the script:
first select the material and the texture that you want to attach to it.

[text]
string $mySel[] = `ls -sl`;
string $myMaterial[] = `ls -mat $mySel`;
string $myTex[] = `ls -tex $mySel`;
string $myGamma = `shadingNode -asUtility gammaCorrect`;
setAttr ($myGamma + ".gammaX") 0.45;
setAttr ($myGamma + ".gammaY") 0.45;
setAttr ($myGamma + ".gammaZ") 0.45;
connectAttr -force ($myTex[0] + ".outColor") ($myGamma + ".value");
connectAttr -force ($myGamma + ".outValue") ($myMaterial[0] + ".color");
[/text]

3 comments

  1. Hugo Baptista

    In 3Dsmax you can control input and output gamma of textures globally. there’s no such thing in Maya? It’s been something like 5 years since I last used Maya…

  2. Oliver

    In fact you may be able to do that, but I m not aware of the procedure to do it correctly. I know you can change the gamma setting in the frame buffer, but the result is not what I expected.

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>