Join Aaron F. Ross for an in-depth discussion in this video Applying ambient occlusion in a shading network, part of Creating Product Shots in Maya.
In this movie we're going to create a shader network, to enhance the ambient occlusion effect beyond what can be achieved in mia material. I want to test my ambient occlusion effect on a surface shader so I can see the effect separate from all the materials in lighting. To achieve that, I'm actually going to turn everything off in my scene. Turn off the white cards, the lights. Turn off the environment. Turn off the table. I'm also going to turn off the watch face, the hands, and the glass.
So the only thing left visible in the view is the watch band and the watch body. Because those are the only things I need ambient occlusion on. With those now, the only things visible I'm going to apply a surface shader to them and, a surface shader is a perfectly flat shader that's not affected by lighting. I'll right-click on the watch body, select the objects, and then right-click on the objects and choose assign new material and this is a mia material. Go up to mia surface and choose surface shader.
Now it's been applied so we can see it in the viewport I'm going to turn the outcolor up to about 3 quarters of the way up. I also want to assign that same surface shader to the watch band, so, right click on the watch band. Select objects, right click the object, and assign existing material, surface shader one. Okay. Sonow, the surface shader's been assigned; let's render that. Select the camera view. And you can see it's just a flat color there is nothing there. Alright now we are going to add the note.
We'll go to the hyper shade window rendering editors hyper shade. And lets bring that surface shader down. So here it is, Surface Shader, right click, and graph that network, so now it's in the work area here. And we want to add an ambient occlusion node. And that's going to be under Mental Ray, Textures. And you'll see that there are 2. MIB ambient occlusion, and MIB fast occlusion. They're very similar. MIB fast occlusion is a little bit faster. It's not blazingly faster, but it's a little bit faster.
If you've got a very heave scene, then you'll see an improvement by using MIB fast occlusion. I'm going to create both of these and when I select each one of them we will see tha attributes in the attribute editor. So MIB fast occlusion is missing one important attribute which is called fall off. We go to MIB and the occlusion you will see there's something called fall off. That's the diminishment of intensity of this bright color over distance. If fall off is set to one, then it's going to diminish the bright color linearly.
If we increase the fall off, then bright will turn to dark more quickly. Which will give the effect of the dark areas spreading out or taking over more. That's if the fall off is set to a value above 1. So MIB amb-occlusion has fall off. MIB fast occlusion does not have fall off. So, that's the reason why I'm not going to use the fast occlusion because I like that fall off effect. If you do use fast occlusion, there are a couple things you need to know. First of all, the spread factor works differently between these two nodes.
Spread is not the size of the effect. Spread is the evenness of the effect. And if it's hemispherical, then it's perfectly even over the surface. If MIB fast occlusion spread is set to 0, then that is hemispherical, or perfectly even. But for MIB amb- occlusion, if you want perfectly even hemispherical coverage, then this spread must be 1, so this is exactly reversed between the two nodes just to be confusing. So, spread for MIB and occlusion should be 1.
For fast occlusion, it should be 0. You'll also see spread EXP here. That's actually a dead attribute that doesn't do anything. It's there to be added later in the future. But currently you can change that to any value and it would do absolutely nothing. One last point about the fast occlusion node. If you use it, then you have to enable ambient aclusion in the render settings. Go into render settings,. And indirect lighting and you'll see down at the bottom Ambient Occlusion and that must be enabled if you want to use the fast occlusion method.
It doesn't need to be enabled if you're using the ambient occlusion node. I am going to use the ambient occlusion node but I want this to be enable because later we're going to use. Render passes. And for that technique this needs to be on as well, so might as well leave that on now. All right, so let's see what this looks like. Go to the surface shader, and then middle mouse drag MIB ambient occlusion onto the out color of the surface shader. And that creates the connection. Go back to ambient aclusion node, and you'll see we've got just default values here. We'll see what that looks like.
Do another test render. And here's the ambient aclusion effect. Anywhere two surfaces are close together, it will be made darker. The max distance is set to 0 right now, so we're getting some default behavior. We want to explicitly set that max distance. I'll set it to a value of 0.5 centimeters and let's store this version and then do another rendering. So, that's with the max distance set to half a centimeter. And that's the default. So you can see this looks a lot better. Now the falloff. I want this to kind of spread out more.
I want to have more dark areas. Make them more strident and more obvious. I'll increase the falloff amount up to a value of 10, and then store that image and do another rendering. So that's a falloff of ten, falloff of one. And then default settings. Ok, so cool, so this looking pretty good now at this point I think, I got pretty good results maybe bring up the samples, cause this is looking a bit grainy, test that once again, in the final rendering we probably won't notice this grain so much because it's going to be integrated in the shader network.
Basically it's just going to block the light hitting the diffuse and reflection channels. Okay, cool. So, now we go back to hypershade, I've got it minimized. And now we want to connect that ambient occlusion node to our chrome material. So we want to go up to chrome mia and right-click on graphics network. And then to get our texture back, we'll go up to Textures. And here is MIB_ambient_occlusion_1. And we can middle mouse drag that down to the work area. And we want to now connect that to the chrome material. So select the chrome material, and middle mouse drag the ambient inclusion onto the diffuse color.
And also onto the reflection color. And in this case we got lucky because the ambient inclusion bright color is white and that was also the color we had previously chosen or the diffuse and reflection colors. So, in other words we don't need to change anything. If we wanted a gold material or some kind of tinted metal or any tinted color at all, then we could change this bright color to whatever we wanted. Okay, we're in a good place now we just need to re-assign that chrome mia material. So, we'll go over and select our objects.
Right-click watch band > Select objects. Right-click chromea and assign. Right-click watch body > Select objects. Right-click chromea and assign material. And then turn on all our layers once again. White card lights. Environment table, watch phase, watch hands and glass. And double checking our render settings, we do the final gathering on and inclusion is on but it doesn't need to be. Select the camera view and render.
Our rendering's finished. We want to compare that to the version without ambient occlusion, so we can see the difference. Store this image. We've got these test images in here. I'm going to delete those. Those are kind of intermediate images. Delete those. And now we've got, here's the ambient occlusion version. Take a look at these areas here in the cracks. And here's the non-ambient occlusion version. So, that's no ambient occlusion, and then with ambient occlusion added. You can see the difference there. The grain not withstanding, we're adding darkness in certain areas, here.
And that's going to enhance the realism. You can see it through out that we're getting, wherever there's cracks in between things, we're not getting any light getting in there. Cool. So that's how we apply ambient declusion though a shader network in mia. We've still got a lot of grain in our rendering, but we're going to fix that up in our final chapter by increasing the mental ray sample settings and the light high sample's values. And that finishes up our chapter on materials, or a product rendering in Maya.
Want to learn how to create the same effect with 3ds Max? Check out Creating Product Shots in 3ds Max.
- Understanding the scene layout, hierarchy, and display layers
- Working with mia_material_x
- Creating and optimizing mental ray area lights
- Generating reflections with self-illuminated white cards
- Providing indirect illumination with Final Gathering
- Image-based lighting with high dynamic range files
- Rendering to a 32-bit file format
- Saving material and lighting components to render passes
- Adding ambient occlusion
- Layering and color correction in After Effects