This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# cg_breakout.py | |
# Version: 1.0.2 | |
# Author: Dan C Bruce | |
# Contact: dancbruce@gmail.com | |
# Updated: May 13th, 2020 | |
# ----------------------------------------------------------------------------- | |
# ----------------------------------------------------------------------------- | |
# Description: | |
# | |
# Creates shuffle nodes to rebuild basic AOVs form Arnold, VRay or Redshift. | |
# ----------------------------------------------------------------------------- | |
import nuke | |
def cg_breakout(): | |
if len(nuke.selectedNodes()) == 1: | |
#Get Selected Node | |
node = nuke.selectedNode() | |
saveX = node.xpos() | |
saveY = node.ypos() | |
#Get Channels and Sort into a List | |
channels = node.channels() | |
findAOV = list( set([c.split('.')[0] for c in channels]) ) | |
findAOV.sort() | |
#Define mergenode | |
mergeNode = None | |
for aov in findAOV: | |
if ('atmosphere' in aov.lower()) == True\ | |
or ('background' in aov.lower()) == True\ | |
or ('caustic' in aov.lower()) == True\ | |
or ('coat' in aov.lower()) == True\ | |
or ('diffuse' in aov.lower()) == True\ | |
or ('emission' in aov.lower()) == True\ | |
or ('gi' in aov.lower()) == True\ | |
or ('global' in aov.lower()) == True\ | |
or ('illumination' in aov.lower()) == True\ | |
or ('lighting' in aov.lower()) == True\ | |
or ('refraction' in aov.lower()) == True\ | |
or ('reflection' in aov.lower()) == True\ | |
or ('specular' in aov.lower()) == True\ | |
or ('sss' in aov.lower()) == True\ | |
or ('transmission' in aov.lower()) == True\ | |
or ('volume' in aov.lower()) == True: | |
#Start of the Node Tree | |
if mergeNode == None: | |
node = nuke.nodes.Dot( inputs=[ node ], xpos=( node.xpos() )+34, ypos=( node.ypos()+250) ) | |
copyDot = nuke.nodes.Dot( inputs=[ node ], xpos=(node.xpos())+250, ypos=(node.ypos())) | |
mergeNode = nuke.nodes.Shuffle( label="[value in]", inputs=[ node ], xpos=node.xpos()-34, ypos=node.ypos()+50 ) | |
mergeNode['in'].setValue(aov) | |
saveY = mergeNode.ypos()+750 | |
#Loop and Build Node Tree | |
else: | |
node = nuke.nodes.Dot( inputs=[ node ], xpos=node.xpos()-250, ypos=node.ypos()) | |
shuffleNode = nuke.nodes.Shuffle( label="[value in]", inputs=[ node ], xpos=node.xpos()-34, ypos=node.ypos()+50 ) | |
shuffleNode['in'].setValue(aov) | |
dotNode = nuke.nodes.Dot( inputs=[ shuffleNode ], xpos=( node.xpos() ), ypos=saveY ) | |
mergeNode = nuke.nodes.Merge2( operation='plus', inputs=[ mergeNode , dotNode ], xpos=saveX, ypos=( dotNode.ypos()-5 ) ) | |
saveY = mergeNode.ypos()+75 | |
#Add Alpha Branch | |
if mergeNode != None: | |
copyDot = nuke.nodes.Dot( inputs=[ copyDot ], xpos=(copyDot.xpos()), ypos=saveY) | |
copyNode = nuke.nodes.Copy( inputs=[ mergeNode, copyDot ], from0="rgba.alpha", to0="rgba.alpha", xpos=(mergeNode.xpos()), ypos=(copyDot.ypos()-11)) | |
#Wrap in Backdrop | |
pad = 75 | |
backdropNode = nuke.nodes.BackdropNode(label="CG Breakout", note_font_size=42, xpos=(node.xpos()-pad), bdwidth=abs(copyDot.xpos()-node.xpos())+(pad*2) , ypos=node.ypos()-pad, bdheight=abs(copyDot.ypos()-node.ypos())+(pad*2) ) | |
else: | |
nuke.message('Invalid Selection') | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment