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

Maya灯光关联

发表时间:2005-10-25

  

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

  //又改进了,可以用光线追踪阴影的版本,如果不需要可以在前面添加"//"

  //因为太多连接在大型场景中有可能导致maya速度减低

  //使用选择点生成灯场;可模拟GI

  string $i,$temp,$TempName;

  string $faces[] = getSelVerts();

  int $j=1;

  for($i in $faces)

  {

  float $point[]=`pointPosition $i`;

  defaultPointLight(1, 1,1,1, 0, 0, 0,0,0, 1);

  move -r $point[0] $point[1] $point[2];

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

  if($j==1)

  {

  $TempName=$tempLight[0];

  }

  else

  {

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

  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("属性名字",$first,$i);

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

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

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

  $temp="connectAttr -f "+$TempName+".lightDiffuse "+$tempLight[0]+".emitDiffuse";

  eval($temp);

  $temp="connectAttr -f "+$TempName+".lightSpecular "+$tempLight[0]+".emitSpecular";

  eval($temp);

  $temp="parent "+$tempLight[0]+" "+$TempName;

  eval($temp);

  };

  $j+=1;

  };

  proc string[] getSelVerts(){

  return `filterExpand -ex true -sm 31`;

  };

  proc LightConnectAttr(string $AttrLight,string $TempName,string $tempLight)

  {

  $temp="connectAttr -f "+$TempName+"."+$AttrLight+" "+$tempLight+"."+$AttrLight;

  eval($temp);

  };

  //此功能需要使用poly才行,而且一定要选择点它才能工作,它会自动在选择点的位置生成

  //灯光,而且会自动把第一个灯光设置成父对像,同时还把color跟intensity连到第一个灯

  //光上.

  //它的用途嘛,多种多样~ 你可以用“平板”生成平面的点,也可以圆形生成"天"跟"地"

  //分别控制,还可以在装修图里分区域分布,不过控制它们亮度是需要计算的

  //你最好先用一个灯打好亮度,然后隐藏,再生成灯光组

  //灯光组的亮度=你需要的亮度/灯光数

点击放大

    评论加载中…