马上注册,加入CGJOY,让你轻松玩转CGJOY。
您需要 登录 才可以下载或查看,没有帐号?立即注册
×
对!没错!都有解决方案,但是MR的方案,渲染太慢了!所以都有sw的解决方案!
但是每个材质都要这样子改,多麻烦那?~于是乎,我就综合归纳出了max脚本来解决这个问题。。场景大的最好小块选,用选择物体修改的脚本,当心场景崩溃,或非类的报错。
-----------------------------------统一改场景材质球颜色脚本为standard.ms---------------------------------------------
for i=1 to scenematerials.count do
(
cmat = scenematerials
if (getClassName cmat) == "Standard" do
(
cmat.diffuseMapEnable = on
cmat.selfillumMapEnable = off
cmat.selfillumMap = undefined
cmat.useSelfIllumColor = off
cmat.selfIllumColor = color 150 150 150
cmat.Diffuse = color 150 150 150
cmat.ambient = color 150 150 150
)
if (getClassName cmat) == "Multi/Sub-Object" do
(
for j = 1 to cmat.numsubs do
if cmat[j] != undefined do
(
bmat = cmat[j]
bmat.diffuseMapEnable = on
bmat.selfillumMapEnable = off
bmat.selfillumMap = undefined
bmat.useSelfIllumColor = off
bmat.selfIllumColor = color 150 150 150
bmat.Diffuse = color 150 150 150
bmat.ambient = color 150 150 150
)
)
if (getClassName cmat) == "Blend" do
(
for h = 1 to cmat.numsubs do
if cmat[h] != undefined do
(
cmat.map1Enabled = off
cmat.map1.diffuseMapEnable = on
cmat.map1.selfillumMapEnable = off
cmat.map1.selfillumMap = undefined
cmat.map1.useSelfIllumColor = off
cmat.map1.selfIllumColor = color 150 150 150
cmat.map1.Diffuse = color 150 150 150
cmat.map1.ambient = color 150 150 150
cmat.map2Enabled = off
cmat.map2.diffuseMapEnable = on
cmat.map2.selfillumMapEnable = off
cmat.map2.selfillumMap = undefined
cmat.map2.useSelfIllumColor = off
cmat.map2.selfIllumColor = color 150 150 150
cmat.map2.Diffuse = color 150 150 150
cmat.map2.ambient = color 150 150 150
)
)
)
-----------------------------------统一改场景材质球颜色脚本为zdepth(sw).ms--------------------------------------------for i=1 to scenematerials.count do
(
cmat = scenematerials
if (getClassName cmat) == "Standard" do
(
cmat.diffuseMapEnable = off
cmat.selfillumMapEnable = on
cmat.selfillumMap = falloff ()
cmat.selfillumMap.type = 4
cmat.selfillumMap.direction = 0
cmat.selfillumMap.farDistance = 9000
cmat.useSelfIllumColor = on
cmat.selfIllumColor = color 0 0 0
cmat.Diffuse = color 0 0 0
cmat.ambient = color 0 0 0
)
if (getClassName cmat) == "Multi/Sub-Object" do
(
for j = 1 to cmat.numsubs do
if cmat[j] != undefined do
(
bmat = cmat[j]
bmat.diffuseMapEnable = off
bmat.selfillumMapEnable = on
bmat.selfillumMap = falloff ()
bmat.selfillumMap.type = 4
bmat.selfillumMap.direction = 0
bmat.selfillumMap.farDistance = 9000
bmat.useSelfIllumColor = on
bmat.selfIllumColor = color 0 0 0
bmat.Diffuse = color 0 0 0
bmat.ambient = color 0 0 0
)
)
if (getClassName cmat) == "Blend" do
(
for h = 1 to cmat.numsubs do
if cmat[h] != undefined do
(
cmat.map1Enabled = on
cmat.map1.diffuseMapEnable = off
cmat.map1.selfillumMapEnable = on
cmat.map1.selfillumMap = falloff ()
cmat.map1.selfillumMap.type = 4
cmat.map1.selfillumMap.direction = 0
cmat.map1.selfillumMap.farDistance = 9000
cmat.map1.useSelfIllumColor = on
cmat.map1.selfIllumColor = color 0 0 0
cmat.map1.Diffuse = color 0 0 0
cmat.map1.ambient = color 0 0 0
cmat.map2Enabled = on
cmat.map2.diffuseMapEnable = off
cmat.map2.selfillumMapEnable = on
cmat.map2.selfillumMap = falloff ()
cmat.map2.selfillumMap.type = 4
cmat.map2.selfillumMap.direction = 0
cmat.map2.selfillumMap.farDistance = 9000
cmat.map2.useSelfIllumColor = on
cmat.map2.selfIllumColor = color 0 0 0
cmat.map2.Diffuse = color 0 0 0
cmat.map2.ambient = color 0 0 0
)
)
)
-------------------------- 统一改选择的材质球颜色脚本.ms(要把组都open,然后隐藏组框,选择里面的物体)-----------------------------------
for i=1 to $selection.count do
(
cmat = $selection.material
if (getClassName cmat) == "Standard" do
(
cmat.diffuseMapEnable = off
cmat.selfillumMapEnable = on
cmat.selfillumMap = falloff ()
cmat.selfillumMap.type = 4
cmat.selfillumMap.direction = 0
cmat.selfillumMap.farDistance = 9000
cmat.useSelfIllumColor = on
cmat.selfIllumColor = color 0 0 0
cmat.Diffuse = color 0 0 0
cmat.ambient = color 0 0 0
)
if (getClassName cmat) == "Multi/Sub-Object" do
(
for j = 1 to cmat.numsubs do
if cmat[j] != undefined do
(
bmat = cmat[j]
bmat.diffuseMapEnable = off
bmat.selfillumMapEnable = on
bmat.selfillumMap = falloff ()
bmat.selfillumMap.type = 4
bmat.selfillumMap.direction = 0
bmat.selfillumMap.farDistance = 9000
bmat.useSelfIllumColor = on
bmat.selfIllumColor = color 0 0 0
bmat.Diffuse = color 0 0 0
bmat.ambient = color 0 0 0
)
)
if (getClassName cmat) == "Blend" do
(
for h = 1 to cmat.numsubs do
if cmat[h] != undefined do
(
cmat.map1Enabled = on
cmat.map1.diffuseMapEnable = off
cmat.map1.selfillumMapEnable = on
cmat.map1.selfillumMap = falloff ()
cmat.map1.selfillumMap.type = 4
cmat.map1.selfillumMap.direction = 0
cmat.map1.selfillumMap.farDistance = 9000
cmat.map1.useSelfIllumColor = on
cmat.map1.selfIllumColor = color 0 0 0
cmat.map1.Diffuse = color 0 0 0
cmat.map1.ambient = color 0 0 0
cmat.map2Enabled = on
cmat.map2.diffuseMapEnable = off
cmat.map2.selfillumMapEnable = on
cmat.map2.selfillumMap = falloff ()
cmat.map2.selfillumMap.type = 4
cmat.map2.selfillumMap.direction = 0
cmat.map2.selfillumMap.farDistance = 9000
cmat.map2.useSelfIllumColor = on
cmat.map2.selfIllumColor = color 0 0 0
cmat.map2.Diffuse = color 0 0 0
cmat.map2.ambient = color 0 0 0
)
)
)
------------------------------------------------------------------------------------------------------------------------------------
Maya篇
------------------------------------------------------------------------------------------------------------------------
//--------------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;
*/
|