/*
beginHelpText

SCRIPT: redshiftAOV_UI.mel
AUTHOR: Joe Harkins ([email protected])
VERSION: 1.0
DATE: 02/05/2016

-=UPDATES=-

-=DESCRIPTION=-

-=EXAMPLE=-

-=NOTES=-

endHelpText
*/

//-------------------------------------------------------------
//---------------------- begin script -------------------------
//-------------------------------------------------------------

global proc redshiftAOV_PrintNothing(){
print("sorry this feature has not been enabled yet!
");
}

global proc redshiftAOV_UI(){

global float $rsAOVEmbedded;

//redshiftAOVHelper_createPropNode();
source generateChannelMenu;
if(`window -ex redshiftAOV_UI`) deleteUI redshiftAOV_UI;

int $h=750;
int $w=280;

if(`about -os`!="nt") {$h=400;$w=300;};

$win = `window -t "redshiftAOV_UI" -in "redshiftAOV_UI" -w $w -h $h redshiftAOV_UI`;

$fl = `formLayout`;
$mcl = `columnLayout -w $w -p $fl -adj on`;

$menuBarLayout = `menuBarLayout -p $mcl`;
menu -label "Rendering Tools" -aob 1 rsRenderMenu;
menuItem -label "Render Settings Window" -command "unifiedRenderGlobalsWindow();";
menuItem -label "Hypershade Window" -command "HypershadeWindow();";
menuItem -label "Optimize Scene" -command "cleanUpScene 1;";

menu -label "Presets" -aob 1 rsPresetsMenu;
menuItem -label "Fast Preview" -command "redshiftAOV_PrintNothing();";
menuItem -label "Production Quality" -command "redshiftAOV_PrintNothing();";
menuItem -label "Max Samples" -command "redshiftAOV_PrintNothing();";

menu -label "Geo Tagging" -aob 1 rsTagsMenu;
menuItem -label "redshiftPuzzleMatte UI" -command "redshiftPuzzleMatte_UI();";

menu -label "Help" -aob 1 rsHelpMenu;
menuItem -label "Redshift Documentation" -command "redshiftAOV_Helper();";

separator -p $mcl;
text -p $mcl -l "Redshift AOV Helper";
//text -p $mcl -l "by Joe Harkins";
separator -p $mcl;

string $AOV_List[];
string $listed = "";
$listed += "World Position";
$listed += ",Depth";
//$listed += ",Puzzle Matte";
$listed += ",Motion Vectors";
$listed += ",ObjectID";
$listed += ",Diffuse Lighting";
$listed += ",Diffuse Lighting Raw";
$listed += ",Diffuse Filter";
$listed += ",Specular Lighting";
$listed += ",Sub Surface Scatter";
$listed += ",Reflections";
$listed += ",Reflections Raw";
$listed += ",Reflections Filter";
$listed += ",Refractions";
$listed += ",Refractions Raw";
$listed += ",Refractions Filter";
$listed += ",Emission";
$listed += ",Global Illumination";
$listed += ",Global Illumination Raw";
$listed += ",Caustics";
$listed += ",Caustics Raw";
$listed += ",Ambient Occlusion";
$listed += ",Shadows";
$listed += ",Normals";
$listed += ",Bump Normals";
$listed += ",Matte";
$listed += ",Volume Lighting";
$listed += ",Volume Fog Tint";
$listed += ",Volume Fog Emission";
$listed += ",Translucency Lighting Raw";
$listed += ",Translucency Filter";
$listed += ",Translucency GI Raw";
$listed += ",Total Diffuse Lighting Raw";
$listed += ",Total Translucency Lighting Raw";
$listed += ",Object-Space Positions";
$listed += ",Object-Space Bump Normals";
$AOV_List = stringToStringArray($listed, ",");
$AOV_List = `sort $AOV_List`;

$rowM1 = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 ($w*.5) -columnWidth 2 ($w*.5) -p $mcl`;

$rowM2 = `rowColumnLayout -numberOfColumns 1 -columnWidth 1 ($w*.5) -p $rowM1`;
separator -h 10 -p $rowM2;
text -p $rowM2 -l "Available AOV(s)";
separator -h 10 -p $rowM2;
textScrollList -h 350 -numberOfRows 10 -allowMultiSelection true -p $rowM2 attrList1;
for($type in $AOV_List)textScrollList -e -append $type attrList1;

separator -h 10 -p $mcl;

$rowM3 = `rowColumnLayout -numberOfColumns 1 -columnWidth 1 ($w*.5) -p $rowM1`;
separator -h 10 -p $rowM3;
text -p $rowM3 -l "Loaded AOV(s)";
separator -h 10 -p $rowM3;
textScrollList -h 350 -numberOfRows 10 -sc redshiftAOVHelper_SelectAOVs -allowMultiSelection true -p $rowM3 attrList2;
string $aovsThatExist[] = `ls -type "RedshiftAOV"`;
for($aovThatExists in $aovsThatExist){
textScrollList -e -append $aovThatExists attrList2;
string $whatFile = `getAttr ($aovThatExists + ".filePrefix")`;
if(`gmatch $whatFile "<BeautyPath>/<BeautyFile>"`){
$rsAOVEmbedded = 1;
//print(" using default redshift AOV path
");
//setAttr "redshiftProperties.rs_embedValue" 0;
}
else{
$rsAOVEmbedded = 0;
//print(" AOV passes are already embedded
");
//setAttr "redshiftProperties.rs_embedValue" 1;
}
}
setParent $fl;
setParent $fl;

$rowC1 = `rowColumnLayout -numberOfRows 1 -rowHeight 1 30 -p $mcl`;

button -p $rowC1 -l " Create Selected AOV(s) " -ann "select the AOVs you want to create under Available AOV(s) list" -h 25 -w ($w*.5) -c redshiftAOVHelper_CreateSelectedAOVs jhLoadCons1;
button -p $rowC1 -l " Delete Selected AOV(s)" -ann "This will delete selected AOV(s) from the LOADED AOV list" -h 25 -w ($w*.5) -c redshiftAOVHelper_deleteSelectedAOVs rsDeleteAOVBtn;

separator -h 10 -p $mcl;

$rowC4 = `rowColumnLayout -numberOfRows 1 -rowHeight 1 30 -p $mcl`;
text -p $rowC4 -l " Embed AOV Passes (on/off) ";
checkBox -p $rowC4 -l "" -ann "Embed AOVs into beauty file (ie: multi-channel EXR)" -onc "redshiftAOVHelper_EnbedPasses" -ofc "redshiftAOVHelper_unEnbedPasses" rsEmbedCB;

//float $rsPropV = `getAttr "redshiftProperties.rs_embedValue"`;

checkBox -e -value $rsAOVEmbedded rsEmbedCB;
separator -h 10 -p $mcl;

button -h 22 -w 200 -p $mcl -bgc .5 .5 1 -l " Create Default Render Setup" -ann "This will create the passes that add up to the Redshift beauty Render in Nuke and a separate AO pass" -c redshiftBeauty_AOV_maker jhAddCons1;
separator -h 10 -p $mcl;

button -h 22 -w 200 -p $mcl -bgc .5 .5 1 -l "Create AO Layer Override" -c "redshiftAO_pass();" -en 1 rsAOLyrBtn;
separator -h 10 -p $mcl;

button -h 22 -w 200 -p $mcl -bgc 1 .5 .5 -l "Print AOV Report to Script Editor" -c "rsPrintAOVs();" -en 1 rsPrintRprtBtn;
separator -h 10 -p $mcl;

button -h 22 -w 200 -p $mcl -bgc .5 1 .5 -l "Refresh Window" -c "redshiftAOV_UI();" -en 1 rsFreshenBtn;
separator -h 10 -p $mcl;
setParent $fl;

window -e -w $w -h $h -rtf 1 redshiftAOV_UI;
showWindow redshiftAOV_UI;
}

//-------------------------------------------------------------

//redshiftAOVHelper_SelectAOVs checkBox -q -v rsEmbedCB;

global proc redshiftAOVHelper_createPropNode(){
if(`objExists "redshiftProperties"`){
print("found redshiftProperties node
");
}
else{
print("created redshiftProperties node
");
string $rsProp = `createNode "transform" -n "redshiftProperties"`;
addAttr -ln "rs_embedValue" -at bool $rsProp;
}
}

global proc rsPrintAOVs(){
//redshiftAOVHelper_createPropNode();
string $aovsThatExist[] = `ls -type "RedshiftAOV"`;
for($aovThatExists in $aovsThatExist){
print(" FOUND AOV ::: " + $aovThatExists + "
");
}
if(`objExists "AO"`)print("FOUND RENDER LAYER(S) ::: Redshift AO Override
");
print("Finished Diagnostics report - please email any questions to [email protected]
");
}

global proc redshiftAOVHelper_deleteSelectedAOVs(){
string $AOV_List[] =`textScrollList -q -si attrList2`;
string $a;
select -cl;
for($a in $AOV_List){
if(`objExists $a`)delete $a;
print("Deleting AOV ::: " + $a + "
");
}
redshiftAOV_UI();
}

global proc redshiftAOVHelper_SelectAOVs(){
string $AOV_List[] =`textScrollList -q -si attrList2`;
string $a;
select -cl;
for($a in $AOV_List){
select -add $a;
print("selecting AOV ::: " + $a + "
");
}
}
global proc redshiftAOVHelper_CreateSelectedAOVs(){
global float $rsAOVEmbedded;
string $AOV_List[] =`textScrollList -q -si attrList1`;
string $a;

for($a in $AOV_List){
//if(`objExists ("rsAov_"+$a)`){
// warning("skipping " + $a + " Redshift AOV because it already exists!
");
//}
// else{
string $aov = `rsCreateAov -type $a`;
catchQuiet(`rename $aov ($a + "_01")`);
print("creating AOV ::: " + $a + "
");
//$v = `getAttr "redshiftProperties.rs_embedValue"`;
if($rsAOVEmbedded == 1)redshiftAOVHelper_EnbedPasses();
// }
}

textScrollList -e -ra attrList2;
string $aovsThatExist[] = `ls -type "RedshiftAOV"`;
for($aovThatExists in $aovsThatExist){
textScrollList -e -append $aovThatExists attrList2;
}
catchQuiet(`redshiftAddAov`);
redshiftAOV_UI();
}

global proc redshiftAOVHelper_EnbedPasses(){
global float $rsAOVEmbedded;
$rsAOVEmbedded = 1;
//catch (`setAttr "redshiftProperties.rs_embedValue" 1`);
string $aovs[] = `ls -type "RedshiftAOV"`;
string $aov;
for($aov in $aovs)setAttr -type "string" ($aov + ".filePrefix") "<BeautyPath>/<BeautyFile>";
}

global proc redshiftAOVHelper_unEnbedPasses(){
global float $rsAOVEmbedded;
$rsAOVEmbedded = 0;
//catch (`setAttr "redshiftProperties.rs_embedValue" 0`);
string $aovs[] = `ls -type "RedshiftAOV"`;
string $aov;
for($aov in $aovs)setAttr -type "string" ($aov + ".filePrefix") "<BeautyPath>/<BeautyFile>.<RenderPass>";
}

global proc redshiftALL_AOV_maker(){
string $AOV_List[];
string $listed = "";
$listed += "World Position";
$listed += ",Depth";
//$listed += ",Puzzle Matte";
$listed += ",Motion Vectors";
$listed += ",ObjectID";
$listed += ",Diffuse Lighting";
$listed += ",Diffuse Lighting Raw";
$listed += ",Diffuse Filter";
$listed += ",Specular Lighting";
$listed += ",Sub Surface Scatter";
$listed += ",Reflections";
$listed += ",Reflections Raw";
$listed += ",Reflections Filter";
$listed += ",Refractions";
$listed += ",Refractions Raw";
$listed += ",Refractions Filter";
$listed += ",Emission";
$listed += ",Global Illumination";
$listed += ",Global Illumination Raw";
$listed += ",Caustics";
$listed += ",Caustics Raw";
$listed += ",Ambient Occlusion";
$listed += ",Shadows";
$listed += ",Normals";
$listed += ",Bump Normals";
$listed += ",Matte";
$listed += ",Volume Lighting";
$listed += ",Volume Fog Tint";
$listed += ",Volume Fog Emission";
$listed += ",Translucency Lighting Raw";
$listed += ",Translucency Filter";
$listed += ",Translucency GI Raw";
$listed += ",Total Diffuse Lighting Raw";
$listed += ",Total Translucency Lighting Raw";
$listed += ",Object-Space Positions";
$listed += ",Object-Space Bump Normals";
$AOV_List = stringToStringArray($listed, ",");
string $type;
for($type in $AOV_List){
print("Creating Redshift AOV ::: " + $type + "
");
rsCreateAov -type $type;
}
catchQuiet(`redshiftAddAov`);
}

global proc redshiftBeauty_AOV_maker(){

//redshiftAOVHelper_createPropNode();
global float $rsAOVEmbedded;
createRenderLayer -name "BTY" -number 1 -global;

string $AOV_List[];
string $listed = "";
$listed += "World Position";
$listed += ",Depth";
$listed += ",Diffuse Lighting Raw";
$listed += ",Diffuse Filter";
$listed += ",Specular Lighting";
$listed += ",Sub Surface Scatter";
$listed += ",Reflections";
$listed += ",Refractions";
$listed += ",Emission";
$listed += ",Global Illumination";
$listed += ",Caustics";
$listed += ",Ambient Occlusion";
$listed += ",Shadows";
$listed += ",Normals";

$AOV_List = stringToStringArray($listed, ",");
string $type;
for($type in $AOV_List){
string $aov = `rsCreateAov -type $type`;
catchQuiet(`rename $aov $type`);
print("creating AOV ::: " + $type + "
");
//$v = `getAttr "redshiftProperties.rs_embedValue"`;
//if($rsAOVEmbedded == 1)redshiftAOVHelper_EnbedPasses();
}

catchQuiet(`setAttr "Depth.normalizeZeroToOne" 1`);
catchQuiet(`setAttr "Depth.filterMode" 0`);
catchQuiet(`setAttr "Depth.scale" 1`);

textScrollList -e -ra attrList2;
string $aovsThatExist[] = `ls -type "RedshiftAOV"`;
for($aovThatExists in $aovsThatExist){
textScrollList -e -append $aovThatExists attrList2;
}
redshiftAO_pass();
redshiftAOVHelper_EnbedPasses();
catchQuiet(`redshiftAddAov`);
redshiftAOV_UI();
}

global proc redshiftAO_pass(){
createRenderLayer -name "AO" -number 1 -global;
string $incand = `createNode RedshiftIncandescent -name "rs_AO_Incadescent"`;
string $ao = `createNode RedshiftAmbientOcclusion -name "rs_AO_Texture"`;
connectAttr -f ($ao + ".outColor") ($incand + ".color");
string $shadingGroup = ($incand + "_SG");
sets -renderable true -noSurfaceShader true -empty -name $shadingGroup;
defaultNavigation -connectToExisting -source $incand -destination $shadingGroup;

hookShaderOverride("AO", "","rs_AO_Incadescent");
connectNodeToNodeOverride($incand, $shadingGroup);

// hookShaderOverride("layer1", "", "lambert1");
// string $meshes[] = listRelatives("-p",`ls -type "mesh"`);
// string $mesh;
// select -r $meshes;
// hyperShade -assign $incand;

//for($mesh in $meshes)sets -e -addElement $mesh $shadingGroup;
// select -cl;
}

//redshiftAOV_UI();

//print("::: CREATED DEFAULT AOVS FOR REDSHIFT :::
");

global proc redshiftAOV_Helper()
{
string $URL = "http://docs.redshift3d.com/Default.html";
showHelp -absolute $URL;
}

/*

DiffuseFilter
DiffuseLightingRaw
GlobalIlluminationRaw *
SubsurfaceScatter *
Reflections
Refractions
SpecularLighting
AO**
Caustics *
Emissions *
Depth (Theres a checkbox for Depth that says "Normalize (0 to 1)".
Lets have that on by default, Filter to Full, and Scale to 1.0)
Normals

*/

redshiftAOV_UI();
//-------------------------------------------------------------
//----------------------- end script --------------------------
//-------------------------------------------------------------

推薦閱讀:

相關文章