Sunday, March 25, 2012

snapShot.py


SnapShot:

snapShot render your current frame result (which ever your seeing your viewer) as a .jpg file and re-load it automatically. Its using your script name, version and your current node   ( means selected node) name.









snapShot.py create a directory called "snapShot"
on your nuke working directory and stores the snapShots into that DIR.























you can modify the snapShots destination DIR and file type as per your need.
  
( I really thank to Nicolas Houle and Frank Rueter for help me out to make this work )

Updated with new icon and custom input gizmo. Place the image gizmo, icon and snapShot.py on your custom nuke DIR. Replace menu.py line to make it work.

Nukepedia: http://www.nukepedia.com/python/render/snapshot/

Download: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!256&parid=776F8351D9892B6A!133


else copy paste below code as snapShot.py
'''
Created on 26-Feb-2012
@author: satheesh
mail - satheesrev@gmail.com

Thank to Nicolas to help me out make this work
'''
import nuke
import nukescripts
def snapShot ():
    nodeName = None
    try:
      nodeName = nuke.selectedNode().name()
    except ValueError:  # no node selected
      pass

    if nodeName is not None:
      w = nuke.createNode("Write")
      w.setName("tempWrite")
      w['file'].setValue("[python {nuke.script_directory()}]/snapShots/[string trim [file tail [value root.name]] .nk]_" + nodeName + "_%04d.jpg")
      w['_jpeg_quality'].setValue(1)
      w['_jpeg_sub_sampling'].setValue(2)
      result = nuke.frame()
      if result =="":
        result = result
      nuke.execute(nuke.selectedNode(), (int(result)), result)
      name = w.knob('file').value()
      nukescripts.node_delete(popupOnError=True)
  ## create Read node
      r = nuke.createNode("image")
      r.setName("snapShot")
      r['input'].setValue(name)
      result = nuke.frame()
      r['first'].setValue(int(result))
      r['last'].setValue(int(result))
      r['xpos'].setValue( 200 )

    else:
      nuke.message('select a node to take snapShot')


## create DIR if there is no such directory
def createWriteDir():
    import nuke, os
    file = nuke.filename(nuke.thisNode())
    dir = os.path.dirname( file )
    osdir = nuke.callbacks.filenameFilter( dir )
    try:
        os.makedirs( osdir )
        return
    except:
        return

nuke.addBeforeRender( createWriteDir )



menu.py file:
import snapShot
toolbar.addCommand("Snapshot", "snapShot.snapShot()", icon="/your directory/camera.png", "F3")

( you can change the shortcut from "F3" to what ever you want )

Wednesday, March 14, 2012

Keying with Expression Node in NUKE

Keying inside Nuke using "expression" node:

Green or Blue screen keying is a important task in compositing. Most off the artists (compositors) use any traditional keyer like Primatte, Keylight, UltraKeyer, IBK keyer etc... For complete the keying Task. Most-probably its the traditional way.
For more information about keyer tools:
http://www.fxguide.com/featured/art_of_keying/

What is happening while we play around (sliders) with above keyer tools. Some color math happening behind while we sampling the screen and adjusting the sliders for fine tuning the Alpha.

Why don't we play with those color math function to getting alpha?
Here is some example.. How to extracting the alpha channel from green or blue screen footages with some color math using nuke's "Expression" node.

1. Green screen:

expression: r*1.5/g*.9


work file: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!251&parid=776F8351D9892B6A!133

2.Blue screen:

expression: r*2.5/g*1-g*4.6

work file: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!250&parid=776F8351D9892B6A!133

Here is some external experiments which i involved to help some Artists.
http://www.vfxtalk.com/threads/34412-Some-Keying-Issues-Out-of-focus-Keylight?highlight=keying


Hope this page help you.

Sunday, March 4, 2012

extractFrame.py

ExtractFrame:

extractFrame is a python script for Nuke.
extractFrame grab out a single frame from your image sequence (input, footage, etc). Usually we add a "Frame Hold" node and give the value off which frame we need.

extractFrame pop-up a window, it will automatically carry the current frame, you can mention the frame which you want on the "which frame you want to extract" field or else it will automatically use your current frame.

Result while specify the frame no:







Result with out specify frame no:






















Python file: http://www.nukepedia.com/python/misc/extractframe

else copy paste below code as extractFrame.py.


'''
Created on 01-Mar-2012
updated on 16-apr-2013
@author: satheesh.R
contact: satheesrev@gmail.com
'''
import nuke
## creating panel
def extractFrame():
curFrame = nuke.frame()
ef = nuke.Panel("extractFrame..... by satheesh-R", 50)
ef.addSingleLineInput("feed frame no to Hold:\n (this is your current frame)",curFrame)
ef.addButton("cancel")
ef.addButton("ok")
window = ef.show()
if window == 0:
return
result=ef.value("feed frame no to Hold:\n (this is your current frame)")
frame = nuke.frame()
if result =="":
result=frame
## create framehold and assign user value
fh = nuke.createNode("FrameHold")
fh.setName("HoldedFrame")
fh['first_frame'].setValue(int(result))


menu.py file:

import extractFrame
n = nuke.toolbar('Nodes')
n.addCommand('Edit/extractFrame', 'extractFrame.extractFrame()', "F2")
( you can change the shortcut from "F2" to what ever you want )

Saturday, March 3, 2012

Working with UV pass inside NUKE

Working with UV pass inside NUKE

UV pass will allow you to re-texture surfaces and add some elements ( like text, batches, picture frame ) later in the compositing stage. Here i place my name on the surface and apply motion blur inside nuke.

Creating UV pass inside MAYA:

Maya 2012 have inbuilt UV render pass.Open up render settings under Passes tab select create render passes and choose UVpass and add.

Maya->Render Settings->Passes->UVpass



If you want to create custom UV pass Follow below link.

http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=13481445&linkID=9242258



Enable float values for rendering

For render UV pass from MAYA you must change your colour bit depth from the standard RGBA 4x8Bits per channel to RGBA (Float) 4x32 Bit (full float).

Open up your 'Render Settings' and at the bottom of the 'Quality' tab change the 'Date Type' to 'RGBA (Float) 4x32 Bit.



choosing File format for rendering from MAYA


UV passes contain infinite values so you can't store UV passes on clamped image formates, such as .jpg, .tga etc. So we need to use image format like .exr which can store float values.


Render your images as .exr sequances from MAYA.


stMap tool in NUKE:

stMap node use UV pass information for re-project your texture on your surface inside Nuke. Also you can place what ever you want on your surface.


Here i add my name on top of my object using UV pass and apply motionBlur using "vectorBlur".

For working with "2D motion vector" inside NUKE follow below link:
http://satheeshnuketutorials.blogspot.in/2012/03/handling-vector-blur-inside-nuke.html


Import you footage in to Nuke and add "stMap" node connect it separately.

stMap-> your UV pass
     src-> your custom object (my case Text)




Dealing with stMap:

On stMap node set UV channel none to your custom UV channel and color channel all to rgba.
Composite stMap result to top off your color channel using "Merge" node.










Applying Motion Blur:

Apply motion blur using vector blur Node.

for more information dealing with vector blur: 
 http://satheeshnuketutorials.blogspot.in/2012/03/handling-vector-blur-inside-nuke.html


Motion blur applied result.









Hope this page help you.

software used: Maya 2012, Nuke 6.3v6.

source files:
UV pass: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!252&parid=776F8351D9892B6A!133
Nuke comp file: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!253&parid=776F8351D9892B6A!133

Friday, March 2, 2012

Handling vector blur inside Nuke

How to use Motion vector Pass inside Nuke?

Many peoples struggled getting exact result inside Nuke using motion vector pass. (once me too..)

Here is the solution for that.

what is motion vector pass?
A 2D motion vector image describes the amount of movement that’s happening in a scene by using two luminance maps and combining them into one image.

For more information: http://aloedesign.com/2008/12/maya-2d-motion-vectors-tutorial/

Render motionVector pass from Maya

Mental-ray have 2D motion vector export shader inbuilt. So go to create render passes panel and select "2D Motion Vector"
hit create.

Maya->Render Settings->Passes->2D Motion Vector.



choosing File format for rendering from MAYA

Vector passes contain infinite values so you can't store vector passes on clamped image formates, such as .jpg, .tga etc. So we need to use image format like .tiff, .exr which can store float values.

Enable float values for rendering

Usually MAYA render 8bit per channel as default. You should tell MAYA to render our image as 16bit half float or 32bit float. How to do that.


Maya->Render Settings->Quality->FrameBuffer->DataType

Change it from its default value:
 RGBA 4*8bit -> RGBA (float)4*32bit for 32bit float.
 RGBA 4*8bit -> RGBA (float)4*16bit for 16bit half float.

Thats all now you can render your images as .exr sequances with Motion Vector.



 (want to know more about open EXR http://www.openexr.com/about.html)



Apply motion blur inside NUKE using 2D Motion Vector pass.

Import your .exr or .tiff image sequence inside nuke.
Nuke display 2DMotionVector pass like right side img
(Look those values going minus).




Dealing with vector blur node

Add vectorBlur node under your Read node.
Change channels all to rgba.
UV channels->your custom channel vector channel name (MV2E_mv2DToxik)
method -> forward  (nuke default backward).



you get the result like below image.

                                        Its look wired why ???? (this is not I'm expecting)

Its happened because off premultiply issue. How to fix it ?

you have to check "alpha" to rgba.alpha. Now you get the correct result what you expect. see below image.

Thats it.

Hope this page help you. If yes leave comments please.

software used: Maya 2012, Nuke 6.3v6.

source files: 
seq file: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!254&parid=776F8351D9892B6A!133
Nuke comp file: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!255&parid=776F8351D9892B6A!133

scale up and down cornerpin node

global scale up and down cornerpin This script help you to global scale up or down the selected cornerpin. Recently i had situation to ...