I have a script which applies an NiMultishader to the selected object, creates an Occlusion color set in the CSE, occludes the mesh with all correct presets, and have a window which allows you to rebake with sliders to change the settings or modify the current bake set. But, I’m having trouble with what sounds like the most simplest step, selecting colorSet1 and the Occlusion color set and blend them both into a new blendedBakeSet using an “Add” polyColorBlendMode.
Here is my script
If anyone could help that person is amazing
// Create Warning Prompt
global proc checkboxPrompt(){
// Dialog Form window.
//
string $form = `setParent -q`;
// Layout Dialog Box
formLayout -e -width 300 -height 300 $form;
string $t = `text -l "DO NOT PRESS CTRL Z OR Z After Script, close this box"`;
}
layoutDialog -ui "checkboxPrompt";
{
//place objects selected into a variable
$jrdSel=`ls -sl`;
//Delete History, Freeze Transforms, Center Pivot to World
DeleteHistory;
delete -ch;
FreezeTransformations;
performFreezeTransformations(0);
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
EnterEditMode;
ctxEditMode;
SnapToPoint;
snapMode -point (!`snapMode -q -point`);
updateSnapMasks;
move 0 0 0 $jrdSel.scalePivot $jrdSel.rotatePivot ;
SnapToPoint;
// Create Occlusion Bake Set with presets
{
$bakeSetAO=`createBakeSet OcclusionSet vertexBakeSet`;
setAttr OcclusionSet.colorMode 3;
setAttr OcclusionSet.occlusionRays 256;
setAttr OcclusionSet.occlusionFalloff 100;
setAttr OcclusionSet.normalDirection 1;
setAttr OcclusionSet.orthogonalReflection 1;
setAttr OcclusionSet.bakeColor 1;
setAttr OcclusionSet.bakeAlpha 0;
setAttr -type "string" OcclusionSet.colorSetName "Occlusion";
}
// Creates Bake Set
if ( `objExists initialTextureBakeSet` == 0 )
{
createBakeSet initialTextureBakeSet textureBakeSet;
}
if ( `objExists initialVertexBakeSet` == 0 )
{
createBakeSet initialVertexBakeSet vertexBakeSet;
}
// Assign the shape nodes to Occlusion
for ( $eachObj in $jrdSel )
{
string $shape[]=`listRelatives -s $eachObj`;
sets -forceElement OcclusionSet $shape[0];
}
// Bake selected Objects.
select -r $jrdSel;
catchQuiet ( `convertLightmapSetup -camera persp -sh -vm -showcpv` );
}
{
$jrdSel=ls -sl
;
// Assign a NiMultiShader to a combined mesh .
//
string $myShader = shadingNode -asShader NiMultiShader
;
string $NiMultiShader1SG = ($myShader + “NiMultiShader1SG”);
sets -renderable true -noSurfaceShader true
-empty -name $NiMultiShader1SG;
defaultNavigation -connectToExisting
-source $myShader
-destination $NiMultiShader1SG;
select -r $jrdSel;
sets -e -forceElement $NiMultiShader1SG;
{
$jrdSel=ls -sl
;
if (window -exists myWindow
) { deleteUI -window myWindow; }
window -rtf true -title “OcclusionReBake” myWindow;
columnLayout;
floatSliderGrp -dragCommand “findValues” -minValue 0 -maxValue 4 -label “Color Mode” -field true posCol;
floatSliderGrp -dragCommand “findValues” -minValue 1 -maxValue 256 -label “Occlusion Rays” -field true posRay;
floatSliderGrp -dragCommand “findValues” -minValue 0 -maxValue 100 -label “Occlusion Falloff” -field true posFal;
columnLayout -adjustableColumn true;
button -label “Bake” -c BatchBake;
button -label “Color Set Editor” -c “colorSetEditor”;
button -h 26 -w 80 -l “Modify Bake”
-c “colorSetEditCmd modify colorSetList”
-enable true
modifyButton;
showWindow myWindow;
proc findValues () {
float $myNumPosCol = floatSliderGrp -q -value "posCol"
;
float $myNumPosRay = floatSliderGrp -q -value "posRay"
;
float $myNumPosFal = floatSliderGrp -q -value "posFal"
;
print $myNumPosFal;
setAttr “OcclusionSet.colorMode” $myNumPosCol;
setAttr “OcclusionSet.occlusionRays” $myNumPosRay;
setAttr “OcclusionSet.occlusionFalloff” $myNumPosFal;
select -r $jrdSel;
}
HypershadeWindow;
colorSetEditor;
}
}