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:
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.

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).

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

Friday, October 19, 2007


Since it only took me a day to get the max 2008 glare shader to work
"properly" whit in maya I just have to spill my guts about it here.

Ok, We'll start with the basics.
What is this glare thing I keep rambling on about and why should anyone care?

Glare (known as bloom in the computer game world) is a
phenomena seen when looking into very bright light
(namely in a high contrast environments) such as the sun
a cars headlights or a lit window late at night.
The source of light seems to be "glowing", it looks light you can actually see the light mid air.

Notice the effect by the lamp.

Ok, so we covered what it looks like, but we cant really see light midair. So what the heck is this glow thing?

Unlike many other camera artifacts this effects can be seen both in images taken with a camera as well as simply looking in to bright objects with your eyes. It is caused by scattering of light in the eye (some part of it, lets not get in to biology here)
,the film in an analogue camera and the CCD on a digital camera.

Used correctly this effect will give a subtle boost to the realism of a rendering. Use it in excess and the image WILL turn in to a "german-wedding-photo-effect".

Lets get back to the shader.
The glare shader was originally written by Lume as part of there light shader set. The lume shaders now come as a part of 3ds max.

To get this shader working in maya copy the lume.mi from:
3ds Max 2008\mentalray\shaders_standard\include

and the lume.dll from:
3ds Max 2008\mentalray\shaders_standard\shaders

This is all you need to do to just get the glare shader to work with maya, however the lume.mi do kinda destroy the create render node window so you need to edit that file to some extent to get it all smooth. But if you just want to fool around never mind this and just delete the files when you are done.

This shader is an output shader, that means it applys to to the rendered image as a post effect. Select your camera and find the tab mental ray>primary output passes>secondary output pass
drag the Glare shader from hypershade (mental ray tab > ouput shaders) here.

Take a few seconds to breathe...ok, lets continue with shader settings.
Quality: ranges from 0 to 4, but has to be a minimum of 3 to work.
Spread: the spread of the glare, note that the light intensity at any given point also makes the glare spread more or less.
Overlay only: Doesn't work.
Verbose: Prints the progress in the output wnidow.
Streaks: Doesn't work.
Scale: Doesn't work.
Contrast: Doesn't work.
Specific Objects: Doesn't work.

No glare.


Wednesday, October 17, 2007

3ds max 2008

Today the new version of 3ds max was made available
for trial download.
The news concerning mental ray is about the same as
in maya but with a more slick OEM integration.

Ill think play around with it for o while and then
its time o try to brake out the improved glare shader
and fiddle it in to maya.. but thats another post.

glare in action

Monday, October 15, 2007

Flicker free animation.

Todays experiment will ( as the title gives away ) handle
flicker free animation with mental rays final gather.

Due to complications with my composting software I will be
unable to finish this experiment. This post will be updated as
soon as its is technically possible.

Friday, October 12, 2007

What to do when rendering.

One of mans first and most important questions:
What on earth am I supposed to do while i wait for this rendering
to finish?

I'll present 3 things which makes my rendering time fly.

1. Physically and mentally abuse the local stuffed animal.
In my case a stuffed animal in the form of a hen
(he.. yes he, is also our director).

2. Surf aimlessly around the Internet in the search for some fact no one
really needs to know, like which animal has the longest tail as percentage of there body.

3. Search the entire server for all files containing the
word force majeure (seems to be about 6 here).

I believe this image speaks for itself.

Wednesday, October 10, 2007

GI the Rambo way.

If Rambo ever got the idea to do some global illumination he would do it the most brute force way there ever was. In mental ray this method is called path tracing.No mumbojumbo, no cryptic controls or shaders.

It is all super mega ray tracing, which means two things:
1. It's super accurate.
2. It's super silly slow.

There are a few things to keep in mind when path tracing. Most important is to use only the path_material, and since this is brute force there are no photon shaders or such needed. In your render settings be sure to disable all photon techniques ( GI and caustic ) as well as final gather.

As we are about to use pure ray tracing as GI we need to make sure that our standard ray tracing depths are high enough to distribute the light through out the scene.

Last but not least, we need a ton of samples to get the render smooth.
( You probably need to look into the oversampling_lens )

Here is an example of the difference between samples, these images were rendered
with min/max 2/2, then oversampled with the oversampling_lens.
Those over samples are the image annotations.

Note. render times are per full frame (415x415)
the images were cropped for easier compare.

In conclusion.
This special technique might not be something you would want to use in your pipeline. But it's always a plus to know as much as possibly about your tools of trade.

The mia_lens_bokeh shader.

Todays mental ray experiment focuses on lens artifacts
such as chromatic aberration, scratches and blooming/glare.

First of: chromatic aberration.
Chromatic aberration is an artifact often seen when using
low end or wide angle lenses. Due to the colors different wavelengths
and the differing index of refraction on the lens, the color spectra
gets separated, mostly on high contrast parts of the image.
( for a more correct explanation take a look at this wikipedia page )

One way to produce this effect is to use the new
bokeh shader shipped with Maya 2008 (mia_lens_bokeh).
The result produced this way will not be at all physically correct
but will give a similar look to the rendering.

Ok, lets see some example.

Top image image taken with a higher quality lens producing no chromatic aberration.
Bottom image taken with a wide angle lens producing substantional chromatic aberration.

Next let's look at the result we get from our bokeh shader

Notice that we only get the effect on the out of focus regions.
This is due to the use of the bokeh shader which is a depth of field shader.

The setup to get this result is really quite simple.
What you need to edit on the shader is the following:
  • Check the "Use bokeh" check box
  • higher the bokeh samples (or the image will render black)
  • load a color map texture in the "Bokeh" slot
The texture used in the rendering above is a really crude RGB map
that look like this.

Thats all on chromatic aberration for now.

Tuesday, October 9, 2007

Bravia #3

Heads up for the third sony bravia TV commercial.
This time its all stop motion made by passion pictures.
Thought this clipp would be the perfect start to this blog
( both bunnies and colors! ).

Kinda sandboxing here.

I really don't have any things to blog about at the moment.
But I'll add an image just to test this new awsome blog.

Ok. that did not work at all, I'll give it a try later on.