mia_physicalsky visibility distance

david | mentalray,rendering,tutorials | Wednesday, October 10th, 2007

This is a mini tutorial on using the visibility distance parameter of the mia_physicalsky shader.

Most people probably add mia_physicalsky to their scenes using the create button in the environment tab at the bottom of the mentalray render-settings (shown here)


This creates a shader network involving several nodes. If we look at the camera attribute editor mentalray tab we see that mia_physicalsky has been connected to the environment shader slot and mia_exposure_simple to the lens shader slot.cameraAttrEdA.jpg

The default settings are a good start point for lighting out door scenes. Here is a render of a 9 objects in a line using the default sun and sky settings - except for the mia_physicalsky visibility distance, which I changed from 0 to 10.

default sun sky render

So what is visibility distance and why am I writing about it?

The manual says "Aerial Perspective is a term used by painters to convey how distant objects are perceived as hazier and tinted towards the blue end of the spectrum. mia_physicalsky emulates this with the visibility_distance parameter." This can be a little confusing for two reasons: 1. there is also a "haze" attribute and 2. it doesnt seem to matter what value you give to visibility distance - nothing changes.

Making visibility distance work is easy once you know how. You need to connect mia_physicalsky as a lens shader. Our camera already has a mia_exposure_simple as a lens shader, but we can add another one. You might expect that you could drag-and-drop the existing mia_physicalsky shader into the empty lens shaders box, but for some reason that doesnt work. Luckily its easy to do with a simple mel command.

connectAttr mia_physicalsky1.message cameraShape.miLensShaderList[0];

(You may need to change the cameraShape name to match your camera.) Then the camera attribute editor should look like this


Update: You can also install a modified mel script to make the connection using a button in the attribute editor. Read about it here.

If we rerender the test scene we get this


These are the same settings as the first render except now mia_physicalsky is being used as a lens shader as well as an environment shader. Here are some different visibility distance settings



So what is the difference between visibility distance and haze? Haze sets the amount of haze in the air and changes the look of the sky but on its own does not obscure the view of the objects. Here is a render with haze but zero visibility distance


Here is the same haze value but visibility distance set to 100


And here is another variation


Summary: visibility distance only works if the mia_physicalsky is used as a lens shader.


  1. very cool! one question is, why is there this "box" around the objects on the ground. its not there in the render with no visibility distance turned on.

    Comment by doug_at_buck — June 25, 2008 @ 11:07 am

  2. Do you mean the gray rectangle? It is a nurbs surface, put there to catch the shadows and I colored it the same as the ground color in the physical sky node, so it totally blends in with no haze or visibility distance. It becomes obvious when you add haze or vis dist because physical sky ground color is really the lower half of a spherical environment and not a real ground plane. This is just an example. Usually you would probably want your ground plane to fill the camera's view.

    Comment by david — June 25, 2008 @ 11:23 pm

  3. i suppose this is exactly the same method as rendering a grayscale Zdepth pass and using it as a mask to color or blur your render in comp , right?

    Comment by royter — December 13, 2008 @ 8:46 am

  4. I don't know if it would be exactly the same. Similar result though, and I do like doing it in post using a depth pass because it allows me to make changes more quickly. But sometimes there are problems with artifacts on edges of objects, due to the "anti-aliasing in a depth image" dilemma.

    Comment by david — December 13, 2008 @ 11:46 pm

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck