Occlusion in 3dsmax 7
Computers and application software are evolving at a tremendous pace. New methods and technical improvements are being introduced with every software release and today creating photorealistic renderings is just a couple of mouse clicks away.
Going back a couple of years, raytracing, particularly raytraced reflections, was nothing more than a fake simulation with the refmap.gif file for 3ds(max) users whereas the term "Refractions" were arousing just a simple question: "Is it possible?". But today we have state-of-the art rendering engines which are available both as standalone and bundled rendering solutions for major 3d software applications aiding the 3d artists to create hyper realistic imagery.
"Global Illumination" or "GI" is one of the techniques available within the contemporary rendering engines which accurately simulates the real world lighting conditions given the proper cpu power and enough time for computations. In today's production environments usually time is of concern if not the cpu power thus makes GI an "expensive" method for visualisation. Optimizing quality rendering time with alternative methods has become an essential need for the production process.
If you are dealing with 3d rendering, you probably have heard of the "Occlusion" method. In the Siggraph 2002 presentation "Production-Ready Global Illumination",Â ILM Technical Director Hayden Landis tells about this alternate method they developed for simulating GI effectively with speed.
Apparently this relatively new technique has been used by many huge production houses for their projects but it has just began to be available as a common toolset for the regular 3d artist like myself :)
With the introduction and integration of mental ray, 3dsmax has gained a strength in its rendering department, particulary the photo-realistic section. 3dsmax 7 now has the ability to render ambient and reflective occlusion images with the help of a mental ray 3.3 shader.
The Ambient Occlusion method is basically rendering out an occlusion pass(which is a grayscale or a tinted image based on environment map) and then overlaying this image over a flat lit diffuse pass(achieved by ambient lighting, I'll describe it later) to represent the shadowing caused by the environment. That's why the method is called "Ambient Occlusion", to describe the occlusion(blocking) of the ambient light amount to simulate GI shadows. It is just like rendering your scene with a GI skylight, with no specular highlights or cast shadows and faster than GI
Analysing the Scene
This image is rendered at 640x470 pixel resolution on a dual opteron workstation with 3dsmax's native GI engine LightTracer in 14 minutes 27 seconds(with default parameters used, you can tell by the artifacts). It shouldn't be considered as a very long time for the GI rendering of a complex object like this car. But if I was to render a high quality animated sequence within a tight deadline, quarter an hour per frame will add up to a relatively long period of time.
Let's see how we can decrease the render time for this specific scene with ambient occlusion method in 3dsmax 7 using mental ray.The scene has a simple setup. There is a ground plane with the car geometry placed in the middle and a spherical mapped gradient ramp is used in the environment slot to represent the sky background. For the lighting, only one skylight is used to illuminate the scene with LightTracer and a couple of other point lights are used to create highlights on several places on the car body
Preparing the Passes
I will be using three different passes for the final composite.
(1)"the ambient color pass" for main diffuse rendering,
(2)"the ambient occlusion pass" to attenuate the diffuse pass and
(3)"the specular pass" to control the highlights seperately.
The Ambient Color Pass
The ambient color pass is the flat lit diffuse rendering pass only illuminated by the scene ambient light.
To render the ambient color pass the first thing we need to do is to turn off all the scene lights from each of the light's general parameters rollout. In addition to that Advanced Lighting should be turned off as we are trying to simulate GI without it. You could do this from theÂ Render Scene Dialog(Default Hotkey: F10) or from the Rendering pulldown menu.
The last step is to turn up the ambient color which is on the Environment Panel of the Environment and Effects dialog (Default Hotkey:8) The ambient color with a Value(HSV) of 140 would do fine to reveal the object clearly in the rendering.
The pass takes only 51 seconds to render including raytracing. Here's what it looks like
It will be wise to render out a specular pass while we are at it because scanline renderer has to be replaced with mental ray in order to render the occlusion pass.
The Specular Pass
For the specular pass the point lights should be turned on to create the highlights. Remember that my scene point lights only affect the specular component of the surfaces not diffuse. Skylight remains turned off. To render out a seperate pass for specular highlights we will be using render elements. This can be done from the Render Scene Dialog, Render Elements Panel. By pressing Add.. button and choosing "Specular" from the list we activate the specular highlights pass for this scene to be rendered out seperately.
After filling in a proper name and defining the output path, we render the scene once again. After the rendering is finished if you haven't unchecked the Display Elements option from the Render Elements Panel the specular pass would be displayed as a seperate virtual frame buffer. The pass takes 59 seconds to render and looks like:
As I said earlier, before rendering the occlusion pass, mental ray has to be assigned as the current renderer from the Render Scene Dialog. The option can be found under the Common tab of the dialog box. Now on to the occlusion pass.
The Ambient Occlusion Pass
For the rendering the occlusion pass, a mental ray surface shader named "Ambient/Reflective Occlusion(base)" should be assigned to the scene geometry. As surface shaders behave like regular 3dsmax maps, they should be attached to a material in order to be assigned to geometry.Â So it would be appropriate to use the Ambient/Reflective Occlusion(base) map in a native mental ray material's Basic Shaders>Surface slot. Now the mental ray material can be assigned to the scene geometry to render the occlusion pass. Before assigning the material let's take a look at the shader's parameters.
I will be dealing with Samples and Type sections of the shader. Default sample amount of 16 would not be enough for a high quality image and will tend to flicker in animated sequences so it should be cranked up to at least 64 for smooth GI look for this image. Of course it all depends on your scene's needs, how much quality GI you want and how much time you have for rendering your scene. Spread parameter determines how the GI samples are scattered and default values would suffice in this case.
You only need to set the type ofÂ the shader which is 0 for standard occlusion, 1 is for occlusion with environment map and 2 is for bent normals mode with RGB values as occlusion which can only be used in an appropriate compositing software.Â
If Type is set to mode 0 the occlusion render will be a grayscale image based on the default Bright and Dark values of the shader which can be modified in RGB color space to obtain a tinted rendering in case you need one.
I want the rendering to reflect the environment colors of the scene so I will set the shader type to mode 1.
Tip: By the way if you do not want to loose the original materials in the scene, a quick way to assign a single material to all scene objects is by enabling material override from mental ray's Processing Panel and dragging the desired shader to designated slot.
After making the adjustments and assigning the material to all the scene members, the pass takes a minute and a half to render. The longest rendering time for a pass so far. The pass looks like:
Moving on to compositing, I'll be using Photoshop here but the method is similar between all the applications that support various blending or transfer modes between layers like Multiply, Overlay, Screen and so on..
We start the compositing by placing the Ambient Color Pass as the base layer:
Then we overelay the Ambient Occlusion Pass with "Overlay" blending mode:
The image looks a bit dull without the Specular Pass layer. Put it on top with the "Screen" transfer mode to complete
If we compare the original GI rendering to the composited image, they look more or less identical. Apart from one thing: The interior of the car looks flat in the composite. This is due to a shortcoming of the ambient occlusion shader as it doesn't support transparency. We would have to tradeoff our rendering time to transparency if it was supported anyway :) One workaround for this situation is by rendering a separate occlusion pass for the interior and compositing it over with a mask image for the windows
For creating the mask image we apply a Matte/shadow Material to the glass portions of the car and render it to obtain a mask from the alpha channel. You can do this by rendering the image to a TGA file and checking theÂ Alpha Split and Pre-Multiplied Aplha from the Targa file settings. The mask will render in 52 seconds
We'll use this mask as the layer mask for the ambient occlusion pass. With the Ambient Occlusion layer selected choose Add Later Mask>Reval All from the Layer pulldown menu. A white layer mask will be added next to the layer. Next we'll have to copy the mask image we rendered and paste it to this layer mask. This can be done via the Channels palette. We enable the transparency channel of the ambient occlusion layer(pressing the eye icon) and paste the mask image into it. We now created a mask that will enable us to see through the interior of the car.
As the last step, I will render out an occlusion pass just for the interior. Same method as described before, but this time I will be applying the Ambient Occlusion shader just to the interior parts of the car and the Matte/Shadow to the remaining objects to help me with the compositing. The pass will render in less than a minute
I then apply this layer with "Darken" blend mode which can vary depending on the image and desired look