Export camera from Houdini to Nuke using EXR
Abstract:
It was always a big problem for me to move the camera from Houdini to Nuke. All attempts to use fbx, for some reason, constantly led to crashes, inverting the directions of the coordinate axes and incorrect animation.
I saw a lot of scripts transferring the camera from Maya, Blender, etc., but since I work in Houdini I decided to make it for Houdini.
The main reason for doing this tool was the wide range possibilities for storing data in exr files. Exr is the main image format which I and my colleagues working with. I thought, if you render a picture for a compositing with information about the camera, which can always be read in Nuke. In this case, there are no problems with the mismatch between the camera and render versions, because Each finished frame will carry up-to-date information about form which camera frame was rendered.
After some research in Houdini transformation, we often animate the camera in all available ways, using Aim, additional parents and Nulls, I have realized that to solve the camera transfer problem, we need to use transformation matrices. In any package that is related to 3D, the calculation of the position and rotation in space is described as a transformation matrix (they are world (worldMatrix) and local). The Euler coordinate system gives us a better understanding of the visual process of working with a 3D object, but when exporting data from one package to another, it is much easier to use matrices, that give us the opportunity to get the position of the object and its rotation (as well as compression and size (for solid objects) important data but not for the camera)) regardless of how we acted on it to obtain movement or position. We can always transform the matrix and get any transformation component (transform, rotate, scale …)
I will not go into the mathematical aspect of this story, if it is interesting to study in more detail, below I gave the materials that I used:
- http://en.wikipedia.org/wiki/Transformation_matrix
- http://www.sidefx.com/docs/houdini13.0/hom/hou/ ObjNode#worldTransform
- http://docs.thefoundry.co.uk/nuke/63/pythonreference/ _nukemath.Matrix4-class.html
Process:
Houdini:
INFO: For now it worked only for Mantra, but it’s no problem to make it for other renderers(Arnold, etc.)
To record a camera in exr, you need to create an expression in the Mantra Node, which in the field «exr/comments» enters the values of the position matrix in world coordinates, as well as the Focal Length and Aperture of the camera selected in this mantra node. It looks like this:
`pythonexprs("hou.node(hou.parm('camera').eval()).worldTransform().asTuple()")``pythonexprs("hou.parm(hou.parm('camera').eval()+'/focal').eval()")``")"``pythonexprs("hou.parm(hou.parm('camera').eval()+'/aperture').eval()")`
I made a shelf, which, if necessary, fills this field for me:
Nuke:
To create a camera in Nuke based on the data from exr, we execute a script that reads data for each frame and puts keys on camera.
In practice, it looks like this:
- Execute script:
- We get camera with animation:
Leave a comment