Framebuffer Shuffling

No matter what you are rendering, at the end of the day you probably need to setup a nuke comp, and shuffle your framebuffers/passes/AOVs – you name it, to recreate your beauty. This is why I wrote a little script that does this tedious job for you.

It works out of the box with mental ray (mila). Just select your read node, run the script and it will layout the dag. It automatically excludes all the utility passes like normals, position data and so on and only keeps everything you need for your beauty. If you want to modify this script for a different renderer, just search for the line where it says:

('diffuse' not in layers[i])

and add everything you need, for example

('refraction' not in layers[i])

if you are using arnold or vray. You don’t have to specify the exact syntax. Your framebuffer name just has to contain the provided string somewhere and the script will keep it in your tree.

 

import nuke
	
def shuffle():
    i=0
    shuffleNode = []
    mergeNode = []
    nodes = nuke.selectedNodes()
    for node in nodes:
        if node.Class() == 'Read':
            channels = node.channels()
            layers = list( set([channel.split('.')[0] for channel in channels]) )
            for i in xrange(len(layers) - 1, -1, -1):
				if ('diffuse' not in layers[i]) and ('glossy' not in layers[i]) and ('specular' not in layers[i]) and ('scatter' not in layers[i]):
					layers.remove(layers[i])


            for layer in layers:  
                if i == 0:          
                    shuffleNode.append( nuke.nodes.Shuffle(label=layer,inputs=[node]))
                else:
                    shuffleNode.append( nuke.nodes.Shuffle(label=layer,inputs=[shuffleNode[i-1]]))
                shuffleNode[i]['in'].setValue( layer )
                shuffleNode[i]['postage_stamp'].setValue(False)
                shuffleNode[i]['name'].setValue('')
                
                shuffleNode[i].setXpos( node.xpos()+200*i)    
                shuffleNode[i].setYpos( node.ypos()+100)            

                if i == 1:
                    mergeNode.append( nuke.nodes.Merge(operation = 'plus', inputs=[shuffleNode[i-1], shuffleNode[i]]))
                    
                if i >=2:
                    mergeNode.append( nuke.nodes.Merge(operation = 'plus', inputs=[mergeNode[i-2], shuffleNode[i]]))
                    mergeNode[0].setYpos(node.ypos()+500)
                    mergeNode[0].ypos()                    
                i+=1
        else:
            pass


Happy Compositing!


Posted

in

by

Tags:

Comments

One response to “Framebuffer Shuffling”

Leave a Reply

Your email address will not be published. Required fields are marked *