Announcement

Collapse
No announcement yet.

VRay EXR to Nuke Camera

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VRay EXR to Nuke Camera

    Hey all,
    I have been wanting to do this for a while so I finally did it, along with the help of some smart people.
    This allows you to create a nuke camera based on the metadata in the VRay exr file.

    I have tested this reasonably well and it matches pretty solidly in my test pixel for pixel.

    Enjoy it!

    http://pastebin.com/4vmAmARU

    Rob
    throb
    vfx supervisor
    http://throb.net

  • #2
    Thanks for sharing Rob.

    Just given it a try and all seems to be working, will report back if I find any problems.
    Last edited by MartinB; 23-04-2012, 04:22 AM.

    Comment


    • #3
      Oh I should mention, this has not been tested with the physical camera.
      throb
      vfx supervisor
      http://throb.net

      Comment


      • #4
        Just been playing with the pWorld pass and postionToPoints node, all seems to line up pretty nicely and its cool being able to get all that data out of one exr!

        Click image for larger version

Name:	pWorldExrCam2.jpg
Views:	1
Size:	183.3 KB
ID:	845275
        Attached Files
        Last edited by MartinB; 23-04-2012, 09:12 AM.

        Comment


        • #5
          Rather than baking to keys you can also just use this section of the code as an expression on the camera focal length:

          Code:
          import math
          
          frame = nuke.frame()
          cam = nuke.thisNode()
          node = nuke.toNode("Read1")
          
          val = node.metadata( 'exr/cameraAperture', frame) 
          fov = node.metadata( 'exr/cameraFov', frame)
          
          focal = val / (2 * math.tan(math.radians(fov)/2.0)) # convert the fov and aperture into focal length
          
          cam['haperture'].setValueAt(float(val),frame)
          
          matrixCamera = node.metadata( 'exr/cameraTransform', frame) # get camera transform data
          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)
          
          ret = focal
          That way if the read gets updated the metadata is being read directly.

          Seems like it works at a useable speed too!


          Nathan

          Comment


          • #6
            Will the cameras created have animation data generated between the frames?

            We set up something similar to this at our studio, but the problem was that you can't do scanlines from Nuke with 100% confidence in the motion blue since the camera doesn't actually move until it hits the next frame.

            Comment


            • #7
              Baking the meta data to the camera makes normal keys that seem to interpolate correctly (see pic) so I assume motion blur would work, but the expression method might not as I figure its swapping out the value as it hits the next frame.

              Click image for larger version

Name:	pWorldExrCam3.jpg
Views:	1
Size:	154.6 KB
ID:	845282
              Last edited by MartinB; 25-04-2012, 01:37 AM.

              Comment


              • #8
                As a side note this works PERFECTLY with EXRs coming from VRayMax, all that is needed is to plug an axis node into the camera with a -90 degree x rotation value. I tested this using a physical cam, AWESOME!!!
                Stephen Hallquist
                Rayden, Inc.
                www.rayden.tv

                Comment


                • #9
                  Originally posted by MartinB View Post
                  Just been playing with the pWorld pass and postionToPoints node, all seems to line up pretty nicely and its cool being able to get all that data out of one exr!

                  [ATTACH=CONFIG]9704[/ATTACH]
                  Nice, what are you calling the passes so nuke picks it up ?
                  I have all that stuff generated but not sure what to call the channels.

                  Rob
                  throb
                  vfx supervisor
                  http://throb.net

                  Comment


                  • #10
                    I just called the extraTex/SampleInfo element 'pWorld' then in nuke shuffled that out and plugged it into the xyz of a positionToPoint node. The wireframe was an fbx of the scene to make sure it was lining up.

                    I vaguely remember a different workflow from an fxphd 'Renderman to Nuke relighting' tutorial which went down a different and was using nWorld and pWorld but can't remember the details...

                    Comment


                    • #11
                      could someone help... i have no idea how to use this code..?
                      is this a new node..? a script.?

                      Comment


                      • #12
                        From what I remember you run it in Nuke's script editor, maybe while having the read node you want to pull the metadata out of.... But it was a while ago I used it.

                        Comment


                        • #13
                          I also haven't had luck with this, either running it from the Script Editor or adding into my script file and running it from the toolbar. Both ways I select the .exr sequence before executing. No luck!
                          Brendan Coyle | www.brendancoyle.com

                          Comment


                          • #14
                            ya, this looks really useful but I can't get it to do anything either – whether sourced or run from ~/.nuke/scriptname.py. A little video or walkthrough would be great.
                            Dave Girard

                            Comment


                            • #15
                              createExrCamVray.zip

                              It's really very, very handy. We use it this way:


                              --
                              Put the script createExrCamVray.py in a folder Nuke scans for py-scripts (like ".nuke"). In your menu.py add something like:

                              Code:
                              import createExrCamVray
                              m = menubar.addMenu("custom")
                              m.addCommand("Create Camera from EXR", "createExrCamVray.createExrCamVray()")
                              Select your read and click on the new command in the menubar.
                              --

                              Cheers!

                              Comment

                              Working...
                              X