Viewers: in countries Watching now:
Lighting and Rendering with mental ray in Maya with Eric Keller shows how to master practical mental ray techniques for rendering models created in Maya. This course walks through the most efficient and innovative mental ray techniques, including direct versus indirect lighting methods, creating different types of shadows, using the new ShadowMap camera, and reusing shadow and final gathering maps. A chapter on optimizing render times and enhancing render quality is also included. Exercise files are included with the course.
The Bokeh Lens Shader in mental ray is the best way to add depth of field effects or depth of field blurring in a scene, mainly because it's easy to control, and it's actually very efficient. Normally rendering with mental ray, you'll find that in your Camera settings, there are some settings here for depth of field. So these are sort of the native Depth of Field effects. These work pretty well; however, you'll find that if you use the Bokeh Lens Shader instead of using these, you get a better-looking render, and it will also be more efficient.
And in this movie, I am just going to describe how to add the shader and why it works better than using these Depth of Field effects. So let's take a look at the render of the scene as it stands right now, without depth of field. So I am just going to create a render from camera1. So here is the scene, and it uses some global illumination, physical light shader on the lamp here. I have a point light behind the camera, which you can see reflected here in these reflective spheres right here, and then just a number of objects that are positioned throughout the scene.
So I will store this image. I have camera1 selected, that's my rendering camera, and I am going to go down to the Lens Shader section, under mental ray, and I am going to click on this checker box next to Lens Shader, pull up the Create Render Node box, and here, under mental ray, I am going to click on Lenses, and I am going to click on mia_lens_bokeh; Bokeh is Japanese for blur, so that's what this means.
So I am going to click on that, and it has added it to the camera. So here are the attributes for the shader itself, mia_lens_bokeh. If you see, if I click on camera1 here, you can see it's connected right there, and I can just click on this Arrow button to switch to the attributes. So I am going to leave the attributes at their default settings and create another test render, so we can see how this looks. So here is the result we get from the render.
You can see that it's taking quite a bit longer, four minutes. Adding depth of field is always going to add a lot to render time, so it's something that you really want to be careful when you add to your scenes. Let's take a look at the render here. You can see that way in the distance here, at the end of the room, it's blurry, but it's more in focus than the objects that are closer to the room. The reason for this is because of the position of the focal plane in our scene. So I would like to show you how you can adjust that. And that's this setting right now.
Currently, it's set to 100. If I switch to the Perspective view, we can see our grid down here, and this is about 10 units. 100 units from the camera is going to be out here somewhere. These parts of the scene are going to be already slightly blurry, and these parts of the scene are going to be very blurry. So to bring these objects into focus, we can start to reduce this value. What I would like to show you is a technique to make this a bit more interactive, because rather than constantly making adjustments to the setting and doing a test render and seeing how it looks, it would be nice if you had some interactive controls so that you could just position something in the scene and know that that part of the scene is going to be in focus.
So I will show you how to set up a custom control for doing just that. I am going to go to the Create menu, and I am going to go Create > Measure tools > Distance tool. So you'll see that the cursor changes to this crosshair, and I am just going to click just randomly, anywhere in the scene; see it's going to create two locators in the scene, and between them I have this little icon, indicating the distance in the tool. So as I move either one of these locators, you'll see the distance increase or decrease.
So this gives me a better way of seeing the distances between objects in the scene. So the first thing I like to do is I am just going to constrain this locator to the camera, so this is always attached to the camera. So to do that, I am going to select camera1 in the Outliner. I am going to Ctrl+Select locator1 in the Outliner. I am going to switch to the Animation menu set, and under Constrain, I am going to use Point. Let me open up the Options here under Point Constraint and make sure that Maintain offset, you want to turn this off.
If this is off, the locator will snap to the position of the camera. So I am going to press Add, and you can see the locator snaps to the position of the camera, and now everywhere I position locator2 in the scene, I can see the distance. So in other words, I know that this sphere is 49 units away from the camera. So now what I can do is I can connect the distance indicator here directly to the Lens Shader, so that I don't have to adjust that slider anymore.
Everywhere I move this locator in here, it will automatically adjust. So in other words, if this distance is connected to the Plane setting here on the Shader, then I know every time I move locator2, wherever I put it in the scene, this Plane setting will update automatically, and I don't have to worry about adjusting that anymore. So to do that, I am just simply going to open up the Hypershade here. It's just one way to make some connections. And in the Work Area, I am just going to drag camera1 over here, select it, and do Graph, Input and Output Connections right here.
And when I do that, I can see, here's my Lens Shader right here. And I am also going to drag the distanceDimension node here from the Outliner. I am going to middle-mouse-button-drag this into the Work Area of the Hypershade. So now what I am going to do is I am just going to middle-mouse-button-drag distanceDimension, choose Other. I want to make sure that I have the Distance setting in here.
I made a very simple and typical mistake. So let me do that again. What I really want to do is I want to make sure that I drag the Shape node of the distanceDimension. So I am going to go Display, make sure that Shapes is on, so I can see Shape nodes, and I am just going to expand this, so I can see, here is the Transform node for distanceDimension1, and here is the Shape node. This is what I actually want to middle- mouse-button-drag into the Work Area. So now that I have that, you can see it's connected to locator2 and locator1. Now I am going to middle-mouse-button- drag distanceDimensionShape1 on top of mia_lens_bokeh, and I'll just choose Other.
When I do that, down here at the bottom, I have Distance, I can click on that to select that, and here on the right side, I'll choose Plane. Now we can see in the Work Area, we have a connection now between distanceDimensionShape node and the MIA Bokeh Lens. If I select the lens, you can see the setting here is 49.270, and this is what this is showing here in the outliner: 49.269; its rounded up for us a little bit.
So now as I move, I want to move this to the position of the Cube here, the setting of 25, and take a look in this tab. We have a setting of 25. So now, let's take a render. Before I do another render, I want to adjust a couple of more settings here. The Radius is going to adjust essentially the blurriness of the scene. So the lower the Radius, the sharper the scenes will be, and by lowering this, I am going to save a little rendering time.
Let me set this down to 0.5, and let's pull up our Render view. I am going to store this image, and create another render. So here's our render, and I've reduced the render time a little bit, and that's mainly by decreasing the Radius setting, because now I have less blurring, so that saved a little bit of render time. So now you can see that the cube is in focus, the stuff in front of the cube, the sphere is out of focus, and the stuff behind the cube is also out of focus. So here is where the plane is in my settings.
So as I move locator2 anywhere in the scene, I know that those objects are going to be in focus, and the rest is going to be blurry. I am going to undo that and go back there. I would like to show you a couple of other settings on the shader that will be very helpful. And switching back on the mia_lens_bokeh tab. The Radius controls the amount of blur. The Sampling controls the quality. You can see that this blur is very grainy here.
By increasing the samples here, I will get higher-quality blur. It will look smoother. It will increase render time a lot. So be careful when increasing that. But the reason that I like this shader, as opposed to the traditional Depth of Field settings there on camera is that this sampling is applied only to the areas that are out of focus in the render. If I was using the traditional Depth of Field, in order to improve the quality, I would have to go to the Render settings, and under Quality tab, I would have to adjust the Min and Max Sampling.
And when I do that, it will improve the blurring, but unlike using the Bokeh shader, it will apply those settings to everything in the scene, which will increase render time even more. So using the Bokeh shader is much more efficient render-wise than using traditional Depth of Field, and that's why I prefer it for creating Depth of Field effects in the camera. To adjust the look of the highlights and other qualities, in other words, the way the blur looks, you can adjust the Bias and the Blade Count and the Blade Angle, and those will change the way that the highlights look, the shape of them, as well as some of the other aspects of the blurring.
But that's the basics for using the Bokeh shader. I think when you're creating in camera Depth of Field effects in your renders, that's definitely the way to go.
There are currently no FAQs about Lighting and Rendering with mental ray in Maya.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.