def matchAovs(): node = nuke.thisNode() filenames = '' for i in range(node.inputs()): #path=node[string+'_file'].value() path = node.input(i)['file'].value() #first=node[string+'first'].value() first = node.input(i)['first'].value() #last=node[string+'last'].value() last = node.input(i)['last'].value() renderString = path.split(publishPath)[-1].split('/')[0] filepath = path.split('/')[-1] filenames += filepath.split('.')[0] + '\n' #parent='/'.join(path.split('/')[:-1])#old folder structure parent = '/'.join(path.split('/')[:-2]) #refactor dirs = os.listdir(parent) if i == 1 and "diffuse_color" in dirs: #if utils, ignore diffuse color from utils dirs.remove("diffuse_color") print filepath, parent, dirs, i with node: nuke.selectAll() nuke.invertSelection() for n in nuke.allNodes('Read'): if n.name() in dirs: n['file'].setValue(parent + '/' + n.name() + '/' + filepath.replace('beauty', n.name())) n['first'].setValue(first) n['last'].setValue(last) node['label'].setValue( '[lindex [split [lindex [split [value input0.file] /] end] .] 0]\n[lindex [split [lindex [split [value input1.file] /] end] .] 0]' ) nodeName = "_".join(filepath.split('_')[:-3]) + "_REBUILD" print nodeName
def main(): nSel = nuke.selectedNodes() nuke.selectAll() nuke.invertSelection() for n in nSel: #get other passes from selected Read buildGrp(n, 0)
def setPath(): tmpWrite = nuke.createNode('WritePrism') tmpWrite.hideControlPanel() tmpWrite.knob('name').setValue('tmp_WP') fullPath = pcore.appPlugin.getOutputPath( nuke.toNode('tmp_WP').node("WritePrismBase"), nuke.selectedNode()) #print fullPath relPath = fullPath.split('01_Workflow')[0] nuke.root()['project_directory'].setValue(relPath) for i in nuke.allNodes(): nodeClass = i.Class() if nodeClass == 'Read': i.knob('selected').setValue(True) filename = i.knob('file').value() oldPath = filename.split('01_Workflow')[0] filename = filename.replace(oldPath, './') i.knob('file').setValue(filename) print "Project path is: \n" + relPath + "\n\nPath changed to relative." nuke.delete(tmpWrite) nuke.selectAll() nuke.invertSelection()
def update(self): nuke.selectAll() nuke.invertSelection() a.nodeList[self.things.currentRow()].knob('selected').setValue(True) node = nuke.selectedNode() xC = node.xpos() + node.screenWidth() / 2 yC = node.ypos() + node.screenHeight() / 2 nuke.zoom(2, [xC, yC])
def update(self): nuke.selectAll() nuke.invertSelection() a.nodeList[self.things.currentRow()].knob('selected').setValue(True) node = nuke.selectedNode() xC = node.xpos() + node.screenWidth()/2 yC = node.ypos() + node.screenHeight()/2 nuke.zoom( 2, [ xC, yC ])
def disconnectViewers(): nuke.selectAll() nuke.invertSelection() for n in nuke.allNodes(): if n.Class() == "Viewer": n['selected'].setValue(True) nuke.extractSelected()
def matchCutref(): orig_sel = nuke.selectedNodes('Read') if len(orig_sel) < 1: nk_file = nuke.Root().name() #Q:/Impulse/IMP210/05_COMP/IMP210_017_070/IMP210_017_070_Comp_V002.nk if nk_file == 'Root': nuke.message('Untitled script. You can only run this command inside of a shot script. Or you must select a plate to run this on.') return shot_name = nk_file.split('/')[-2] #IMP210_017_070 precomp_lut_dir = '/'.join(nk_file.split('/')[0:-1])+'/02_OUTPUT/01_precomp/'+shot_name+'_LUT.csp' print 'Creating matchgrade template based on nuke file name : {0}'.format(shot_name) try: c = importAssets.ImportAssets().importCutrefs()[-1] except TypeError: nuke.message('Could not find a cutref for this shot.') c = nuke.createNode('NoOp', inpanel=False) c.setSelected(False) try: p = importAssets.ImportAssets().importPlates()[0] except TypeError: nuke.message('Could not find a plate for this shot.') p = nuke.createNode('NoOp', inpanel=False) p.setSelected(False) matchgrade_setup(precomp_lut_dir,p,c) else: for p in orig_sel: plate_file = p['file'].value() #Q:/Impulse/IMP210/01_PLATES/IMP210_017_070/PLATE/PLATE_O/01_EXRS/IMP210_017_070.####.exr proj_plate_dir = grabPattern(plate_file, r".*/01_PLATES/") shot_plate_dir = grabPattern(plate_file, r".*/01_PLATES/(\w)*/") if shot_plate_dir == '': nuke.message('Are you sure the selected node is EXR/DPX plate inside the 01_PLATES directory?') return shot_comp_dir = shot_plate_dir.replace('01_PLATES', '05_COMP') shot_name = shot_comp_dir.split('/')[-2] precomp_lut_dir = shot_comp_dir + '/02_OUTPUT/01_precomp/' + shot_name + '_LUT.csp' plate_file = plate_file.replace('01_PLATES', '05_COMP') plate_file = '/'.join(plate_file.split('/')[0::-1]) print 'Creating matchgrade template based on selected read node : {0}'.format(shot_name) try: c = importAssets.ImportAssets().importCutrefs()[-1] except TypeError: nuke.message('Could not find a cutref for this shot.') c = nuke.createNode('NoOp', inpanel=False) c.setSelected(False) nuke.selectAll() nuke.invertSelection() p.setSelected(True) matchgrade_setup(precomp_lut_dir, p, c)
def getMissingFrames(node): parent = os.path.dirname(node['file'].value()) if len(nuke.getFileNameList(parent)) > 1: nuke.selectAll() nuke.invertSelection() node.setSelected(1) nuke.zoomToFitSelected() nuke.message('missing frames: ' + ",".join(nuke.getFileNameList(parent)))
def versionDown(): node = nuke.thisNode() path = node['file'].value() renderString = path.split(publishPath)[-1].split('/')[0] with node: nuke.selectAll() nuke.invertSelection() for n in nuke.allNodes('Read'): if renderString in n['file'].value(): n.setSelected(1) versionTools.version_down()
def paste_to_selected(): nodes = nuke.selectedNodes() all_nodes = nuke.allNodes() unselect() for node in nodes: node.setSelected(True) nuke.nodePaste('%clipboard') unselect() if not nodes: nuke.nodePaste('%clipboard') # Select pasted nodes select(all_nodes) nuke.invertSelection()
def replaceNode(old,new,grp): with grp: n=old # remove any previous selections to avoid unwanted wiring of the new node nuke.selectAll() nuke.invertSelection() # create a new node of the replacement Class c = new c.setXYpos(n.xpos(), n.ypos()) # connect inputs for i in range(n.inputs()): c.setInput(i,n.input(i)) # connect outputs for d in n.dependent(nuke.INPUTS,forceEvaluate=False): for input in [i for i in range(d.inputs()) if d.input(i) == n]: d.setInput(input,c) name=n.name() #delete original nuke.delete(n)
def makeGroup(self): if len(self.lista) >= 2: nuke.selectAll() nuke.invertSelection() for shuffleknob in self.sGroup: shuffleknob['selected'].setValue(True) #for shuffleknob in self.readNodes: #shuffleknob['selected'].setValue(True) node = nuke.collapseToGroup(show=False) node['xpos'].setValue(self.mainBeautyLayer.xpos()) node['ypos'].setValue(self.mainBeautyLayer.ypos() + 100) #node.autoplace() #gName = node.name() #nuke.tprint((self.mainBeautyLayer)) #nuke.toNode(gName)["name"].setValue("Exr Merge %s" %'hello') #self.nIncrement += 1 #node.lock_connections(True) else: pass
def addAssetGizmos(*args): global assetGizmos if len(args): assetGizmos = assetGizmos + '/' + args[0] nuke.selectAll() nuke.invertSelection() node = nuke.thisNode() addedGizmos = [] assetMetadata = getMetadata('Asset') with node: for n in nuke.allNodes('NoOp'): if n.name().endswith("_OUT"): aov = n.name().split("_OUT")[0] gizmos = findAssetGizmos(aov, assetMetadata) lastNode = n.dependencies()[0] addedGizmos.extend(gizmos) for g in gizmos: lastNode.setSelected(True) giz = nuke.createNode(g, inpanel=False) nuke.selectAll() nuke.invertSelection() giz.setInput(0, lastNode) giz.setXYpos(lastNode.xpos(), lastNode.ypos() + 30) giz['tile_color'].setValue(16711935) lastNode = giz n.setInput(0, lastNode) if len(addedGizmos): nuke.message('ADDING ASSETS:\n' + "\n".join(addedGizmos)) #show data aList = 'Assets:\n' for data in getMetadata2("Asset", node): aList += data + '\n' node['assetList'].setValue(aList) mList = 'Materials:\n' for data in getMetadata2("Material", node): mList += data + '\n' node['matList'].setValue(mList) eList = 'Existing:\n' for assetGizmo in getAssetGizmos2(node): eList += assetGizmo + '\n' node['existList'].setValue(eList)
def matchgrade_setup(outfile,plate,cutref): nuke.nodePaste("//qumulo/Libraries/HAL/LIVEAPPS/apps/Scripts/NUKE/scripts/MatchCutref.nk") for i in nuke.selectedNodes('MatchGrade'): i['outfile'].setValue(outfile) for i in nuke.selectedNodes('Dot'): if i['label'].value().lower() == 'plate': i.setInput(0,plate) plate['xpos'].setValue(i['xpos'].value() - plate.screenWidth()/2) plate['ypos'].setValue(i['ypos'].value() - plate.screenHeight()*2) if i['label'].value().lower() == 'cutref': i.setInput(0,cutref) cutref['xpos'].setValue(i['xpos'].value() - cutref.screenWidth()/2) cutref['ypos'].setValue(i['ypos'].value() - cutref.screenHeight()*2) nuke.selectAll() nuke.invertSelection()
def addAssets(grp): nuke.selectAll() nuke.invertSelection() addedGizmos = [] for n in nuke.allNodes('NoOp'): if n.name().endswith("_OUT"): aov = n.name().split("_OUT")[0] gizmos = findAssetGizmos(aov, grp) lastNode = n.dependencies()[0] addedGizmos.extend(gizmos) for g in gizmos: lastNode.setSelected(True) giz = nuke.createNode(g, inpanel=False) nuke.selectAll() nuke.invertSelection() giz.setInput(0, lastNode) giz.setXYpos(lastNode.xpos(), lastNode.ypos() + 30) lastNode = giz n.setInput(0, lastNode) if len(addedGizmos): nuke.message('ADDING ASSETS:\n' + "\n".join(addedGizmos))
def flopViewer(): """input process to flop the viewer""" allV = nuke.allNodes('Viewer') pV = allV[0] List = nuke.selectedNodes() nuke.selectAll() nuke.invertSelection() try: n = nuke.toNode('VIEWER_INPUT') if n.Class() == 'Mirror': n['Vertical'].setValue(not n['Vertical'].value()) for i in allV: i['input_process'].setValue(not n['Vertical'].value() + n['Horizontal'].value() == 0) if n['Vertical'].value() + n['Horizontal'].value() == 0: nuke.delete(n) nuke.selectAll() nuke.invertSelection() else: nuke.message("Another Viewer Input already exists.\nAborting to avoid conflict") except: n = nuke.Node('Mirror',inpanel=False) n['xpos'].setValue(pV.xpos()+150) n['ypos'].setValue(pV.ypos()) n['name'].setValue('VIEWER_INPUT') n['hide_input'].setValue(1) n['Vertical'].setValue(not n['Vertical'].value()) nuke.selectAll() nuke.invertSelection() for i in List: i['selected'].setValue(True) for i in List: i['selected'].setValue(True)
def create(self): for i, info in enumerate(self.infos): self.shot_code = info[0] self.base_path = info[1] cmps = self.get_comp() nuke.selectAll() nuke.invertSelection() for cmp in cmps: cmp['selected'].setValue(True) nuke.autoplace(cmp) #nuke.autoplace_all() #_autoplace() x = autoBackdrop.autoBackdrop() x['bdheight'].setValue(x['bdheight'].value() + 100) x['ypos'].setValue(x['ypos'].value() - 50) nuke.selectAll() nuke.invertSelection() p = self.get_plate() p['xpos'].setValue(x['xpos'].value() + 20) p['ypos'].setValue(x['ypos'].value() + 20) c = self.get_cutref() if c: c['xpos'].setValue(p['xpos'].value() + 100) c['ypos'].setValue(p['ypos'].value()) c['selected'].setValue(True) p['selected'].setValue(True) x['label'].setValue(self.shot_code) x['ypos'].setValue(x['ypos'].value() - 40) x['bdheight'].setValue(x['bdheight'].value() + 40) #print nuke.selectedNode()['tile_color'].value() if i % 2: x['tile_color'].setValue(1431655935) else: x['tile_color'].setValue(2088533247)
def matchAovs(): node = nuke.thisNode() filenames = '' for i in range(node.inputs()): #path=node[string+'_file'].value() path = node.input(i)['file'].value() #first=node[string+'first'].value() first = node.input(i)['first'].value() #last=node[string+'last'].value() last = node.input(i)['last'].value() renderString = path.split(publishPath)[-1].split('/')[0] filepath = path.split('/')[-1] filenames += filepath.split('.')[0] + '\n' #parent='/'.join(path.split('/')[:-1])#old folder structure parent = '/'.join(path.split('/')[:-2]) #refactor dirs = os.listdir(parent) #attempt to remove any lighting aovs that are misplaced in Utils to avoid incorrect renders if i == 1: for la in lightingAovs: if la in dirs: dirs.remove(la) print filepath, parent, dirs, i with node: nuke.selectAll() nuke.invertSelection() for n in nuke.allNodes('Read'): if n.name() in dirs: n['file'].setValue(parent + '/' + n.name() + '/' + filepath.replace('beauty', n.name())) n['first'].setValue(first) n['last'].setValue(last) node['label'].setValue( '[lindex [split [lindex [split [value input0.file] /] end] .] 0]\n[lindex [split [lindex [split [value input1.file] /] end] .] 0]' ) nodeName = "_".join(filepath.split('_')[:-3]) + "_REBUILD" print nodeName
def deselectAll(self): #Select All to invert the selection XD nuke.selectAll() nuke.invertSelection()
def buildAOV(node, title, passes, operation, divide, lastMerge, color, function): prior = node shufs = [] for p in passes: sh = nuke.nodes.Shuffle() sh['in'].setValue(p) sh['label'].setValue('[value in]') sh.setInput(0, prior) if node.Class() != "Shuffle": sh.setXYpos(prior.xpos(), prior.ypos() + 200) if node.Class() == "Shuffle": sh.setXYpos(prior.xpos() + 400, prior.ypos()) if prior != node: sh.setXYpos(prior.xpos() + 200, prior.ypos()) prior = sh shufs.append(sh) allNodes = shufs nodes = [] if divide: for sh in shufs: m = mergeDivide(sh, "diffuse_color") nodes.append(m) else: for sh in shufs: u = unPremultNode(sh) nodes.append(u) allNodes.extend(nodes) m = multiPlus(nodes) gizmos = findAssetGizmos(m, title) lastNode = m for g in gizmos: giz = nuke.createNode(g) nuke.selectAll() nuke.invertSelection() giz.setInput(0, lastNode) giz.setXYpos(lastNode.xpos(), lastNode.ypos() + 30) lastNode = giz noOp = nuke.nodes.NoOp() noOp.setName(title + "_OUT") noOp.setInput(0, lastNode) noOp.setXYpos(lastNode.xpos(), lastNode.ypos() + 400) merge = nuke.nodes.Merge2() merge.setInput(0, noOp) merge.setInput(1, noOp) if lastMerge: merge.setInput(0, lastMerge) merge.setName(title + "_MERGE") merge['operation'].setValue(operation) merge['output'].setValue('rgb') merge.setXYpos(noOp.xpos(), noOp.ypos() + 80) allNodes.append(m) allNodes.append(noOp) allNodes.append(merge) b = buildBackdrop(allNodes) if m.inputs() < 2: nuke.delete(m) b.setName(title + "_BACKDROP") b['label'].setValue(title) b['tile_color'].setValue(int(color)) noOpKnob = nuke.String_Knob('noOp') mergeKnob = nuke.String_Knob('merge') b.addKnob(noOpKnob) b.addKnob(mergeKnob) b['noOp'].setValue(noOp.name()) b['merge'].setValue(merge.name()) if function: globals()[function](noOp) return prior, merge
def main(): if nuke.root().name() == 'Root': nuke.message('save file in shot directory before running script') scriptRoot = nuke.root().name().split("/nuke/")[0] scriptName = nuke.root().name().split("/nuke/")[1].split(".nk")[0] scriptShot = scriptName.split("_")[0] scriptVersion = scriptName.split("_")[-1] nSel = nuke.selectedNodes() if len(nSel) and nuke.root().name() != 'Root': continu, viewOrder = setViews(nSel) #viewOrder.reverse() if not continu: return #jv=nuke.nodes.JoinViews() #for i,n in enumerate(nSel): # jv.setInput(i,n) jvx, jvy = getNodeAvgPos(nSel) #jv.setXYpos(jvx,jvy+200) #get min depth from renders tmpM = multiPlus(nSel) tmpM['Achannels'].setValue('uPointCamera') tmpM['Bchannels'].setValue('uPointCamera') nd = nuke.nodes.ML_normalizeDepth() nd.setInput(0, tmpM) nd['script'].execute() far = nd['whitepoint'].value() if 'inf' in str(far): far = -100000 nuke.delete(tmpM) nuke.delete(nd) #deselect nuke.selectAll() nuke.invertSelection() backView = '' rebuilds = [] #add rebuild group from template for i, v in enumerate(nSel): rebuild = nuke.nodePaste(rebuildTemplate) rebuild.setInput(0, v) rebuild.setXYpos(v.xpos(), v.ypos() + 100) rebuild.setName(viewOrder[i] + '_Rebuild') rebuilds.append(rebuild) if not backView: backView = rebuild #place far in atmosGrade with rebuild: depth = nuke.toNode('ML_normalizeDepth1') depth['whitepoint'].setValue(far) nuke.selectAll() nuke.invertSelection() viewOrder = rebuilds viewOrder.reverse() priorMerge = '' m = viewOrder[0] for i, view in enumerate(viewOrder): if i < len(viewOrder) - 1: m = nuke.nodes.Merge2() m['operation'].setValue('over') m['also_merge'].setValue('all') m.setXYpos(view.xpos(), view.ypos() + 600) if i > 0: d = nuke.nodes.Dot() d.setInput(0, view) d.setXYpos(view.xpos() + 40, priorMerge.ypos()) priorMerge.setInput(1, d) if not priorMerge: m.setInput(0, view) if priorMerge and i < len(viewOrder) - 1: m.setInput(0, priorMerge) m.setXYpos(priorMerge.xpos(), priorMerge.ypos() + 100) priorMerge = m #add lightwrap lw = nuke.nodes.chromaLumaLightwrap() lw.setInput(0, priorMerge) lw.setXYpos(priorMerge.xpos(), priorMerge.ypos() + 200) #add backplate setup vb = createBackplate(lw, far) #connect backplate d = nuke.nodes.Dot() d.setInput(0, vb) d.setXYpos(vb.xpos() + 400, vb.ypos()) lw.setInput(1, d) m = nuke.nodes.Merge2() m.setInput(0, lw) m.setInput(1, d) m['operation'].setValue('under') m.setXYpos(lw.xpos(), d.ypos()) m['also_merge'].setValue('all') #add prelut shuffle #sh=nuke.nodes.Shuffle() #sh.setInput(0,m) #sh.setXYpos(m.xpos(),m.ypos()+400) #insertToNewChannel(sh,"preLut","rbga") #sh['in'].setValue("rgba") #add LUT gizmo, Why does attah to camera? #lutGizmo=findLUTGizmos() #lastNode=sh #for g in lutGizmo: # giz=nuke.createNode(g) # giz.setXYpos(lastNode.xpos(),lastNode.ypos()+200) # giz.setInput(0,lastNode) # lastNode=giz #add keepChannels keep = nuke.nodes.multiKeepChannels() keep.setInput(0, m) #keep['channels2'].setValue('startRGBA') #keep['channels3'].setValue('preLut') #add grain grain = nuke.nodes.LumaGrain2() grain.setInput(0, keep) #add text info #txt=nuke.nodes.Text() #txt['message'].setValue('[ lrange [split [ basename [ value root.name ] ] . ] 0 0 ]\n[frame]') #txt['translate'].setValue([0,0]) #txt['size'].setValue(50) #txt['box'].setValue([0,120,1920,0]) #txt.setInput(0,grain) #txt['font'].setValue('C:/Windows/Fonts/arial.ttf') #txt['xjustify'].setValue('left') #txt['yjustify'].setValue('center') #add metadata #taskDictionary=getShotgunTaskData(scriptShot) taskDictionary = {} metaDataNode = createMetaDataNode(taskDictionary, grain) #add crop cr = nuke.nodes.Crop() cr['crop'].setValue(0) cr.setInput(0, metaDataNode) cr['box'].setValue([0, 0, nuke.root().width(), nuke.root().height()]) #add writeOut w = nuke.nodes.Write() w.setInput(0, cr) w.setName('comp') w['channels'].setValue('all') w['file_type'].setValue('exr') renderPath = scriptRoot + '/_renders/nuke/' + scriptName + '/' + w.name( ) + '/exr/' + scriptShot + '_' + w.name( ) + '_' + scriptVersion + '.%04d.exr' w['file'].setValue(renderPath) w['metadata'].setValue('all metadata') #forceSingleView() from mlScripts import gizmoTools gizmoTools.findMissingAssetGizmos.main()
def rebuildGroup(thisNode): n=nuke.nodes.Read() n['file'].setValue(thisNode['file'].value()) n['first'].setValue(thisNode['first'].value()) n['last'].setValue(thisNode['last'].value()) nuke.selectAll() nuke.invertSelection() n.setSelected(True) #get other passes from selected Read filename=n['file'].value().split('/')[-1] task = nuke.ProgressTask("getRenders") task.setMessage( 'processing %s' % filename ) grp=nuke.collapseToGroup(n) myGroup=nuke.toNode(grp.name()) n= nuke.allNodes('Read',group=myGroup)[0] n['name'].setValue("HeroRead") f=n['file'].value() dir=os.path.dirname(f) seqData=findRendersFromDirectory(dir) uniquePaths,uniqueNames,commonPath,commonName=seqData #return message of number of sequences found #nuke.message(str(len(uniqueNames)) +' sequences found:'+"\n"+"\n".join(uniqueNames)) nodes=[] sh='' priorShuffle='' with grp: for p,each in enumerate(uniqueNames): if not each=="": #create read node, set expressions r=nuke.nodes.Read() r['file'].setValue(commonPath+uniquePaths[p]) r['first'].setExpression("HeroRead.first") r['last'].setExpression("HeroRead.last") r['on_error'].setExpression("HeroRead.on_error") r['name'].setValue(each) if 'Crypto' in each: print each #store cryptoAsset for metadata fetching if 'CryptoAsset' in each: cryptoMaterialExists=r chanDict=getChannelsAsDictionary(r) for ch in chanDict.keys(): #create shuffleCopy and setup sh=nuke.nodes.ShuffleCopy() sh.setInput(1,ref) if not priorShuffle: sh.setInput(0,n) if priorShuffle: sh.setInput(0,priorShuffle) sh['in'].setValue(ch) sh['in2'].setValue('rgba') nuke.tcl('add_layer { '+ch+' '+ch+'.red '+ch+'.green '+ch+'.blue '+ch+'.alpha}') sh['out'].setValue('none') sh['out2'].setValue(ch) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') sh['green2'].setValue('alpha') sh['label'].setValue('[value out2]') #add to array priorShuffle=sh nodes.append(r) else: #create shuffleCopy and setup sh=nuke.nodes.ShuffleCopy() sh.setInput(1,ref) if not priorShuffle: ref=nuke.nodes.Reformat() ref.setInput(0,n) sh.setInput(0,ref) heroRef=ref if priorShuffle: sh.setInput(0,priorShuffle) sh['in'].setValue('rgba') sh['in2'].setValue('rgba') nuke.tcl('add_layer { '+each+' '+each+'.red '+each+'.green '+each+'.blue '+each+'.alpha}') sh['out'].setValue('none') sh['out2'].setValue(each) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') if 'rgba.alpha' in r.channels(): sh['green2'].setValue('alpha') else: sh['green2'].setValue('alpha2') sh['label'].setValue('[value out2]') #add to array priorShuffle=sh nodes.append(r) task.setProgress( int( float(p) / len(uniqueNames) *100) ) #avoid consolidate if not lighting pass reads if 'direct_specular.red' in sh.channels(): c=consolidateChannels(sh,['direct_specular','direct_specular_2'],'spec') sh=consolidateChannels(c,['indirect_specular','indirect_specular2','indirect_specular_2'],'indirect_spec') #create combined asset mattes sh=buildAssetMattes(sh) sh2=sh #add startRGBA channel sh=nuke.nodes.Shuffle() sh['in'].setValue('rgba') nuke.tcl('add_layer { '+'startRGBA'+' '+'startRGBA'+'.red '+'startRGBA'+'.green '+'startRGBA'+'.blue '+'startRGBA'+'.alpha}') sh['out'].setValue('startRGBA') sh.setInput(0,sh2) nuke.toNode('Output1').setInput(0,sh) nuke.toNode('Output1').setXYpos(sh.xpos(),sh.ypos()+80) createReadGroup(n,grp) del(task) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") file=grp['file'].value() fName=file.split('/')[-1].split('.')[0] regex = re.compile("v[0-9]{2,9}") vers=regex.findall(file)[0] grp['label'].setValue(fName+'\n'+vers) grp.setXYpos(thisNode.xpos(),thisNode.ypos()) #reconnect to old group connections connections=getConnections(thisNode) for c in connections.keys(): nuke.toNode(c).setInput(connections[c],grp) nuke.delete(thisNode) #using 'scripts' in call because 'scripts' is currently called during import of all script files pyButtonLatest = nuke.PyScript_Knob('updateVersion', "updateToLatest", "mlScripts.arnoldGatherBty.updateLatest()") pyButtonLatest.setFlag(nuke.STARTLINE) pyButtonUp = nuke.PyScript_Knob('verionUp', "versionUp", "mlScripts.arnoldGatherBty.versionUp()") pyButtonDown = nuke.PyScript_Knob('verionDown', "versionDown", "mlScripts.arnoldGatherBty.versionDown()") grp.addKnob(pyButtonLatest) grp.addKnob(pyButtonUp) grp.addKnob(pyButtonDown) nuke.selectAll() nuke.invertSelection()
def main(): nSel = nuke.selectedNodes() nuke.selectAll() nuke.invertSelection() for n in nSel: n.setSelected(True) #get other passes from selected Read filename = n['file'].value().split('/')[-1] task = nuke.ProgressTask("getRenders") task.setMessage('processing %s' % filename) grp = nuke.collapseToGroup(n) myGroup = nuke.toNode(grp.name()) n = nuke.allNodes('Read', group=myGroup)[0] n['name'].setValue("HeroRead") f = n['file'].value() dir = os.path.dirname(f) seqData = findRendersFromDirectory(dir) uniquePaths, uniqueNames, commonPath, commonName = seqData #return message of number of sequences found #nuke.message(str(len(uniqueNames)) +' sequences found:'+"\n"+"\n".join(uniqueNames)) nodes = [] sh = '' priorShuffle = '' with grp: for p, each in enumerate(uniqueNames): if not each == "": #create read node, set expressions r = nuke.nodes.Read() r['file'].setValue(commonPath + uniquePaths[p]) r['first'].setExpression("HeroRead.first") r['last'].setExpression("HeroRead.last") r['on_error'].setExpression("HeroRead.on_error") r['name'].setValue(each) #get number of channels within node, built out shuffleCopy for each node #chanDict=getChannelsAsDictionary(r) #for ch in chanDict.keys(): #create shuffleCopy and setup sh = nuke.nodes.Copy() sh.setInput(1, r) if not priorShuffle: sh.setInput(0, n) if priorShuffle: sh.setInput(0, priorShuffle) sh['from0'].setValue("none") sh['to0'].setValue("none") sh['channels'].setValue("all") #sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) task.setProgress(int(float(p) / len(uniqueNames) * 100)) #create combined asset mattes sh = buildAssetMattes(sh) nuke.toNode('Output1').setInput(0, sh) nuke.toNode('Output1').setXYpos(sh.xpos(), sh.ypos() + 80) createReadGroup(n, grp) del (task) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") file = grp['file'].value() fName = file.split('/')[-1].split('.')[0] regex = re.compile("v[0-9]{2,9}") vers = regex.findall(file)[0] grp['label'].setValue(fName + '\n' + vers) #using 'scripts' in call because 'scripts' is currently called during import of all script files #pyButton = nuke.PyScript_Knob('updateVersion', "updateToLatest", "scripts.arnoldGatherBty.updateLatest()") #pyButton.setFlag(nuke.STARTLINE) #grp.addKnob(pyButton) nuke.selectAll() nuke.invertSelection()
def buildGrp(n, rebuild): filename = n['file'].value().split('/')[-1] if rebuild: thisNode = n n = nuke.nodes.Read() n['file'].setValue(thisNode['file'].value()) n['first'].setValue(thisNode['first'].value()) n['last'].setValue(thisNode['last'].value()) nuke.selectAll() nuke.invertSelection() n.setSelected(True) #get other passes from selected Read filename = n['file'].value().split('/')[-1] task = nuke.ProgressTask("getRenders") task.setMessage('processing %s' % filename) f = n['file'].value() dir = os.path.dirname(f) seqData = findRendersFromDirectory(dir) if seqData: n.setSelected(True) grp = nuke.collapseToGroup(n) myGroup = nuke.toNode(grp.name()) n = nuke.allNodes('Read', group=myGroup)[0] n['name'].setValue("HeroRead") n['knobChanged'].setValue( "kn=[\"before\",\"cacheLocal\",\"premultiplied\",\"format\",\"after\",\"on_error\",\"last\",\"colorspace\",\"first\"]\nn=nuke.thisNode()\nk=nuke.thisKnob()\nif k.name() in kn:\n for node in nuke.allNodes():\n if k.name() in node.knobs(): node[k.name()].setValue(n[k.name()].value())" ) uniquePaths, uniqueNames, commonPath, commonName, version = seqData #ignore cryptoMatte in lightingRenders if not 'uBasic' in filename: uBasicRemove = [] for uN in uniqueNames: print uN if uN.startswith('u'): print 'remove' uBasicRemove.append(uN) for uR in uBasicRemove: uniqueNames.remove(uR) print uniqueNames #return message of number of sequences found #nuke.message(str(len(uniqueNames)) +' sequences found:'+"\n"+"\n".join(uniqueNames)) nodes = [] sh = '' priorShuffle = '' cryptoMaterialExists = 0 with grp: for p, each in enumerate(uniqueNames): if not each == "": #create read node, set expressions r = nuke.nodes.Read() r['file'].setValue(commonPath + uniquePaths[p].replace( '.####', version + '.####')) #add version back into uniquePath #r['file'].setValue(commonPath+uniquePaths[p]) #r['first'].setExpression("HeroRead.first") #r['last'].setExpression("HeroRead.last") r['first'].setValue(n['first'].value()) r['last'].setValue(n['last'].value()) r['on_error'].setValue(n['on_error'].value()) r['name'].setValue(each) ref = nuke.nodes.Reformat() ref.setInput(0, r) if 'Crypto' in each: #store cryptoAsset for metadata fetching if 'CryptoAsset' in each: cryptoMaterialExists = r chanDict = getChannelsAsDictionary(r) for ch in chanDict.keys(): #create shuffleCopy and setup sh = nuke.nodes.ShuffleCopy() sh.setInput(1, ref) if not priorShuffle: sh.setInput(0, n) if priorShuffle: sh.setInput(0, priorShuffle) sh['in'].setValue(ch) sh['in2'].setValue('rgba') nuke.tcl('add_layer { ' + ch + ' ' + ch + '.red ' + ch + '.green ' + ch + '.blue ' + ch + '.alpha}') sh['out'].setValue('none') sh['out2'].setValue(ch) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') sh['green2'].setValue('alpha') sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) else: #create shuffleCopy and setup sh = nuke.nodes.ShuffleCopy() sh.setInput(1, ref) if not priorShuffle: ref = nuke.nodes.Reformat() ref.setInput(0, n) sh.setInput(0, ref) heroRef = ref if priorShuffle: sh.setInput(0, priorShuffle) sh['in'].setValue('rgba') sh['in2'].setValue('rgba') nuke.tcl('add_layer { ' + each + ' ' + each + '.red ' + each + '.green ' + each + '.blue ' + each + '.alpha}') sh['out'].setValue('none') sh['out2'].setValue(each) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') if 'rgba.alpha' in r.channels(): sh['green2'].setValue('alpha') else: sh['green2'].setValue('alpha2') sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) task.setProgress(int(float(p) / len(uniqueNames) * 100)) #avoid consolidate if not lighting pass reads if 'direct_specular.red' in sh.channels(): c = consolidateChannels( sh, ['direct_specular', 'direct_specular_2'], 'spec') sh = consolidateChannels(c, [ 'indirect_specular', 'indirect_specular2', 'indirect_specular_2' ], 'indirect_spec') #create combined asset mattes sh = buildAssetMattes(sh) #build hair Mattes sh = buildHairMattes(sh) sh2 = sh #add startRGBA channel sh = nuke.nodes.Shuffle() sh['in'].setValue('rgba') nuke.tcl('add_layer { ' + 'startRGBA' + ' ' + 'startRGBA' + '.red ' + 'startRGBA' + '.green ' + 'startRGBA' + '.blue ' + 'startRGBA' + '.alpha}') sh['out'].setValue('startRGBA') sh.setInput(0, sh2) if 'spec.red' in sh.channels(): sh = buildRemainderChannel(sh) copyBB = nuke.nodes.CopyBBox() copyBB.setInput(0, sh) copyBB.setInput(1, heroRef) if cryptoMaterialExists: metaNode = nuke.nodes.CopyMetaData() metaNode.setInput(0, copyBB) metaNode.setInput(1, cryptoMaterialExists) copyBB = metaNode nuke.toNode('Output1').setInput(0, copyBB) nuke.toNode('Output1').setXYpos(copyBB.xpos(), copyBB.ypos() + 80) createReadGroup(n, grp) del (task) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") file = grp['file'].value() fName = file.split('/')[-1].split('.')[0] regex = re.compile("v[0-9]{2,9}") vers = regex.findall(file)[0] grp['label'].setValue( '[lindex [split [lindex [split [value file] /] end] .] 0] ') if rebuild: grp.setXYpos(thisNode.xpos(), thisNode.ypos()) #reconnect to old group connections connections = getConnections(thisNode) for c in connections.keys(): nuke.toNode(c).setInput(connections[c], grp) nuke.delete(thisNode) #using 'scripts' in call because 'scripts' is currently called during import of all script files #pyButtonLatest = nuke.PyScript_Knob('updateVersion', "updateToLatest", "mlScripts.GatherAovs_Arnold.updateLatest()") #pyButtonLatest.setFlag(nuke.STARTLINE) #pyButtonUp = nuke.PyScript_Knob('verionUp', "versionUp", "import mlPipeline\nfrom mlPipeline import ml_pipelineTools\nreload(mlPipeline.ml_pipelineTools)\nmlPipeline.ml_pipelineTools.versionUp()") #pyButtonDown = nuke.PyScript_Knob('verionDown', "versionDown", "import mlPipeline\nfrom mlPipeline import ml_pipelineTools\nreload(mlPipeline.ml_pipelineTools)\nmlPipeline.ml_pipelineTools.versionDown()") #grp.addKnob(pyButtonLatest) #grp['on_error'].setValue(3) grp['knobChanged'].setValue( "kn=[\"postage_stamp\",\"disable\"]\nn=nuke.thisNode()\nk=nuke.thisKnob()\nif k.name() in kn:\n for node in nuke.allNodes():\n if node.Class()==\"Read\": node[k.name()].setValue(n[k.name()].value())" ) #grp.addKnob(pyButtonUp) #grp.addKnob(pyButtonDown) nuke.selectAll() nuke.invertSelection()
def deselect_all(): """Deselect All""" #Select All to invert the selection XD nuke.selectAll() nuke.invertSelection()
def _clearSelection(): nuke.selectAll() nuke.invertSelection()
def autoComp(): node = nuke.selectedNode() nodesToSelect = [] readNodes = [] nodesToSelect.append(node) def climb(node): for n in node.dependencies(): nodesToSelect.append(n) climb(n) climb(node) for i in nodesToSelect: if 'read' in i.name().lower(): readNodes.append(i) if len(readNodes) > 0: readNode = readNodes[0] elemID = (readNode['file'].value().split('/')[-1]).split('.')[0] else: elemID = '' print elemID tileWidth = nuke.toNode("preferences")['TileWidth'].value() dotScale = nuke.toNode("preferences")['dot_node_scale'].value() dot_offset = (tileWidth / 2) - ((dotScale * 10) / 2) nodeXOffset = 150 nodeYOffset = 150 firstDot = nuke.createNode('Dot', inpanel=False) firstDot.setInput(0, node) firstDot['xpos'].setValue(node['xpos'].value()) firstDot['ypos'].setValue(node['ypos'].value() + nodeYOffset) firstDot['label'].setValue(elemID) firstDot['note_font_size'].setValue(100) c = ''' dinput=nuke.thisNode().input(0) elem = (dinput['file'].value().split('/')[-1]).split('.')[0] nuke.thisNode()['label'].setValue(elem) ''' pyk = nuke.PyScript_Knob('update_name', 'Update Name', c) firstDot.addKnob(pyk) lastDot = nuke.createNode('Dot', inpanel=False) lastDot.setInput(0, node) lastDot['xpos'].setValue(node['xpos'].value()) lastDot['ypos'].setValue(node['ypos'].value() + nodeYOffset) nuke.selectAll() nuke.invertSelection() node = firstDot #it craetes a temp lastDot node, to preserve the connected nodes, it then conencts itself to the output node and deletes itself... :) #node = lastDot channels = node.channels() layers = list(set([c.split('.')[0] for c in channels])) layers.sort() #print layers createGrades = True # grades for Basic Layers processAO = True # process ambient occlusion processFA = True # fake atmosphere setup and connection showInputs = True # Hide lines of shuffles and remove dots above them basicLayers = [] #rawLight, diff, rawGI, spec, refl, selfIllum, sss rawLight_Layers = [] #rawLight broken out rawSpec_Layers = [] #spec broken out selectionLayers = [] #mattes xtex_Layers = [] #extra textures extraLayers = [] #all others splitRawLight = False splitRawSpec = False cryptomattes = False basicLayerTemplate = [ 'diffuse', 'rawGI', 'rawLight', 'reflect', 'specular' ] for layer in layers: ### Basic breakout if layer.lower() == 'diffuse': basicLayers.append(layer) if layer.lower() == 'rawgi': basicLayers.append(layer) if layer.lower() == 'rawlight': basicLayers.append(layer) if layer.lower() == 'reflect': basicLayers.append(layer) if layer.lower() == 'specular': basicLayers.append(layer) if layer.lower() == 'selfillum': basicLayers.append(layer) if layer.lower() == 'refract': basicLayers.append(layer) if layer.lower() == 'sss': basicLayers.append(layer) ### Selection breakout if layer.lower() == 'matteshadow': selectionLayers.append(layer) if layer.lower() == 'ambocc': selectionLayers.append(layer) if layer.lower() == 'n': selectionLayers.append(layer) if 'normal' in layer.lower(): selectionLayers.append(layer) if 'matte' in layer.lower(): selectionLayers.append(layer) if 'materialid' in layer.lower(): selectionLayers.append(layer) if layer.lower() == 'depth': selectionLayers.append(layer) if layer.lower() == 'zdepth': selectionLayers.append(layer) if layer.lower() == 'displacement': selectionLayers.append(layer) if 'atmos' in layer.lower(): selectionLayers.append(layer) ### RawLight breakout if 'raw_' in layer.lower() and '_spec' not in layer.lower(): rawLight_Layers.append(layer) splitRawLight = True if 'rawlight_' in layer.lower(): rawLight_Layers.append(layer) splitRawLight = True if 'light_raw' in layer.lower(): rawLight_Layers.append(layer) splitRawLight = True if 'lightsel' in layer.lower(): rawLight_Layers.append(layer) splitRawLight = True if 'lsel_' in layer.lower(): rawLight_Layers.append(layer) splitRawLight = True if 'ls_' in layer.lower() and '_spec' not in layer.lower(): rawLight_Layers.append(layer) splitRawLight = True ### Specular breakout if '_specular' in layer.lower(): rawSpec_Layers.append(layer) splitRawSpec = True if 'specular_' in layer.lower(): rawSpec_Layers.append(layer) splitRawSpec = True if 'spec_' in layer.lower(): rawSpec_Layers.append(layer) splitRawSpec = True if '_spec' in layer.lower(): rawSpec_Layers.append(layer) splitRawSpec = True ### Extra Textures breakout if '_xtex' in layer.lower(): xtex_Layers.append(layer) if 'xtex_' in layer.lower(): xtex_Layers.append(layer) basicLayers = list(set(basicLayers)) rawLight_Layers = list(set(rawLight_Layers)) rawSpec_Layers = list(set(rawSpec_Layers)) selectionLayers = list(set(selectionLayers)) #last item will be added first if 'matteShadow' in selectionLayers: selectionLayers.remove('matteShadow') selectionLayers.insert(0, 'matteShadow') if 'depth' in selectionLayers: selectionLayers.remove('depth') selectionLayers.insert(0, 'depth') if 'AmbOcc' in selectionLayers: selectionLayers.remove('AmbOcc') selectionLayers.insert(0, 'AmbOcc') if 'atmosphere' in selectionLayers: selectionLayers.remove('atmosphere') selectionLayers.insert(0, 'atmosphere') #selectionLayers.append('AmbOcc') xtex_Layers = list(set(xtex_Layers)) extraLayers = list( set(layers) - set(basicLayers + rawLight_Layers + rawSpec_Layers + selectionLayers + xtex_Layers)) extraLayers = list(set(extraLayers)) extraLayers.remove('rgba') basicLayersOrder = { 'rawLight': 0, 'diffuse': 1, 'rawGI': 2, 'SSS': 3, 'selfIllum': 4, 'reflect': 5, 'specular': 6, 'refract': 7 } basicLayers = sorted(basicLayers, key=basicLayersOrder.__getitem__) ##Print out layer information def pr(a, b): if len(b) > 0: print "" print str(a) + str(b) pr('All Layers: ', layers) pr('Basic Layers: ', basicLayers) pr('RawLight Layers: ', rawLight_Layers) pr('Specular Layers: ', rawSpec_Layers) pr('Selection Layers: ', selectionLayers) pr('Extra Textrue Layers: ', xtex_Layers) pr('Unexpected Layers: ', extraLayers) merges = [] dotCount = 0 rsn = 0 for i in rawSpec_Layers: rsn += 1 ##basic nodes basicLayerNodes = [] bln = 0 blnLength = len(basicLayers) bnLastNode = None dots = [] shuffles = [] tempNode = node for layer in basicLayers: layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(node['ypos'].value() + nodeYOffset * 0.5) layerDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset * bln) + dot_offset) layerDot.setInput(0, tempNode) tempNode = layerDot dots.append(layerDot) shuf = nuke.createNode('Shuffle', inpanel=False) shuf['in'].setValue(layer) shuf['in2'].setValue('alpha') shuf['alpha'].setValue('red2') shuf['label'].setValue(layer) shuf['postage_stamp'].setValue(True) shuf['tile_color'].setValue(4234105727) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() + (nodeXOffset * bln)) basicLayerNodes.append(shuf) shuffles.append(shuf) shuf.setInput(0, layerDot) if shuf['label'].value() == 'rawLight': ''' rawLight_m = nuke.createNode("MergeExpression", inpanel=False) rawLight_m['expr0'].setValue('(((!isnan(Br/Ba))?Br/Ba:0)*((!isnan(Ar/Aa))?Ar/Aa:0))*Ba') rawLight_m['expr1'].setValue('(((!isnan(Bg/Ba))?Bg/Ba:0)*((!isnan(Ag/Aa))?Ag/Aa:0))*Ba') rawLight_m['expr2'].setValue('(((!isnan(Bb/Ba))?Bb/Ba:0)*((!isnan(Ab/Aa))?Ab/Aa:0))*Ba') rawLight_m['expr3'].setValue('Ba') ''' rawLight_m = nuke.createNode("Merge2", "operation multiply", False) rawLight_m['output'].setValue('rgb') rawLight_m['xpos'].setValue(shuf['xpos'].value()) rawLight_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 4) rawLight_s = shuf rawLight_m.setInput(1, shuf) #merges.append(rawLight_m) if shuf['label'].value() == 'diffuse': diffuse_s = shuf diff_dot = nuke.createNode("Dot", inpanel=False) diff_dot.setInput(0, shuf) diff_dot['xpos'].setValue(shuf['xpos'].value() + 35) diff_dot['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 3.4) diffuse_m = nuke.createNode("Merge2", "operation plus", False) diffuse_m['xpos'].setValue(diffuse_s['xpos'].value()) diffuse_m['ypos'].setValue(diffuse_s['ypos'].value() + nodeYOffset * 4) merges.append(diffuse_m) diff_dot2 = nuke.createNode("Dot", inpanel=False) diff_dot2['xpos'].setValue(diffuse_m['xpos'].value() + 35) diff_dot2['ypos'].setValue(diffuse_m['ypos'].value() + nodeYOffset) bnLastNode = diff_dot2 if shuf['label'].value() == 'rawGI': rawGI_s = shuf ''' rawGI_m = nuke.createNode("MergeExpression", inpanel=False) rawGI_m['expr0'].setValue('(((!isnan(Br/Ba))?Br/Ba:0)*((!isnan(Ar/Aa))?Ar/Aa:0))*Ba') rawGI_m['expr1'].setValue('(((!isnan(Bg/Ba))?Bg/Ba:0)*((!isnan(Ag/Aa))?Ag/Aa:0))*Ba') rawGI_m['expr2'].setValue('(((!isnan(Bb/Ba))?Bb/Ba:0)*((!isnan(Ab/Aa))?Ab/Aa:0))*Ba') rawGI_m['expr3'].setValue('Ba') ''' rawGI_m = nuke.createNode("Merge2", "operation multiply", False) rawGI_m['output'].setValue('rgb') rawGI_m['xpos'].setValue(shuf['xpos'].value()) rawGI_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 4) rawGI_m.setInput(1, shuf) #merges.append(rawGI_m) if shuf['label'].value() == 'SSS': sss_s = shuf sss_m = nuke.createNode("Merge2", "operation plus", False) sss_m['xpos'].setValue(shuf['xpos'].value()) sss_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) sss_m.setInput(0, bnLastNode) sss_m.setInput(1, shuf) bnLastNode = sss_m merges.append(sss_m) if shuf['label'].value() == 'refract': refract_s = shuf refract_m = nuke.createNode("Merge2", "operation plus", False) refract_m['xpos'].setValue(shuf['xpos'].value()) refract_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) refract_m['disable'].setValue(True) refract_m.setInput(0, bnLastNode) refract_m.setInput(1, shuf) bnLastNode = refract_m merges.append(refract_m) if shuf['label'].value() == 'reflect': reflect_s = shuf reflect_m = nuke.createNode("Merge2", "operation plus", False) reflect_m['xpos'].setValue(shuf['xpos'].value()) reflect_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) reflect_m.setInput(0, bnLastNode) reflect_m.setInput(1, shuf) bnLastNode = reflect_m merges.append(reflect_m) if shuf['label'].value() == 'specular': specular_s = shuf specular_m = nuke.createNode("Merge2", "operation plus", False) specular_m['xpos'].setValue(shuf['xpos'].value()) specular_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) specular_m.setInput(0, bnLastNode) specular_m.setInput(1, shuf) bnLastNode = specular_m merges.append(specular_m) if shuf['label'].value() == 'selfIllum': selfIllum_m = nuke.createNode("Merge2", "operation plus", False) selfIllum_m['xpos'].setValue(shuf['xpos'].value()) selfIllum_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) selfIllum_m.setInput(0, bnLastNode) selfIllum_m.setInput(1, shuf) bnLastNode = selfIllum_m merges.append(selfIllum_m) selfIllum_s = shuf bln += 1 try: rawLight_m.setInput(0, diff_dot) except: pass try: rawGI_m.setInput(0, diff_dot) except: pass try: diffuse_m.setInput(0, rawGI_m) except: pass try: diffuse_m.setInput(1, rawLight_m) except: pass ##end of basic nodes ##SPECULAR LAYERS BREAKOUT ## rsnReverse = [] if splitRawSpec == True: rsLastNode = None rsnLength = len(rawSpec_Layers) rsn = 0 rsnXOffset = -900 rsnYOffset = 0 rs_merges = [] #rsDot = nuke.createNode("Dot", inpanel=False) #rsDot.setInput(0, node) #rsDot['ypos'].setValue(node['ypos'].value()+30) #rsDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset)*blnLength) last_rsm = None for layer in rawSpec_Layers: #print layer shuf = nuke.createNode("Shuffle", inpanel=False) shuf['in'].setValue(layer) shuf['in2'].setValue('alpha') shuf['alpha'].setValue('red2') shuf['label'].setValue(layer) shuf['postage_stamp'].setValue(True) shuf['tile_color'].setValue(4292105727) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() + nodeXOffset * (rsn + bln)) shuffles.append(shuf) #shuf.setInput(0, rsDot) rsnReverse.append(shuf) layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(shuf['ypos'].value() - nodeYOffset * 0.5) layerDot['xpos'].setValue(shuf['xpos'].value() + dot_offset) layerDot.setInput(0, tempNode) tempNode = layerDot rsnReverse.append(layerDot) dots.append(layerDot) #shuf.setInput(0, layerDot) rs_m = nuke.createNode("Merge2", "operation plus", False) rs_m.setInput(1, shuf) rs_m.setInput(0, last_rsm) #rs_m.setInput(0, None) merges.append(rs_m) rs_merges.append(rs_m) if last_rsm != None: #print last_rsm.name() #print rs_m.name() last_rsm.setInput(0, rs_m) last_rsm = rs_m rs_m['xpos'].setValue(shuf['xpos'].value()) rs_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 1.5) rsnReverse.append(rs_m) rsLastNode = rs_m rsn += 1 shuf.setInput(0, layerDot) #rsDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset)*blnLength) #Reorder the merges #last_rsm_dot = nuke.createNode('Dot', inpanel=False) #last_rsm_dot.setInput(0, rsLastNode) #last_rsm_dot['ypos'].setValue(rsLastNode['ypos'].value()+nodeYOffset*0.25) #last_rsm_dot['xpos'].setValue(rsLastNode['xpos'].value()+dot_offset) if 'specular_s' in locals(): rawSpec_switch = nuke.createNode("Merge2", "operation copy", False) rawSpec_switch['xpos'].setValue(specular_s['xpos'].value()) rawSpec_switch['ypos'].setValue(rsLastNode['ypos'].value() + nodeYOffset * 0.25) rawSpec_switch['output'].setValue('rgb') rawSpec_switch.setInput(1, rs_merges[0]) rawSpec_switch.setInput(0, specular_s) rawSpec_switch['label'].setValue( rawSpec_switch.input(0)['label'].value()) #specular_m.setInput(1, rawSpec_switch) last_rs_m = None rs_merges = reversed(rs_merges) for rs_merge in rs_merges: rs_merge.setInput(0, last_rs_m) #rs_merge.setInput(1,None) last_rs_m = rs_merge ''' rawSpec_switch = nuke.createNode("Merge2", "operation copy", False) rawSpec_switch['xpos'].setValue(specular_s['xpos'].value()) rawSpec_switch['ypos'].setValue(rsLastNode['ypos'].value()+nodeYOffset*0.25) rawSpec_switch['output'].setValue('rgb') rawSpec_switch.setInput(1, last_rsm_dot) rawSpec_switch.setInput(0, specular_s) rawSpec_switch['label'].setValue(rawSpec_switch.input(0)['label'].value()) ''' #mirrorNodes(rsnReverse, direction="x") ##end of rawSpec nodes ##SELECTION LAYERS BREAKOUT ## for layer in selectionLayers: if 'crypto' in layer.lower(): cryptomattes = True else: layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(node['ypos'].value() + nodeYOffset * 0.5) layerDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset * (bln + rsn)) + dot_offset) layerDot.setInput(0, tempNode) dots.append(layerDot) tempNode = layerDot shuf = nuke.createNode("Shuffle", inpanel=False) shuf['in'].setValue(layer) shuf['in2'].setValue('alpha') shuf['alpha'].setValue('red2') shuf['label'].setValue(layer) shuf['postage_stamp'].setValue(True) shuf['tile_color'].setValue(2475294719L) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() + nodeXOffset * (bln + rsn)) shuf.setInput(0, layerDot) shuffles.append(shuf) bln += 1 if shuf['label'].value().lower() == 'ambocc': ambOcc_s = shuf #shuf['alpha'].setValue('white') ambOcc_m = nuke.createNode("Merge2", "operation multiply", False) ambOcc_m['xpos'].setValue(shuf['xpos'].value()) ambOcc_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) ambOcc_m.setInput(0, bnLastNode) ambOcc_m.setInput(1, shuf) ambOcc_m['disable'].setValue(True) #merges.append(ambOcc_m) white = nuke.createNode("Constant", inpanel=False) white['channels'].setValue('rgba') white['color'].setValue(1) white['xpos'].setValue(shuf['xpos'].value() + nodeXOffset * 0.4) white['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 1.5) white_m = nuke.createNode("Merge2", inpanel=False) white_m['xpos'].setValue(shuf['xpos'].value()) white_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 2.3) white_m['operation'].setValue('under') white_m.setInput(0, shuf) white_m.setInput(1, white) #print white_m.name() bnLastNode = ambOcc_m if shuf['label'].value().lower() == 'depth': depth_s = shuf depth_m = nuke.createNode("Merge2", "operation plus", False) depth_m['xpos'].setValue(shuf['xpos'].value()) depth_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) depth_m.setInput(0, bnLastNode) depth_m['disable'].setValue(True) depth_m.setInput(1, shuf) bnLastNode = depth_m merges.append(depth_m) depth_constant = nuke.createNode("Constant", inpanel=False) depth_constant['channels'].setValue('rgba') depth_constant['color'].setValue(1) depth_constant['xpos'].setValue(shuf['xpos'].value() + nodeXOffset * 0.4) depth_constant['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 1.5) depthconst_m = nuke.createNode("Merge2", inpanel=False) depthconst_m['xpos'].setValue(shuf['xpos'].value()) depthconst_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 2.3) depthconst_m['operation'].setValue('multiply') depthconst_m.setInput(0, shuf) depthconst_m.setInput(1, depth_constant) if shuf['label'].value().lower() == 'atmosphere': atmos_s = shuf atmos_m = nuke.createNode("Merge2", "operation plus", False) atmos_m['xpos'].setValue(shuf['xpos'].value()) atmos_m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 5) atmos_m.setInput(0, bnLastNode) atmos_m.setInput(1, shuf) bnLastNode = atmos_m merges.append(atmos_m) if cryptomattes: try: layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(node['ypos'].value() + nodeYOffset * 0.5) layerDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset * (bln + rsn)) + dot_offset) layerDot.setInput(0, tempNode) dots.append(layerDot) tempNode = layerDot shuf = nuke.createNode("Cryptomatte", inpanel=False) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() + nodeXOffset * (bln + rsn)) shuf.setInput(0, layerDot) shuffles.append(shuf) bln += 1 except RuntimeError: print 'Could not create Cryptomatte node.' pass ##end of selection nodes ##RAWLIGHT LAYERS BREAKOUT ## if splitRawLight == True: rlLastNode = None rlnLength = len(rawLight_Layers) rln = 0 rlnXOffset = -300 rlnYOffset = 0 rl_dots = [] for layer in rawLight_Layers: #print layer shuf = nuke.createNode('Shuffle', inpanel=False) shuf['in'].setValue(layer) shuf['in2'].setValue('alpha') shuf['alpha'].setValue('red2') shuf['label'].setValue(layer) shuf['postage_stamp'].setValue(True) shuf['tile_color'].setValue(4292105727) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() - (nodeXOffset * rlnLength) + (nodeXOffset * rln)) #shuf.setInput(0, rlDot) shuffles.append(shuf) unpremult = nuke.createNode('Unpremult', inpanel=False) unpremult['ypos'].setValue(node['ypos'].value() + nodeYOffset + (nodeYOffset / 1.5)) unpremult['xpos'].setValue(node['xpos'].value() - (nodeXOffset * rlnLength) + (nodeXOffset * rln)) layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(shuf['ypos'].value() - nodeYOffset * 0.5) layerDot['xpos'].setValue(shuf['xpos'].value() + dot_offset) try: layerDot.setInput(0, dots[0]) except: layerDot.setInput(0, node) #tempNode = layerDot dots.append(layerDot) rl_dots.append(layerDot) m = nuke.createNode("Merge2", "operation plus", False) m.setInput(1, unpremult) m.setInput(0, rlLastNode) merges.append(m) #['xpos'].setValue(shuf['xpos'].value()) m['xpos'].setValue(shuf['xpos'].value()) m['ypos'].setValue(shuf['ypos'].value() + nodeYOffset * 1.5) rlLastNode = m rln += 1 shuf.setInput(0, layerDot) #rlDot['xpos'].setValue(node['xpos'].value() - (nodeXOffset/2)*rlnLength) if 'rawLight_s' in locals(): rawLight_switch = nuke.createNode("Merge2", "operation copy", False) rawLight_switch['ypos'].setValue(rlLastNode['ypos'].value()) rawLight_switch['output'].setValue('rgb') rawLight_switch.setInput(1, rlLastNode) rawLight_switch.setInput(0, rawLight_s) rawLight_m.setInput(1, rawLight_switch) rawLight_switch['label'].setValue( rawLight_switch.input(0)['label'].value()) #reverse the dot order and connection try: last_rl_dot = dots[0] except: last_rl_dot = node rl_dots = reversed(rl_dots) for dot in rl_dots: dot.setInput(0, last_rl_dot) last_rl_dot = dot ##end of rawLight nodes ##EXTRA TEXTURES BREAKOUT ## nuke.selectAll() nuke.invertSelection() for layer in xtex_Layers: layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(node['ypos'].value() + nodeYOffset * 0.5) layerDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset * (bln + rsn)) + dot_offset) dots.append(layerDot) layerDot.setInput(0, tempNode) tempNode = layerDot shuf = nuke.createNode('Shuffle', inpanel=False) shuf['in'].setValue(layer) shuf['in2'].setValue('alpha') shuf['alpha'].setValue('red2') shuf['label'].setValue(layer) shuf['postage_stamp'].setValue(True) shuf['tile_color'].setValue(2190700799) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() + nodeXOffset * (bln + rsn)) shuf.setInput(0, layerDot) shuffles.append(shuf) bln += 1 ##end of extra layers ##EXTRA LAYERS BREAKOUT ## nuke.selectAll() nuke.invertSelection() for layer in extraLayers: layerDot = nuke.createNode("Dot", inpanel=False) layerDot['ypos'].setValue(node['ypos'].value() + nodeYOffset * 0.5) layerDot['xpos'].setValue(node['xpos'].value() + (nodeXOffset * (bln + rsn)) + dot_offset) layerDot.setInput(0, tempNode) dots.append(layerDot) tempNode = layerDot shuf = nuke.createNode('Shuffle', inpanel=False) shuf['in'].setValue(layer) shuf['in2'].setValue('alpha') shuf['alpha'].setValue('red2') shuf['label'].setValue(layer) shuf['postage_stamp'].setValue(True) shuf['tile_color'].setValue(2384272895) shuf['ypos'].setValue(node['ypos'].value() + nodeYOffset) shuf['xpos'].setValue(node['xpos'].value() + nodeXOffset * (bln + rsn)) shuf.setInput(0, layerDot) shuffles.append(shuf) bln += 1 ##end of extra layers for merge in merges: merge['Achannels'].setValue('rgb') if splitRawSpec == True: try: specular_m.setInput(1, rawSpec_switch) except: pass nuke.selectAll() nuke.invertSelection() for node in basicLayerNodes: node['selected'].setValue(True) if splitRawLight == True: if node['label'].value().lower() == 'rawlight': node['selected'].setValue(False) rawLight_switch['selected'].setValue(True) if splitRawSpec == True: if 'spec' in node['label'].value().lower(): node['selected'].setValue(False) rawSpec_switch['selected'].setValue(True) gradeNodes = [] connectionNodes = nuke.selectedNodes() nuke.selectAll() nuke.invertSelection() for i in connectionNodes: i['selected'].setValue(True) g = nuke.createNode("Grade", inpanel=False) g['xpos'].setValue(i['xpos'].value()) g['ypos'].setValue(node['ypos'].value() + nodeYOffset * 2.1) g['unpremult'].setValue('rgba.alpha') gradeNodes.append(g) nuke.selectAll() nuke.invertSelection() o = None if bnLastNode != None: o = nuke.createNode("Output", inpanel=False) o.setInput(0, bnLastNode) o['xpos'].setValue(bnLastNode['xpos'].value()) o['ypos'].setValue(bnLastNode['ypos'].value() + 200) lastDot.setInput(0, o) nuke.delete(lastDot) firstDot['xpos'].setValue(firstDot['xpos'].value() + dot_offset) if showInputs == False: for shuf in shuffles: shuf['hide_input'].setValue(True) for dot in dots: nuke.delete(dot) ##:( try: ambOcc_m.setInput(1, white_m) except: pass try: depth_m.setInput(1, depthconst_m) except: pass return o