【MAYA】【交流】一键为材质灯光的颜色创建gamma节点MEL
maya吧
全部回复
仅看楼主
level 8
ldj656 楼主
觉得可能有人需要就放上来了,刚写完没怎么测试,欢迎提意见。
2013年07月02日 04点07分 1
level 8
ldj656 楼主
直接运行或者存在安装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 11
谢谢老师,好东西,插楼!
2013年07月02日 04点07分 4
老师您主要是做渲染还是特效啊
2013年07月02日 04点07分
回复 聊城人伤心 :渲染
2013年07月02日 04点07分
啊,渲染还这么会MEL,羡慕嫉妒恨!我还是继续要学PYTHON了,,,,,,,
2013年07月02日 04点07分
回复 聊城人伤心 :不会py,mel就是个字符串编辑器,弄懂基本规则很快就上手了。
2013年07月02日 06点07分
level 1
学习了,赞一个
2013年07月02日 11点07分 5
level 7
此贴不精天理何在.
@杀手族长 允许我@你一下.
2013年07月03日 12点07分 6

2013年07月03日 15点07分
level 14
这个东西具体怎么用啊?以前没用过,比如说那个0.4545这个数值是干什么的?还有下面的英文选项是干什么的,虚心求教一下,你或许觉得我的水平菜,但是就是想知道哇[泪]
2013年07月06日 03点07分 7
线性工作流要用到的,0.4545 约等于2.2的倒数。 下面的选项是控制执行对象的,第一行的选择是材质,灯光,两者,第二行是所有,当前选择
2013年07月06日 03点07分
噢,虽然还是不明白有什么效果,但是我会用实践去理解的,谢谢
2013年07月06日 03点07分
level 1
不支持 mia_material_x 求改进
2013年07月06日 04点07分 8
ldj656: channel Name 打 diffuse,这时候别的普通材质的diffuse属性可能也会被连上,这个时候还是手动选择mia材质再选selected选项再执行,或者再等我改一下,让它只识别double3类别的属性
2013年07月06日 06点07分
level 8
ldj656 楼主
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
谢谢亲
2013年07月06日 12点07分
level 8
ldj656 楼主
贴上来了以后就没了缩进,蛋疼的度娘
2013年07月06日 07点07分 11
没缩进,看得我也蛋疼。。。如果对应各种材质写个列表直接替换$Attr就好了,不过那样工作量就大了。我现在用一个叫jj_gammacorrect的还不错,creative crash直接能下。
2013年10月22日 14点10分
回复 可乐爱多 :这东西写出来以后我就没用过了,加了个gamma节点以后贴图就不能预览挺蛋疼。后来干脆在shader里写了gamma矫正
2013年10月23日 02点10分
回复 可乐爱多 :我写的这儿有属性列表的,默认color;diffuse,自动过滤非颜色属性,要添加打上属性名就可以,用;隔开,不知道这个JJ脚本怎么样
2013年10月23日 02点10分
回复 ldj656 :那个JJ我现在用下来还不错,本来也打算自己写来着,但是maya里面乱七八糟的需要加gamma的地方太多了,属性名也都不一样。
2013年10月23日 02点10分
level 12
集成为插件不是更好?
2013年07月07日 00点07分 12
level 9
不知道LZ 对程序材质有没有研究过
2013年10月22日 09点10分 13
会一点
2013年10月23日 02点10分
level 9
高端,不过还在安软件,学建模阶段的同学先学基础吧。
伽马值,可以给大家普及下,不知道说得对不对,请高手指正
伽马就是一个位图(这个词请百度)黑与白的平衡点(对纯黑和纯白无效),在maya渲染的OCC中会非常明显的体现,你需要的就是:用Photoshop打开一张OCC图,然后ctrl+l打开色阶面板,输入色阶中间有个数值为一的三角滑块,这个就是伽马值,其他软件可能不同。但原理一致,你左右滑动一下,立马明白了这个看似高深的数值。
2013年10月23日 02点10分 14
level 9

2013年10月26日 14点10分 15
level 7
感谢老师,这样以后贴材质可就方便很多了。太实用了呵呵
2013年11月11日 02点11分 16
level 8
[乖]纯纯的技术交流贴····我是来顶的····
2013年11月11日 03点11分 17
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 1
不会用
2014年01月06日 05点01分 21
level 7
先顶
2014年01月17日 05点01分 22
level 8
楼主 帮忙解释下 这个怎么用吧 就是玛雅渲染出来偏灰是怎么回事?用楼主这个mel又是如何工作流程呢 麻烦解释下吧 万分感谢
2014年09月08日 07点09分 23
1 2 尾页