Monday, December 10, 2007

foxCamera part 1.

Have you ever wanted to handle your maya cameras as if it were a film camera or an SLR ? Let the the shutter, f-stop, focal length etc. give you the correct depth of field and motion blur?

Well this is the goal with the foxCamera mel script.
Many rendering engines do already have this type of nodes or shaders, mental ray contains all the necessary components but there is no actual composite-node or UI of those.

Ok, so almost all of the attributes can be found on one node/shader or another. My mission boils down to two things:
1.
Create some kind of interface with all of the knobs and switches in a camera familiar way.
2. Figure out the relations between the camera settings (shutter, f-stop, focal length etc.) and the different effects such as depth of field and motion blur.

Outline
The foxCamera consists of a rigging part, an interface part and a function part.
As the script is run it creates a network of nodes and sets them to drive each other via the UI and the scripts functions.
Used nodes are:
  • mia_bokeh
  • mia_photographic
  • mib_cie_d
  • miDefaultOptions
  • camera

The interface


The interface is pretty straight forward divided into six parts.

Blur Switches
Controls the use of motion blur (off/exact/tranform) and depth of filed.

Camera Controls
This is the main settings for any camera. ISO speed, f-stop, focal length, shutter speed and white balance. These attributes directly drive the mia_photographic lens shader that is used. And indirectly drives the amount of blur, more on this in the info & statistics section. There is also a button to set the focus distance to the selected object. The white balance is connected to the lens via a CIE node that allows the input of kelvin values just like a real camera would. There is also a button for auto white balance (coming feature).

Artistic Controls
The artistic controls do also directly drive attributes found on the lens shader.
These attributes would represent the tuning settings found on an DSLR.
This section also controls the vignetting. As soon as I get my hands on some more info on how to calculate the proper vignetting it'll be integrated.

Info & Statistics
This sections shows the calculated values and the formulas used to get them.
And the formulas are as follows:

DOF radius = (focal length / f-stop) / 2

Motion blur shutter = frame rate(1/camera shutter)

As I'm not physicist, if you find the formulas iffy please do tell me!
The formulas comes partly from the help docs and partly from
some twisted minds.

In most cases one would like to know what values that are really used for the blur operations. Check these values to make sure that the blur is not excessive before rendering. If you have some camera experience you'll know what attributes to adjust to get the amount of blur you´re after

Quality & Samples
Basic quality settings for the different blurs.

Connected Nodes
When the script create the nodes that it needed for the foxCamera to work it does not connect it to any of the nodes used by maya to categorize it in the hypershade. Therefore they only show up in the hypershade if the user has added a custom mental ray tab. To resolve this a list of buttons for selecting the these nodes are used (coming feature).

Future
For the script to be really useful for anyone but me it needs to be made fail safe. As of today one would need only to run parts of the script to bring back a lost UI not to invoke the creation of nodes. I just might post some instructions on how to practically use it soon.

Planned Features
The auto white balance is planned to use the suns rotation to get the right kelvin value for the white balance. So for version one this feature would only be useful in a physical sky based scene.
The connected nodes feature should be fixed as soon as possible.

Ideas for Features
  • Focus tracking, ability to lock focus to an object.
  • A global scale parameter.
  • Presets for SLR's, video cameras, film cameras etc.
  • Vignetting based on lens and camera type.
If you wish to take it for a spin here's the MEL.
Use it at your own risk, I take no responsibility!


End of part 1