level 8
直接运行或者存在安装script的目录再执行gammaCtrl都可以
安装script的目录例如:\Documents\maya\XXXX版本\scripts
2013年07月02日 04点07分
3
不太明白具体意思,整体意思是给颜色图片都gamma0.45校正吗?
2013年07月06日 02点07分
回复 shenzhouchange :不只是图片给gamma0.45,程序纹理还有直接拾取的颜色也会给gamma校正。你是不明白为什么要这么做还是不明白MEL的工作过程?
2013年07月06日 02点07分
回复 ldj656 :不会MEL,学mel用处大吗? 这么做是因为线性工作流程吗
2013年07月06日 02点07分
回复 shenzhouchange :是线性工作流,用MEL可以使工作效率加快。还有粒子表达式里也要写mel,当然那个是特效师的事了。
2013年07月06日 02点07分
level 8
global proc gammaCtrl()
{
if (`window -exists gammaCtrlWin`){
deleteUI -window gammaCtrlWin;
}
window -width 150 -t "gammaCtrl" gammaCtrlWin;
columnLayout -adjustableColumn true;
rowLayout -adj 2 -nc 2;
text -label "channel Name";
textField -tx "color;diffuse" channelTF;
setParent..;
rowLayout -adj 2 -nc 2;
text -label "gamma";
floatField -v .4545 gammaFF;
setParent..;
radioButtonGrp -numberOfRadioButtons 3 -l1 "material" -l2 "light" -l3 "both" -sl 1 -columnWidth3 60 60 60 mlRbGrp;
radioButtonGrp -numberOfRadioButtons 2 -l1 "all" -l2 "selected" -sl 1 -columnWidth2 60 60 slRbGrp;
button -label "create/modify" -command "doGammaCtrl(`textField -q -tx channelTF`,`floatField -q -v gammaFF`)" -bgc 0 1 0;
button -label "remove all" -command "doRemoveGammaCtrl" -bgc 1 0 0;
button -label "close" -command "deleteUI -window gammaCtrlWin" -bgc 0 0 0;
showWindow gammaCtrlWin;
}
gammaCtrl();
global proc string doGammaCtrl(string $Attr,float $gamma)
{
int $slml = `radioButtonGrp -q -sl mlRbGrp`;
int $slsl = `radioButtonGrp -q -sl slRbGrp`;
string $sl[];
if ($slsl == 2)
{
$sl = `ls -sl`;
for($i=0;$i<size($sl);$i++)
if (`nodeType $sl[$i]`=="transform")
{
string $tmp[] = `ls -dag -type shape $sl[$i]`;
$sl[$i] = $tmp[0];
}
switch ($slml)
{
case 1:
$sl = `ls -mat $sl`;
break;
case 2:
$sl = `ls -lt $sl`;
break;
case 3:
$sl = `ls -mat -lt $sl`;
break;
}
}
else
switch ($slml)
{
case 1:
$sl = `ls -mat`;
break;
case 2:
$sl = `ls -lt`;
break;
case 3:
$sl = `ls -mat -lt`;
break;
}
if (!`objExists "gammaCtrl"`)
{
string $gammaCtrNode = `createNode -n "gammaCtrl" unknown`;
addAttr -ln "gamma" -at double -dv $gamma gammaCtrl;
setAttr -e-keyable true gammaCtrl.gamma;
}
setAttr "gammaCtrl.gamma" $gamma;
string $buffer[];
tokenize $Attr ";" $buffer;
for ($a in $sl)
{
for ($attr in $buffer)
{
if(`attributeExists $attr $a` && `getAttr -type ($a + "." + $attr)` == "float3")
{
string $color = $a + "." + $attr;
string $channel[] = `listConnections -p 1 $color`;
if ($channel[0] == "")
{
string $gamma = `createNode gammaCorrect`;
vector $c = `getAttr $color`;
setAttr ($gamma + ".value") ($c.x) ($c.y) ($c.z);
connectAttr -force ($gamma + ".outValue") $color;
connectAttr -force gammaCtrl.gamma ($gamma + ".gammaX");
connectAttr -force gammaCtrl.gamma ($gamma + ".gammaY");
connectAttr -force gammaCtrl.gamma ($gamma + ".gammaZ");
}
else
{
string $type = `nodeType $channel[0]`;
if($type != "gammaCorrect")
{
string $gamma = `createNode gammaCorrect`;
connectAttr -force $channel[0] ($gamma + ".value");
connectAttr -force ($gamma + ".outValue") $color;
connectAttr -force gammaCtrl.gamma ($gamma + ".gammaX");
connectAttr -force gammaCtrl.gamma ($gamma + ".gammaY");
connectAttr -force gammaCtrl.gamma ($gamma + ".gammaZ");
}
}
}
}
}
select gammaCtrl;
return "gammaCtrl";
}
global proc doRemoveGammaCtrl()
{
if (`objExists "gammaCtrl"`)
{
string $gammaNode[] = stringArrayRemoveDuplicates(`listConnections "gammaCtrl.gamma"`);
delete gammaCtrl;
for ($s in $gammaNode)
{
string $inPlug[] = `listConnections -p 1 ($s + ".value")`;
string $outPlug[] = `listConnections -p 1 ($s + ".outValue")`;
vector $c = `getAttr ($s + ".value")`;
delete $s;
if ($outPlug[0] != "")
{
if ($inPlug[0] != "") connectAttr -f $inPlug[0] $outPlug[0];
else setAttr $outPlug[0] ($c.x) ($c.y) ($c.z);
}
}
}
}
2013年07月06日 06点07分
10
level 9
高端,不过还在安软件,学建模阶段的同学先学基础吧。
伽马值,可以给大家普及下,不知道说得对不对,请高手指正
伽马就是一个位图(这个词请百度)黑与白的平衡点(对纯黑和纯白无效),在maya渲染的OCC中会非常明显的体现,你需要的就是:用Photoshop打开一张OCC图,然后ctrl+l打开色阶面板,输入色阶中间有个数值为一的三角滑块,这个就是伽马值,其他软件可能不同。但原理一致,你左右滑动一下,立马明白了这个看似高深的数值。
2013年10月23日 02点10分
14
level 7
感谢老师,这样以后贴材质可就方便很多了。太实用了呵呵
2013年11月11日 02点11分
16
level 7
楼主,能在写一个mel 吗?
就是 一键删除所有的 outvalue -diffuse,color. 这样就完美了呵呵。
2013年11月15日 02点11分
19
点remove all不管用吗?
2013年11月15日 04点11分
除非你这个gammaCorrect节点不是用这个脚本创建的。用这个脚本创建的会用一个节点去控制所有gamma节点的gamma值,获取需要删除的gamma节点也是通过这个节点的连接信息去获取。不建议暴力删除所有gammacorrect节点,某些gamma节点说不定有别的作用也会被误删
2013年11月15日 04点11分
回复 ldj656 :一点 remove all就全部都删除了。就没有gamma了
2013年11月15日 09点11分
level 8
楼主 帮忙解释下 这个怎么用吧 就是玛雅渲染出来偏灰是怎么回事?用楼主这个mel又是如何工作流程呢 麻烦解释下吧 万分感谢
2014年09月08日 07点09分
23