shuffleAlpha.py

shuffleAlpha

Usually we use shuffle node to extract matte's from ID pass. For to do this we add a shuffle node and select the channel which need to be alpha channel.
 
This script will simplify this work, Its pop-up a panel (window)  called "selectChannel to shuffle" and you should choose your channel and click ok. This script will automatically done the above job. shuffleAlpha script also label the node like (red-->Alpha).

 Added extra future called "to All channel". By default "to All channel" is unchecked, If you select your channel and hit ok it will give you below result.
(This script keep other channels black rather then "alpha" channel)


I used to work like this, Because off work-flow optimisation. For more information about nuke work-flow optimisation tips.... nuke-workflow-optimisation-tips


With "to All channel" checked result:



Also shuffleAlpha.py will label the shuffle node according to your selection and create a stickyNote node and insert the result on it.


Added rgba to alpha. Some time we need to merge all channels together to alpha. If you select 'rgba' this script will create a expression node, merge all the channel together and convert it to alpha. Output value are clamped.







Hope this will help you friends.

Download from: nukepedia

Download from: skydrive

(or)

Copy below code and enjoy.


import sys
import nuke

'''
Created on 2 Jan 2013

@author: satheesh.R
contact: satheesrev@gmail.com
'''
## creating panel
def  shuffleAlpha():
    sa = nuke.Panel("shuffleAlpha.......  by satheesh-r", 400)
    sa.addEnumerationPulldown('selectChannel to shuffle', 'red green blue alpha rgba')
    sa.addBooleanCheckBox("to All channels", False)
    sa.addButton("cancel")
    sa.addButton("ok")
    result = sa.show()
    channel=sa.value("selectChannel to shuffle")
    value=sa.value("to All channels")
    ## continue the function if user hit ok
    if result == 0 :
        return

    if channel == 'rgba' :
        ex = nuke.createNode('Expression', inpanel = False)
        ex['expr3'].setValue('clamp(r+g+b+a)')
        ex['label'].setValue(channel+ ' ---> alpha')
        ex['note_font_size'].setValue(15)
        xpos = ex.xpos()
        ypos = ex.ypos()
        sn = nuke.createNode('StickyNote', inpanel = False)
        sn['label'].setValue(channel+ ' channels converted to alpha\n value clamped')
        sn['xpos'].setValue(xpos+110)
        sn['ypos'].setValue(ypos)


    ## Create shuffle node and set selected channel to all channels
    elif value == True :
        sh = nuke.createNode("Shuffle", inpanel = False)
        sh['alpha'].setValue(channel)
        sh['red'].setValue(channel)
        sh['green'].setValue(channel)
        sh['blue'].setValue(channel)
        sh['label'].setValue(channel+'-->All')
        sh['note_font_size'].setValue(20)

        ## add stickyNotes with shuffle information
        xpos = sh.xpos()
        ypos = sh.ypos()
        sn = nuke.createNode('StickyNote', inpanel = False)
        sn['xpos'].setValue(xpos+110)
        sn['ypos'].setValue(ypos+10)
        sn['label'].setValue(channel+ ' channel replaced\n with all channels')

    ## Create shuffle node and set selected channel to alpha channel only, keep other channels black
    elif value == False :
        sh = nuke.createNode("Shuffle", inpanel = False)
        sh['alpha'].setValue(channel)
        sh['red'].setValue('black')
        sh['green'].setValue('black')
        sh['blue'].setValue('black')
        sh['label'].setValue(channel+'-->alpha')
        sh['note_font_size'].setValue(20)

        ## add stickyNotes with shuffle information
        xpos = sh.xpos()
        ypos = sh.ypos()
        sn = nuke.createNode('StickyNote', inpanel = False)
        sn['xpos'].setValue(xpos+110)
        sn['ypos'].setValue(ypos+10)
        sn['label'].setValue(channel+ ' channel converted to alpha\n other channels switched to black')

        ## setting node tile color based on user selection
        if channel == "red" :
            sh['tile_color'].setValue(4278190335)
        if channel == "green" :
            sh['tile_color'].setValue(16711935)
        if channel == "blue" :
            sh['tile_color'].setValue(65535)
        if channel == "alpha" :
            sh['tile_color'].setValue(4278124287)

    else:
        return

Comments

Post a Comment

Popular posts from this blog

Export Nuke's retime information

Working with UV pass inside NUKE

DeepEdgeSmoother