//--------------pt1.创建基本zdepth材质,pass-----------------------
shadingNode -asUtility samplerInfo;
shadingNode -asUtility distanceBetween;
connectAttr -f samplerInfo1.pointCamera distanceBetween1.point1;
shadingNode -asUtility setRange;
connectAttr -f distanceBetween1.distance setRange1.valueX;
setAttr "setRange1.maxX" 1;
setAttr "setRange1.oldMinX" 500;
setAttr "setRange1.oldMaxX" 1600;
//这个数据要测量获得
shadingNode -asTexture ramp;
rename ramp1;
removeMultiInstance -break true ramp1.colorEntryList[1];
setAttr "ramp1.colorEntryList[2].color" -type double3 0 0 0 ;
setAttr "ramp1.colorEntryList[2].position" 1;
setAttr "ramp1.colorEntryList[0].color" -type double3 2 2 2 ;
setAttr "ramp1.colorEntryList[0].position" 0;
connectAttr -f setRange1.outValueX ramp1.vCoord;
shadingNode -asShader surfaceShader;
rename zdepthSshaer;
connectAttr -force ramp1.outColor zdepthSshaer.outColor;
//-----------------pt2.下面开始复制材质,并且连接,及指定贴图,pass--------------------------
for ($i = 2; $i < 6; $i++)
{
shadingNode -asShader layeredShader;
rename ("layeredShader"+$i);
connectAttr -force zdepthSshaer.outColor ("layeredShader"+$i+".inputs[0]"+".color");
setAttr ("layeredShader"+$i+".compositingFlag")1;
shadingNode -asTexture file;
rename ("file"+$i);
setAttr -type "string" ("file"+$i+".fileTextureName") {"tex"+$i+".dds"};
connectAttr -force ("file"+$i+".outTransparency") ("layeredShader"+$i+".inputs[0]"+".transparency");
sets -renderable true -noSurfaceShader true -empty -name ("layeredShader"+$i+"SG");
defaultNavigation -connectToExisting -source ("layeredShader"+$i) -destination ("layeredShader"+$i+"SG");
//connectAttr -f ("layeredShader"+$i+".outColor") ("layeredShader"+$i+"SG"+".surfaceShader");
sets -e -forceElement ("layeredShader"+$i+"SG");
};
//----------点选物体,指定材质error------------------------------
string $select[] = `ls -sl`;
for($in in $select)
{
sets -e -forceElement ("layeredShader"+$in+"SG");
}
//-------------bakup-------------------------------
/*
shadingNode -asShader layeredShader;
connectAttr -f zdepthSshaer.outColor layeredShader1.inputs[1].color;
removeMultiInstance -break true layeredShader1.inputs[0];
shadingNode -asTexture file;
connectAttr -force file1.outTransparency layeredShader1.inputs[1].transparency;
setAttr "layeredShader1.compositingFlag" 1;
duplicate layeredShader1 ;
connectAttr -force surfaceShader1.outColor layeredShader4.inputs[1].color;
connectAttr -force file1.outTransparency layeredShader4.inputs[1].transparency;
sets -renderable true -noSurfaceShader true -empty -name layeredShader4SG;
defaultNavigation -connectToExisting -source layeredShader4 -destination layeredShader4SG;
connectAttr -f layeredShader4.outColor layeredShader4SG.surfaceShader;
sets -e -forceElement layeredShader2SG;
*/
|