Baking Ambient Occlusion

Hey all! You have probably seen my previous tutorial, introducing Ambient Occlusion. In this post, we are going further into it and learning how to bake (yes, bake) the AO right on the model as a texture. Baking is useful when you want that AO effect in things such as Video Games. So, let’s get started.

I have modeled a low-poly oven model in honor of this tutorial. You know, baking on not in an oven. 😛 So, I’ve turned on AO and quickly rendered it to show you what we’re looking at.

AO-Bake1

But, we’re not going to be using AO for this tutorial. No sir. We are keeping it off this time. 😉 We are going to use the Bake tool in Blender to simulate Ao. So let’s jump right in.

First, you’ll need a model, as you see above, I’ve make an oven. You can color it using Material Colors. Now visit Edit Mode. Select all (A) and press U for Unwrap. Don’t press Unwrap, though. Press Smart UV Project.

AO-Bake3

In the next box that comes up, change 0.06 so that nothing overlaps. Now, open your UV Editor Window. First, change your GUI mode to UV Editing.

AO-Bake4

Once you are in that GUI, you’ll need an image to Bake to. It does not matter what image you are using, the Bake process will replace the image anyway. So I just used a 1920 x 1920px blank (white) image I made in Paint.

NOTE: The larger you image is, the better quality your Baked AO will be.

So go down below the UV Editing Window and press Image>Open Image.

AO-Bake5

Open your image, check your UV (to see it it is there 😉 ) and you’re all set. Now to actually bake! Go to the corner and drag it to make a nifty little window. Now change the window type to Properties. Then, (in the Render Settings) scroll all the way down and open the Bake tab.

AO-Bake6

Change the Bake Type to Ambient Occlusion. set the Margin to 2.

AO-Bake7

Have your model in Edit Mode and press Bake! Baking might take a little while, though, so be patient. The larger the image, the longer the baking times.

OPTIONAL: If you go over the the World Settings, where you normally change the AO sample amount, you can tweak the settings without even having AO turned on. So, if you wanted a better quality Bake, change the Samples amount to a higher one. But higher samples will mean a longer Bake time.

Once it is finished, you’ll see an image pop up behind your UV Map. It is the bake result. Go down to Image>Save Image if you wish to save your Bake over the image you started with. If you’d rather Save a copy, press Save A Copy.

AO-Bake8

Now you can remove all the Material Colors and make a new Shadeless one and apply your newly-baked texture on it. There you go! Great shading without even needing any lights in the scene! 😀

Approximate Ambient Occlusion

If the Raytracing gather method does not work, or looks bad, I recommend that you use Approximate. The only thing wrong with Approximate is that it produces very dark shadows. To fix that, just light your scene better, for example, add a sun lamp and turn on Indirect Lighting (under the World Settings). That should usually help. When baking, the same concept is used. Baking is just taking what the scene looks like and putting it onto an image or Vertex Colors. Let’s do this step-by-step:

  • Set up your scene (which I have already done with my low-poly oven)
  • Turn on Approximate Ambient Occlusion.

approximate AO

    • Create a new image in the UV Image Editor Window, then go to the Render Settings and Bake (Bake Ambient Occlusion).
    • Once your model is finished, you should save your image, duplicate your model (Shift+D), delete all the materials, and make a new Shadeless material and apply your image to it. Render and see if it looks OK. If it does, good! You’re done! If not, keep going…
    • If your Ambient Occlusion bake is too dark or had very deep shadows, try turning on Indirect Lighting and adding 1 Sun Lamp.

darkness

lightness

  • As you can see, the first image is too dark, but the second image is brighter without dark shadows. I added 1 Sun Lamp and turned on Indirect Lighting. I also baked Full Render, not just Ambient Occlusion. This way, the Sun Lamp takes effect, and the Indirect Lighting takes effect.
  • The Full Render Bake also takes effect for anything, not just Ambient Occlusion. If you have multiple materials, textures, and a lighting setup, it will bake exactly what you see when you render. Also, you don’t have to turn on Ambient Occlusion or Environment Lighting, if you like what you see when you render it, you can bake it. 🙂 It will bake it all into 1 image, so make sure your image is large enough and your UV Maps are set up properly (everything is UV un-wrapped and nothing is overlapping).

If you have any questions, be sure to comment! 😀

Happy Blending–I mean Baking! 😛

-rioforce

Want to try this but don’t have a model to try it on? You can use my Oven! (Link Below). NOTE: On Layer 1 of the model is the original model (with Material Colors) and on Layer 2, is the Baked version of the model.

(See more on layers HERE)

”Download

Advertisements

15 thoughts on “Baking Ambient Occlusion

  1. I has a suggested could you make a scene, like a room, with minifigure in the a room for exampel and having other objects around them, like a screenshot, and post some screenshots of that.

    By the way just wonder how long would you think a scene would take to animated in Blender?

    • I don’t understand what you mean by the first sentence. Please explain. 🙂

      If you want to animate a scene of a movie, it is according to how long you want your movie to be.

      • I meant if you could make posts with screenshots while the minifigure is interacting with environment. Just for fun.

        Let us pretend the movie is five minutes long, how long would that take to animate and why?

        What is the hardest thing with animation in Bledner, and why?

  2. One thing to add to your tutorial if I might 😛 One way to save on textures should you want is to add vertex colors to your model, and then under bake use ‘Bake to Vertex Color’. Useful for games. Also the need to worry about texture sizing is eliminated (often doesn’t look quite as nice though, and you can encounter errors if not done correctly ;))

    • Oh, looks like you kind of covered it with your ‘Baking is just taking what the scene looks like and putting it onto an image or Vertex Colors.’ there… oh well 😛 Also, my comment is awaiting moderation?! Have I seriously never commented on this site before?! 😛

    • That’s true, I should have mentioned that, after all, I’ve written some shaders for Unity that use Vertex Colors! (Although, Vertex Colors cannot handle image textures. 😉 ). I’ll add it to the tutorial. 🙂

    • Lol, Windows 8 Email Noticifations. 😛 I didn’t mean that Vertex Shaers couldn’t because they can. I meant that if you had an Image Texture on your model, it will not bake well to Vertex Colors, because you’d have to have lots of vertices to bake a texture onto Vertex Colors…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s