您现在的位置:首页 > CG教程 > 其他专栏 > 程序脚本 > 文章内容
Maya灯光关联 RSS订阅

Maya灯光关联

发表时间:2005-10-25

作者:潮流兴夹Band

  心血来潮,写了一个灯光关联和一个批量成点光的mel(可以模拟GI,并有很强的自由度)。

  先看图:

点击放大

  以下是程序代码:

  //把选择灯光的属性连接起来;

  //增加控制漫反射跟高光的属性;

  string $objects[] = `ls -sl`;

  string $i,$first,$temp;

  $first=$objects[0];

  group;

  for($i in $objects)

  {

  if ($i==$first)

  {}

  else

  {

  //下行意思:LightConnectAttr("属性名字",$first,$i);

  //属性名字可以随便改成你所知道的名字。

  //举例,可以改成shadowRays、rayDepthLimit、castSoftShadows

  //useDepthMapShadows等:

  //下面四行去掉"//"时候可以连接阴影。

  //LightConnectAttr("useDepthMapShadows",$TempName,$tempLight[0]);

  //LightConnectAttr("dmapResolution",$TempName,$tempLight[0]);

  //LightConnectAttr("dmapFilterSize",$TempName,$tempLight[0]);

  //LightConnectAttr("dmapBias",$TempName,$tempLight[0]);

  //下面四行去掉"//"时候可以连接光线跟踪阴影。

  //LightConnectAttr("useRayTraceShadows",$TempName,$tempLight[0]);

  //LightConnectAttr("rayDepthLimit",$TempName,$tempLight[0]);

  //LightConnectAttr("shadowRays",$TempName,$tempLight[0]);

  //LightConnectAttr("lightRadius",$TempName,$tempLight[0]);

  LightConnectAttr("intensity",$first,$i);

  LightConnectAttr("color",$first,$i);

  $temp="connectAttr -f "+$first+".lightDiffuse "+$i+".emitDiffuse";

  eval($temp);

  $temp="connectAttr -f "+$first+".lightSpecular "+$i+".emitSpecular";

  eval($temp);

  }

  };

  proc LightConnectAttr(string $AttrLight,string $first,string $i)

  {

  $temp="connectAttr -f "+$first+"."+$AttrLight+" "+$i+"."+$AttrLight;

  eval($temp);

  }

  //此功能,你只需要把几个灯光选择了之后,按一下按键,它就会自动把选择的灯光

  //连接到第一个选择的灯光的color跟intensity上,也可以自己添加属性,里面的

  //解释已经说得很清楚明白

  //经过改进后,我已经把它们合成组,而不是连接成父子节点的关系,这样管理

  //更加方便,第一个灯光的属性就可以控制了

共4页: 上一页 1 [2] [3] [4] 下一页
    评论加载中…