Unity 4.3 Essential Training
Illustration by Mark Todd

Adding depth of field


Unity 4.3 Essential Training

with Adam Crespi

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Adding depth of field

Depth of field is one of those effects that really can add some visual subtlety, power to your images. Sunbeams are neat and they're really cool to see coming in through windows. An ambient inclusion really adds the gravity. But putting depth of field on, really takes the player from seeing something that's not quite right to really sitting in the scene. Here is why, we see with our two eyes or occasionally one. Out to one point in space. And things beyond that, things in the background and things closer than that in the foreground, blur out.
Expand all | Collapse all
  1. 2m 57s
    1. Welcome
    2. What you should know before watching this course
    3. Using the exercise files
      1m 24s
  2. 21m 21s
    1. Designing the game
      4m 39s
    2. Setting the project
      4m 9s
    3. Exploring the Hierarchy, Scene, and Inspector windows
      5m 45s
    4. Creating and transforming objects
      6m 48s
  3. 21m 34s
    1. Organizing the Assets window
      2m 55s
    2. Exporting objects from 3D modeling programs
      8m 33s
    3. Importing and configuring models and textures
      4m 54s
    4. Setting properties for models and textures in the Inspector
      5m 12s
  4. 29m 8s
    1. Introducing the game environment
      4m 27s
    2. Placing the player controller
      4m 29s
    3. Publishing project settings
      5m 32s
    4. Adding sky and fog
      8m 17s
    5. Fine-tuning the First Person Controller
      6m 23s
  5. 57m 25s
    1. Creating the terrain geometry
      3m 29s
    2. Forming the topography
      9m 54s
    3. Painting the terrain textures
      7m 9s
    4. Painting trees and forests
      10m 55s
    5. Painting grass, shrubs, and 3D geometry
      9m 38s
    6. Painting detail meshes
      8m 46s
    7. Adjusting terrain settings
      7m 34s
  6. 39m 45s
    1. Creating materials and assigning shaders
      8m 56s
    2. Handling multiple materials
      7m 13s
    3. Adding textures to a material
      3m 57s
    4. Manipulating textures
      5m 20s
    5. Adding reflections to materials
      8m 1s
    6. Creating lit materials
      6m 18s
  7. 47m 12s
    1. Creating GameObjects
      5m 2s
    2. Understanding components
      6m 15s
    3. Using colliders for barriers
      6m 22s
    4. Using colliders for triggers
      8m 1s
    5. Exploring physics
      8m 22s
    6. Working with Physic materials
      5m 3s
    7. Adding joints to rigid bodies
      8m 7s
  8. 20m 33s
    1. Setting up prefabs for animation and batching
      5m 8s
    2. Animating an object
      6m 32s
    3. Adjusting timing in an animation
      3m 50s
    4. Animating transparency and lights
      5m 3s
  9. 11m 58s
    1. Importing skinned meshes
      4m 51s
    2. Separating animations into clips and states
      3m 14s
    3. Creating transitions between states
      3m 53s
  10. 30m 22s
    1. Customizing ambient light
      2m 59s
    2. Creating the sun using a directional light
      5m 49s
    3. Using layers and tags for lighting
      3m 32s
    4. Adding spot and point lights
      4m 25s
    5. Using point lights for fill
      4m 30s
    6. Adding and fine-tuning shadows
      5m 10s
    7. Creating lighting effects with cookies
      3m 57s
  11. 9m 15s
    1. Adding scripts to GameObjects
      2m 42s
    2. Using correct script syntax
      6m 33s
  12. 23m 7s
    1. Setting up a 2D project
      3m 13s
    2. Importing sprites
      2m 30s
    3. Slicing in the Sprite Editor
      3m 6s
    4. Layering sprites and setting the sorting order
      5m 12s
    5. Creating 2D colliders
      3m 12s
    6. Adding 2D physics
      2m 25s
    7. Animating 2D elements
      3m 29s
  13. 30m 25s
    1. Creating light shafts and sunbeams
      5m 20s
    2. Using ambient occlusion to add gravity
      4m 37s
    3. Adding depth of field
      8m 40s
    4. Applying motion blur
      5m 46s
    5. Tuning color for mood
      6m 2s
  14. 38m 16s
    1. Exploring water effects
      7m 36s
    2. Working with wind zones
      2m 8s
    3. Using an audio source
      4m 3s
    4. Creating a sound zone
      5m 59s
    5. Triggering audio
      3m 37s
    6. Adding audio effects
      3m 13s
    7. Creating particle systems
      2m 26s
    8. Adjusting particle systems
      9m 14s
  15. 25m 23s
    1. Setting up occlusion culling
      5m 52s
    2. Enabling batching to reduce draw calls
      3m 28s
    3. Testing in the game window using statistics
      4m 27s
    4. Building a development build and debugging
      6m 0s
    5. Building the executable
      5m 36s
  16. 49s
    1. Next steps

please wait ...
Watch the Online Video Course Unity 4.3 Essential Training
6h 49m Beginner Mar 10, 2014

Viewers: in countries Watching now:

Interested in game making? Start in Unity—a game engine for mobile and desktop games and real-time simulations. Author Adam Crespi shows techniques used in game development with Unity and introduces the basics of scripting and game functionality. First, learn how to import models and textures, organize your project and hierarchies, and add terrain, water, and foliage. Next, Adam explores how to use lighting to bring the game to life, and add rendering, particles, and interactivity. The end result is a sample game with a lush environment, fully animated characters, and some basic interactive gameplay.

Topics include:
  • Designing the game
  • Creating and transforming objects
  • Importing and configuring models and textures
  • Setting properties in the Inspector
  • Creating the terrain geometry
  • Building materials and adding shaders
  • Creating GameObjects
  • Exploring physics
  • Animating objects
  • Lighting the scene
  • Creating 2D game elements
  • Adding special effects
3D + Animation Developer
Unity 3D Unity
Adam Crespi

Adding depth of field

Depth of field is one of those effects that really can add some visual subtlety, power to your images. Sunbeams are neat and they're really cool to see coming in through windows. An ambient inclusion really adds the gravity. But putting depth of field on, really takes the player from seeing something that's not quite right to really sitting in the scene. Here is why, we see with our two eyes or occasionally one. Out to one point in space. And things beyond that, things in the background and things closer than that in the foreground, blur out.

Cameras see the same way. What this means is that when we see a scene like this in Unity where everything is well, smaller in distance but perfectly in focus, it seems a little bit odd. So we can add on some depth or field to tell the audience, I want you to focus in this range. There's two different depth of field image effects we can put on. And I'll go through a little bit of each one, to show what they do. You can choose which one you want to use depending on the look you want. I'll start out by selecting my main camera in the first person controller and dragging over depth of field 3.4.

I'll roll up the screen's base occlusion and pull that in. What this does is say, here's a focal distance and a focal size, and how much blur we have. I'll try it out just at the default settings. And these are going to need some tweaking already, I can tell you. It's beautiful. Apparently, we forgot our glasses today. Because everything is strongly out of focus. Here's what's really going on, joking aside. The focal distance in depth of field is set to one. One meter out is in focus.

Focal size of zero means that 1.1 meter out is in focus and everything else blurs out from there. Theoretical depth of field is zero. Only one point is in focus at a time, but we use focal size to give us a focal plane thickness, is how you can think of it, a zone of focus instead of a point. So that things more or less stay in focus until they really start to go out. I'll push out that focal distance to 15 and bring up that focal size to six. Next, I'll take that Blur Spread way down.

Here it is at 0.25 and I'll take the blurriness down as well. This way, I've pushed out how far we can see, and given us quite a good zone that's always in focus. I've reduced the maximum blur way down. And this way, things aren't subtly blurry in the deep background. Lastly, I'll look at the quality. Right now, the resolution is low, and I'll see if I can get by with it low because high takes more computing power. There's also a quality choice, only background, or background and foreground.

This is a judgement call on the look. If we're using only background, everything in the foreground up to that focal distance is clear and beyond it we start to see blur. With background and foreground on, the foreground blurs as well. Comes into focus. And then we get the background blur. I'll try it on these settings before I switch over and see if I have enough in focus. This is somewhat better. The building across the way is noticeably blurry still. But inside my building I am definitely in focus. It looks good, although my sky is definitely blurring out.

Inside though, everything is nicely in focus, so I'm really telling the audience, you should run around this building and look around what's in here first before you get outside. Once you get close enough to the outside, things will resolve into focus like as you look through the windows, and you can say, hm, maybe I should go look over there, now that I can see what it is. Here's what happens when we turn on foreground and background. We've got a foreground size now, and we'll really start to see things blur out in the foreground at this value. With the foreground and background blur on, we can definitely see where that focal point is.

If I pull back and look into this space, we can see two walls back are in focus, but the emmas are definitely blurred. Its okay to use this because it can give you a very soft, almost dreamy quality. Just be mindful of using too much blur in there. Too much blur is visually disconcerting. It makes us feel like our eyes aren't working well. I'll take that foreground size back to 0.15, again keeping it very subtle. Now I've got just a little blur in the foreground pushing my attention out to where my focal point is.

In this case, it's really up to you. Which one you want to have your audience focus on. If they're back here knocking over the art, that should probably be in focus. So, in this particular case, most likely a foreground blur is not the right choice. I'll switch back to only background. One of the last things we've got here is, enable Bokeh blur. What this does is enable an extreme blur, and we can see it when we turn it on and scroll down. Bokeh blur is when things like specular highlights, or little twinkling lights, blur out into distinct shapes.

Often we see hexagons or pentagons of light, maybe squares and it really depends on the number of blades in the lens. We can customize that Bokeh blur if we need through the texture mask. Taking in a texture with an alpha channel. You can even make a Bokeh blur turn into hearts or stars if you wanted. What this will do for us then is say, at what point do we see a Bokeh blur, what shape does it become and how big should those pieces be. I'll try it out and see if we notice any difference. At the moment there is not much of a difference and this is because I don't have many round things in here which twinkling highlights.

It is also day light. So I'm not getting any really hidden lights in places. What would be great for a Bokeh blur is if it was near dusk, and there was a sparking fountain in the background, or something similar. Something with little points of light that could bloom into those shapes. So I'll turn off the Bokeh blur, and let my depth of field go, just background only. Now I'll turn off this depth of field, and put on the other depth of field for scatter. I'll drag it in. And now I've got slightly different parameters. First, we've got a focal distance and a focal size.

Then there's a focus on a distinct transform. If we want to keep one object in focus. And finally an aperture. The lower the aperture the blurrier things get. We have a de-focus type depending on what kind of blur we'd like. Both disk blur and DirectX 11 if you're supporting it. And then a sample count and a max blur distance. I'll try this out and see how it looks at the default settings before I adjust it. This is a pretty nice looking blur. Although it's a little blurry on the emmas. They do come in to focus decently when I'm close but it's a little too much blur, as we saw before.

What I'll do is take that focal size up I'll put at four so I'm dealing in a good range and focus and then lower down the aperture to eight. I'll press Play again and now I've got most everything clear and just a little bit of blur in the background. I like the way it's looking although the emmas up close are still very blurred. We actually need to back off to see them in focus. It's up to you, which way you'd like to handle it. Personally, I would like to have this game be about a close focus, because right now, close-up on the art, we're losing the detail in the texture that we should probably see.

So I'd like to use the other depth of field and push that focus back. So it's really a background blur, more than an obscuring blur in the foreground. As with any effect, it's up to you which one you'd like to lose. And you need to pick the one that really enhances the look, feel, mood and immersion‎ of your game. How should the viewer feel when they see this space. Visualize then, for us, enables visualization when we play our game. We'll actually see, what's close and what's far.

And, in this case, we're seeing where that depth of field sits. It's very, very close, and we're seeing what's only in focus. Degenerating into blur very quickly. As we start to push those focal distances around, we'll see that turn into more of a grey scale. And it's a tool for visualizing how far out the blur is, and how subtle it's getting. I'm going to remove this component. And turn back on the depth of field 3.4. I'm ready to add on some final polish. I've got depth of field on, sun shafts, and screens base seclusion.

Things that are naturally occurring and really help bring out the look. Now I can think about unifying the look of my entire scene with some color correction and a little bit of motion blur.

There are currently no FAQs about Unity 4.3 Essential Training.

Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Unity 4.3 Essential Training.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.