Showing posts with label multiple views. Show all posts
Showing posts with label multiple views. Show all posts

Jun 14, 2012

Submit nuke render job with specific views for deadline

Hi, I posted this on deadline forums, I thought it would be on a good place here too.
In this post I describe what files to edit in the deadline repository, if you want to submit not all, but specific view(s) from a multiview (stereo) nuke scene to deadline. The modification include the nuke submitter dialog, where user can check which views to render, and the nuke plugin file. Hope it helps someone. By the way it is for deadline 5.0, the exact solution for other versions may be different.


Submission/SubmitNukeToDeadline.py, gui declaration in __init__ somewhere append this:

1:   self.viewToRenderLabel = nuke.Text_Knob( "separator31", "Views to render:" )   
2:   self.addKnob( self.viewToRenderLabel)   
3:   self.views = nuke.views()   
4:   self.viewToRenderKnobs = []   
5:   for x, v in enumerate(self.views):   
6:    bknob = nuke.Boolean_Knob(('viewToRender_%d' % x), v)   
7:    bknob.setFlag(0x1000)   
8:    self.viewToRenderKnobs.append((bknob, v))   
9:    self.addKnob(bknob)   
10:   bknob.setValue(True)   


Still SubmitNukeToDeadline.py, in SubmitJob function, where writing into plugin info file, for example after: "fileHandle.write( "NukeX=%s\n" % dialog.useNukeX.value() )"


1:  viewsToRender = getSelectedViews()  
2:  viewsToRender_str = ','.join(viewsToRender)  
3:  print 'Views to render in plugin info file: %s' % viewsToRender_str  
4:  fileHandle.write( "viewsToRender=%s\n" % viewsToRender_str )  




Still SubmitNukeToDeadline.py, at the end, a new function to get list of views from submitter dialog (that the user selected) write this:

1:  def getSelectedViews():  
2:   global dialog  
3:   x = 0  
4:   viewsToRender = []  
5:   for vk in dialog.viewToRenderKnobs:  
6:    if vk[0].value():  
7:     viewsToRender.append(vk[1])     
8:   x+=1  
9:   print '\nViews to render: %s\n\n\n ' % viewsToRender  
10:  return viewsToRender  


-------
In plugins/ nuke.py file in RenderArgument function, just before return append this:


1:  viewsToRender = GetPluginInfoEntryWithDefault( "viewsToRender", "" )  
2:  if viewsToRender != '':  
3:   LogInfo( "==VIEWS==\nUsing " + viewsToRender + " view(s) for rendering\n" )  
4:   renderarguments += " -view \"" + viewsToRender + "\""   

And that's it. It's even logging the views to be rendered.
Cheers,
Gabor

May 3, 2012

Nuke multiple views in read nodes

Hi,

I had a little problem not long ago, with setting stereo sequences in readnodes. No problem when the filepaths of views differ only in the view names, like BH_010_left.%04d.dpx and BH_010_right.%04d.dpx. Then you can use "%V" as wildcard for view name. But unfortunately our 3d guys was giving me renders where the 2 view are different in version number, like BH_010_v005_layer1.beauty.%04d.exr and BH_010_v006_layer1.beauty.%04d.exr.
(We have redesigned our cg output system to handle this since then, but I share this experience anyway ) The problem is that the file knob in the readnode is capable of splitting for views (split a knob = make different values for different views in the same knob), but the automatic path manipulator tools, like version up-down script, search and replace, that are needed to change so many passes in readnodes at once, are not working with splitted filenames, only working on the view that is not splitted off. For example if you split off left, these will work only on right view.
So the workflow to handle readnodes's paths with splitted views: choose 1 view that will be split off, so you won't be able to manipulate (only one by one). Assume this is the "right" view. Put all the readnodes down, set them to desired version for "right" view. Check that you are on the "right" view (in the viewer top line). Then (while all read selected) run this script:

sn=nuke.selectedNodes('Read')
for n in sn:
n['file'].splitView()


This will split off right view in all readnodes. Now change to left view in the viewer, and then change the version (alt+shift up/down), or do search and replace, those will be effecting the left view only (the "unsplitted" view).
If you have to change both view again, (for example new versions rendered for both view) then unsplit the previously splitted view ("right" in this example), with standing on "right" view, and running this little script:

sn=nuke.selectedNodes('Read')
for n in sn:
n['file'].unsplitView()


It will make readnodes normal again, and you can start the process over again :)
Sounds complicated? It's not, just tedious. Of course I could have used separate readnodes for each view (for each pass), but hey, that would be so simple right? (And too many readnodes)

Feb 27, 2012

Nuke createwritedir script with multiple views

Hi, just jumped into a stereo project, and found that couple things not working properly with nuke. For example the good, ol' createwritedir script, that creates directory before rendering, doesn't handle the '%V' view tag in filenames, so I post here an updated version. This however creates directory for every view, because didn't find a way create them separately, as the script is not called in render for every view, only once.
Here is the code snippet. Sorry for misaligned lines. Anyone knows a better way for displaying code?
 def createWriteDir():  
     import nuke, os  
     import re  
     #view = nuke.thisView()  
     views = nuke.views()  
     file = nuke.filename(nuke.thisNode())  
     dir = os.path.dirname(file)  
     viewdirs = []  
     
     if re.search('%V', dir):    # replacing %V with view name  
         for v in views:  
             viewdirs.append(re.sub('%V', v, dir))  

     if len(viewdirs) == 0:  
         osdir = nuke.callbacks.filenameFilter(dir)  
         if not os.path.isdir(osdir):  
             os.makedirs (osdir)  
     else:  
         for vd in viewdirs:  
             osdir = nuke.callbacks.filenameFilter(vd)  
             if not os.path.isdir(osdir):  
                 os.makedirs (osdir)  
                 print 'Directory (with viewname) created: %s' % (osdir)  
(I edited the script, there was an unnecessary try: except part)