In this series of tutorials, we'll be taking a detailed look at each of mental ray's texture nodes. Each video is a self-contained tutorial centering on one of mental ray's nodes. This means that these tutorials can be viewed in any order you wish, allowing you to jump straight to the content that is most relevant to you. Over the course of these tutorials, we'll learn how each node works and best practices to utilize for attaining desired results while saving time. Software required: Maya 2008 and up.
Kyle was one of the first authors for Digital-Tutors (now a Pluralsight company) and has been a part of the team for over 10 years. Kyle began his career in computer graphics education as a college instructor and worked as a Digital-Tutors rendering tutor and curriculum manager since 2002.
Introduction and Project Overview [Autogenerated] in this lesson. We're gonna take a look at the m ight. Be ambient occlusion shooter, and we'll see how this could be used to really make the detail pop out on our model objects. All right, so if you open up the star file for this lesson and hit render, you'll see that we have really just a very simple light setup. We have just a single point light that's able to cast some shadows. And then we're also using a little bit of final gather to kind of introduce a little bit of secondary in direct illumination. Now, for the most part, this is not a bad light setup, but you'll see that there is actually quite a bit of model detail in here that is somewhat difficult to make out. So what we can do is utilize something like the ambient occlusion shader to really make this pop. So this Ambien occlusion shader can be found over in the hyper shade. If we take a look inside the middle rate nodes, this Ambien occlusion is actually found inside the textures tap. This is actually a texture that we're gonna be applying. So the same conclusion shader can actually be connected to any of the existing Mayan notes. So a good candidate to connect this to as the Maya surface Shater. And the reason being is because the surface shader doesn't calculate any kind of shadows or highlights anything like that. So what we get back will be just pure color information that's return from this. So let's take this in conclusion. Shader just connected to the default attributes of this surface later, which should be the outcome. So now let's just take this surface shader and you simply assigned it to our object. All right, let's see what we get Now you'll notice that our render now comes back very, very quickly. So this is actually a very fast shader to evaluate. And you notice that we now have a little bit of sheeting information that's been applied to this. But you'll also notice that there is actually no diffused color information. This is really just a flat shaded image. All right, so let's zoom in and just get a little bit closer into this. I will try to discuss exactly what it is that this Ambien occlusion shader is doing all right. So, really, this Ambien occlusion is not actually creating any kind of shadows. This is really just a distance based shading trick, but you'll see it's actually a very good trick. So, really, the way that this works is this a mean Occlusion is able to look at two points that are relatively close to each other, like right where my cursor is. So with these points, very close the meat occlusion shader will shade those areas black, and you'll notice that as we start to get further and further away to some of these areas that are not really close to any other kind of a surface point, those points start to be shaded closer and closer white until you start to get out into some of these areas around the front that are really not close to anything as far as being able to reach out with any kind of rays and sample any other piece of geometry. So those points, as a result, just get shaded white. So like I said, this is really just a distance based shading trick, but it is very, very effective at letting us pull out some of this actual model detail that we have on this mesh. Now, a lot of times we would actually render this occlusion out as its own separate pass in this condemn, be composited back on top of our color pass to start to get some of these nice, secondary soft shadows. So if we wanted to do this, you'll notice. In my case, my background is actually said to Blue, you're working on your own. Seen this may be set to something like black by default, and that's really not something that we would want for compositing purposes. So let's go to the camera. Just select the camera and we'll set the background color toe white. All right. And this is pretty much what we would want if we were going to use this for compositing so we could just simply output this as its own separate pass, then use something like after effects or Shaker fusion, and then just simply dropped this on top of her color past and use something like just a simple multiply blend mode to kill everything that's white and just leave us with these dark, shaded areas. All right, so let's take a look at some of the attributes that are gonna be found in this Andean occlusion Shader. If we double click on this, you can see that we do have a handful of attributes here. The first is the number of samples. Now, this is basically controlling how noisy or how greenie these shadowed results will be. So with a fairly low value, you can see that our renders do come back relatively quick, although they do contained quite a bit of noise. So if I were to increase the number of samples to something like 64 and just say this image for comparison, you'll see that our rented image is now a lot less noisy than it was before. He compared the two images. But you will notice that increasing these sample rays will also start to slow down your renders a little bit. So do try to be aware of not taking these up too high. Now the bright and the dark colors really just refer to the color that gets displayed and the brightest areas of this result and the darkest areas. Normally, you would probably want to leave these set to black and white, especially if you're gonna be doing any kind of compositing. But you do have the ability to change those if the's situation calls for it. Below that, we have the spread and the max distance. Now these two values actually work fairly close together as faras, actually, what they do in the ability to use thes or the need to use these. So by default, the max distance is set to zero. Now this is controlling how far out any of these points can reach to sample shading information from other objects by default. This is set to zero, which means these points can actually reach out potentially into infinity. Now this could start to slow our renders down. So always try to make sure that you have a max distance of something defined in here. So that way, the rays won't reach out to infinity. If it's not really necessary and you'll notice with a smaller distance that are shooting, information starts to become a little bit more subdued. So now these points are not able to reach out quite as far to sample some of this information that we can also really choke this bank if we want to. So if we were to dial it down to something like 0.2. You can see now that these points on the mash have to be very, very close proximity to each other to start to have any kind of an effect on each other. All right, now, if I were to increase this max distance, it'll make it a little bit easier to see exactly what this spread does. This is really how fast we transition from the black color to our white color. Then you can see with the spread set to its default value, that this transition happens fairly gradually and starts to give us these really nice soft shading effects. But if we wanted to tighten this up or even spread it out even further, we would do that through the use of the spread. So for you to die a list down to something like 0.1, you can see that we get a very, very rapid transition from the black color to the white color. So this could be a good way of kind of solidifying these soft shadowing effects and give you use something a little bit more closer to the appearance of direct illumination shadows. Likewise, if we wanted to make these even softer. We could take these up to a value of two or three or whatever you decide is necessary. All right, so these are pretty much the attributes that you will be using most frequently when using Ambien occlusion. Although we do have a few other options down here to choose from, we have the output mode which will really kind of let us change the actual result that we get from using this same conclusion by default. It's set to zero, which gives us the standard occlusion that we have now. If we were to set this to an output motive one, this is now going to use some kind of an environment if we have one plugged in to instead derive the actual occlusion result. Now, in our case, since we're not using an environment in our scene, we really won't see much of a difference whenever using this. And even so, even when you are using an environment, the difference that you get from using this is very, very subtle. Now, an output mood, too. We can now start to explain or rather export some kind of a normal pass. So with this set to an output motive too. This will now is basically just shaving our object according to its orientation in world space. So these points that are gonna be shaded more blue are points that are oriented more closely toward the Z axis. You can see those were actually sort of pointing bank in this direction, these points that are shaded more green or get it along the y axis. So these are gonna be areas of this object that are pointing upward. And then we also have the X axis. Which of these red shaded areas these air? Some of the areas that are actually facing a little bit more backward in this direction. All right, now, finally, an output mode three, we have a camera space normal. So if I save my comparison, you can see now that thes points are now She did a little bit differently compared to what we had before. So now we're looking at these points that are shaded now according to camera space. So these points that are going to be more oriented away from the camera and the easy access are now shaded more blue, these points that are oriented away from the camera and We're vertical fashion or shaded this green color and same with the X axis. All right, so that's pretty much the different output modes that we have available to us. Now, just below that, we have the falloff. Now, this is really very similar to the spread and that it controls how quickly we transition from the black into the white portions of this shader. So with a default fall off of one, we get something like this. Now, as we start to lower this fall off, we should now start to see a much faster transition into this white color. So if I see what I have for comparison, you can see that we now kill a lot of the black shaded areas that we had before. All right? And likewise, if this fallen for the increase to a higher level, let's say something like to we cannot start to get these black values that are very, very strong and defined. All right, And then finally, just below that, we have the i d include exclude and the idee non self. Now these have to do with any kind of an object I d. That you've assigned to any kind of geometry. So if you include a label attributes on any kind of geometry, you can then define that actual label number in this particular value. And by defining that you could say OK, anything that has a label value of, let's say, too if we had anything or seen it was labeled with an M I label value of two, you could say, OK, this is now not going to be calculated and the actual occlusion so we can start to use this as a way of including and excluding certain objects based on their mental ray I D. And similar to that we have the idee non self. This is aware on area where we can basically tell objects that have a certain i d not to effect each other as faras, the occlusion goes. So any objects that have a material idea or rather, a label i d of two will have no effect on any other pieces of geometry that have the same label, which is really what these to do. All right, so you'll notice that up to this point, we've just been looking at this flat black and white image. So, really, for occlusion. This is a good way of exporting this for compositing purposes. Now, if for whatever reason we don't want to use this for compositing, we maybe just want to render this here in the view port with color and compositing or rather, color and occlusion. We can actually do that. So all we would need to do is take this occlusion, shader and just simply take any kind of a, uh, surface Shader something like a Lambert. And quite simply, just drop it right into the bright attributes. And now this is the result that we get so really all that we've done by connecting the Lambert into our and inclusion. Shader is basically said, OK, anyplace where we would normally calculate the white portion of the shader instead. Now calculate the labor. So this is how we can start to mix the diffuse color information of our shooters in with the ambient result of this Amy conclusion Shader, you can see the shooter really does a great job of adding a lot of visual contrast to a lot of our model areas of our geometry. So that's a look at how we can utilize this Ambien occlusion, shader