Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
If you're using mental ray, there are other ways to create depth of field. And these are using what are called Lens Shaders. Now what Lens Shaders are, are basically filters that attach to your camera that simulate different types of lenses. So I've got the same scene that we've used before, but in this case I've actually changed the renderer to mental ray. Now in order to set up depth of field in mental ray using a Camera Shader, we can go into the Camera Attribute Editor.
Now if we scroll down you'll see that we have Depth of Field. We can certainly turn that on, but in this case we want to turn on the mental ray parameters here. So we have a number of different things that we can do. One is an Environment Shader, which basically gives you kind of the environment of the room that sort of things, good for reflection, that sort of stuff. Volume Shader, and the one we're interested in is called the Lens Shader. So all I have to do is hit this Texture button, and it brings up my Create Render Node menu. Now I've got all my mental ray stuff here, but I can't attach just anything to my lens.
For example, I can't attach car paint to my lens. I have to attach Lenses, so if I go here there's actually category called Lenses. So all of these can be used on a mental ray camera. So we have a physical lens depth of field. One's called an oversampling_lens, and couple of other ones. The one I want to use, it is actually just one of my favorites, is called Bokeh. So this is basically the blurring effect that you get for Depth of Field. And certain types of lenses are actually valid for the type of bokeh that they do.
So, what we can do here is we need to set a Plane. That's the focus distance. So, what we can do is we can use our Heads Up Display like we did before. So make sure Heads Up Display and Object Details are turned on, and then we need to decide what we're actually going to focus on. And in this case let's go ahead and focus on this red cylinder, and that's at 41 units away from the camera. So, if I go back to my Camera Attribute Editor, go into my Lens Shader here, and go back down here, you just say my Plane is 41.
Okay, now the Radius. This is again the distance that is focusing how much is in focus, how much is out. Let's go ahead and just leave this at the default. Number of Samples, this is the quality of the blurring effect. Bias, that deals with the quality of the blurring effect. Blade Count, so Blade Count allows you to simulate specific lenses. So, some lenses have more blades than others and different numbers of blades will create a different blurring effect. Now, at 0 it has an infinitely round blade, and then the Angle of the blade.
So if we turn that on, all I did was set the plane and left it at default and just did a quick render. Let's take a look at what this looks like. So as you can see, we get a pretty high-quality effect. Now I do have Reflections turned on in this, so you can kind of see the reflection of one thing in the other, but you notice how the effect is pretty good, but we're getting kind of a grainy effect here. Now that's actually the number of samples. So, if I increase the number of samples, so let's say go from 4-16. You can always go higher. Increasing the number of samples increases the quality of the effect.
Increasing the number of samples to 16 greatly reduced this edge effect and we can certainly increase it more if we want. So let's go ahead and play with some of the other ones. Now Radius, the higher the number of Radius the more blurring you get. So, for example, if I would bring this up to say 3 or 4 and do a render, we'll see a much more enhanced effect. So, at a radius of 4 you get a very enhanced effect. If I brought this down to say maybe 0.5 then more of the scene would be in focus and less would be blurred.
Now I'm going to go ahead and place this back to 1, and the other one we want to take a look at is Blade Count. Now this actually controls just the quality of the effect. Different Blade Counts will just make things look a little bit different. Not so much better, worse, more or less blurred, just slightly different. So, we've got a number of different effects that we can use on this Bokeh Lens Shader. Now there are other types of Lens Shaders that you can apply to mental ray lenses. So you can actually play with these, but this is actually one of my favorites. So this is the one I've used a lot in production.
It's actually a really good shader to get high quality and very controllable depth of field. So go ahead and use Bokeh in your scenes and use other Lens Shaders as you see fit.
Get unlimited access to all courses for just $25/month.Become a member
107 Video lessons · 35608 Viewers
100 Video lessons · 6131 Viewers
94 Video lessons · 24884 Viewers
83 Video lessons · 10513 Viewers
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.
Your file was successfully uploaded.