awesome - thanks, it works now. This is amazing, not having to deal with FBX camera nodes at all. My plates are matched perfectly.
Announcement
Collapse
No announcement yet.
VRay EXR to Nuke Camera
Collapse
X
-
-
Ehi guys, i'm trying to get this working with nuke 7 (outputting from max though), but apparently i can't create anything.
Any help?
Cheers
Comment
-
Originally posted by kagemaru View PostEhi guys, i'm trying to get this working with nuke 7 (outputting from max though), but apparently i can't create anything.
Any help?
Cheers
Comment
-
Originally posted by tashko.zashev View PostDid you got it to work? I see few posts earlier that Stephen has managed to get correct result from Max as well.
I haven't deeply investigated, but with a ViewMetaData node i can see camera informations are in there, something's wrong with how the script reads the file (at least in my case).
Ps
We use standard cameras, not vray ones.
[EDIT]
I think i managed to catch what was wrong: basically in my files metadata "FocalLenght" is defined as "Fov", changing names worked. There's still something strange about rotations (even pluggin -90 x axis rotation doesn't look right), i'll try to see if i can match an fbx camera i used (which i'm sure is doing things right).
Don't know if this difference has happened on vray or nuke side.Last edited by kagemaru; 27-08-2013, 06:06 AM.
Comment
-
Originally posted by kagemaru View PostActually no, i've just tried with latest renders from vray 2.40.04 (last stable build for max) and nukex7.0v5 but it just outputs "no metadata for camera found".
I haven't deeply investigated, but with a ViewMetaData node i can see camera informations are in there, something's wrong with how the script reads the file (at least in my case).
...
[CUT]
In this way my fbx camera and the one extracted from exr match.
This has been tested with nukeX7v0.5 and renders from Max (sorry for the cross post).
Code:import math import nuke import nukescripts def createExrCamVray(): ''' Create a camera node based on VRay metadata. This works specifically on VRay data coming from maya. ''' #Big thanks to Ivan Busquets who helped me put this together! #(ok, ok, he really helped me a lot) #Also thanks to Nathan Dunsworth for giving me solid ideas and some code to get me started. ### TODO : add progress bar (even though it's really not needed here) that works node = nuke.selectedNode() mDat = node.metadata() # reqFields = ['exr/camera%s' % i for i in ('FocalLength', 'Aperture', 'Transform')] reqFields = ['exr/camera%s' % i for i in ('Fov', 'Aperture', 'Transform')] if not set( reqFields ).issubset( mDat ): print 'no metadata for camera found' return first = node.firstFrame() last = node.lastFrame() ret = nuke.getFramesAndViews( 'Create Camera from Metadata', '%s-%s' %( first, last ) ) fRange = nuke.FrameRange( ret[0] ) nukescripts.clear_selection_recursive() myAxis = nuke.createNode('Axis2') myAxis['rotate'].setValue(-90,0,0) cam = nuke.createNode( 'Camera2' ) cam['useMatrix'].setValue( False ) for k in ( 'focal', 'haperture', 'vaperture', 'translate', 'rotate'): cam[k].setAnimated() #task = nuke.ProgressTask( 'Baking camera from meta data in %s' % node.name() ) for curTask, frame in enumerate( fRange ): #if task.isCancelled(): #nuke.executeInMainThread( nuke.message, args=( "Phew!" ) ) #break; #task.setMessage( 'processing frame %s' % frame ) # IB. If you get both focal and aperture as they are in the metadata, there's no guarantee # your Nuke camera will have the same FOV as the one that rendered the scene (because the render could have been fit to horizontal, to vertical, etc) # Nuke always fits to the horizontal aperture. If you set the horizontal aperture as it is in the metadata, # then you should use the FOV in the metadata to figure out the correct focal length for Nuke's camera # Or, you could keep the focal as is in the metadata, and change the horizontal_aperture instead. # I'll go with the former here. Set the haperture knob as per the metadata, and derive the focal length from the FOV val = node.metadata( 'exr/cameraAperture', frame) # get horizontal aperture fov = node.metadata( 'exr/cameraFov', frame) # get camera FOV imHeight = node.metadata( 'input/height', frame) # get image height imWidth = node.metadata( 'input/width', frame) # get image width focal = val / (2 * math.tan(math.radians(fov)/2.0)) # convert the fov and aperture into focal length vAper = val / ( float(imWidth) / float(imHeight) ) # get the camera vertical aperture cam['focal'].setValueAt(float(focal),frame) cam['haperture'].setValueAt(float(val),frame) cam['vaperture'].setValueAt(float(vAper),frame) matrixCamera = node.metadata( 'exr/cameraTransform', frame) # get camera transform data #Create a matrix to shove the original data into matrixCreated = nuke.math.Matrix4() for k,v in enumerate(matrixCamera): matrixCreated[k] = v # matrixCreated.rotateX(math.radians(-90)) # this is needed for VRay. It's a counter clockwise rotation translate = matrixCreated.transform(nuke.math.Vector3(0,0,0)) # Get a vector that represents the camera translation rotate = matrixCreated.rotationsZXY() # give us xyz rotations from cam matrix (must be converted to degrees) cam['translate'].setValueAt(float(translate.x),frame,0) cam['translate'].setValueAt(float(translate.y),frame,1) cam['translate'].setValueAt(float(translate.z),frame,2) cam['rotate'].setValueAt(float(math.degrees(rotate[0])),frame,0) cam['rotate'].setValueAt(float(math.degrees(rotate[1])),frame,1) cam['rotate'].setValueAt(float(math.degrees(rotate[2])),frame,2)
Comment
-
Regarding using this in Max (and excuse my lack of understanding of Nuke), I'm getting a message saying:
createExrCamVray() takes exactly 1 argument (0 given)
Traceback (most recent call last):
File "<string>", line 1, in <module>Last edited by DPS; 05-09-2013, 09:11 PM.
Comment
-
-
Originally posted by ronald_a View Posttashko.zashev Is there any chance somebody has this updated to work with nuke 13?
Comment
Comment