Bake a Texture In Blender


All right in this video we’re going to show you how to bake a texture. Now, that this is specific to Blender and it works with a lot of different projects. In this instance what I’m doing is I’ve got a series of videos that show you how to take a drone scan or a 3d scan and process it through open source software and then end up with these 3d models, so go ahead and check the different links in the description for the whole list of videos. But in this video I’m just going to be showing you how to take a model with multiple textures applied to it and then bake it into just a single texture. And this is just used to optimize it for various reasons . Maybe you’re going to make it into a low poly mesh for a game or maybe you’re going to make it into a video render, or maybe you’re going to export it into an HTML file using Blend4Web. So there’s various things you can do with it but… This applies to any any Blender project overall. So this is not specific to what I’m just talking about. Go ahead and take a look at this. This is going to show you how to bake your texture. So what we have here is an .obj file output from OpenDroneMap. This is a 3d scan I did on a rock. I’ve trimmed it down but what I’m going to do is is go ahead and crop it a little more and then we’re going to bake the texture on it so instead of having all these different textures applied, you can see here these are the various materials that we have applied to this model. So what we’re going to do to simplify that is we’re going to trim it down to what we want and then do a texture bake so we have only one material with one texture file. So first I’m going to go into orthoscopic mode so what that means is you don’t see things get smaller in the distance they stay lined up constantly. Then we hit NUM PAD 7 So now we’re looking down on it. I’m gonna hit TAB and go into edit mode. So I can see the top of the rock there so I can kind of zoom in if I need to see see it a little better. Hit B for box select and I make sure this is activated right here. What that allows me to do is select vertices behind the ones I see. Hit B again to select here and B again, select here. B again and then we hit X and delete the vertices. Okay there we go that gives you an example how to crop and trim down your model because when I first started there’s a lot of extraneous, ragged edges caused by the oblique camera angles catching things in the distance. So from here what we’re going to do is form a new UV map. We have a timeline down here so any window and Blender can become any other window so we’re going to turn this into the UV image editor. And we’re going to come over to our Data Object tab in the properties panel. Here’s the UV map that is currently applied. So you don’t get too confused with how materials work, the material is something that’s applied to the object and then the texture is something that is stacked on top of the material. So you can consider a stack. So back here in the in the Data Tab, make sure I’m calling that the right thing, Object Data, we’re going to create a new UV map. So we’ll just hit the Plus Sign and we’re going to name it rock-bake. I will name it rock-bake-1 in case we end up doing more of these and hit ENTER. And then down here in the image editor we’re going to create a new image. We’ll call it we’ll call it rock bake to (as well) or rock bake as well. And it’s better to make these POT images our power of two.
So 1024 is a power of 2 and so we’re going to double that if you wanted to make a smaller file for like a video game or something you want to go much smaller than this but we’re going to go with 2048 by 2048. Okay, so here is our new image that we’ve created now we’re going to come back up here into our 3D View, TAB into edit mode, A to select everything, U to unwrap and we’re going to select Smart UV Project. And then we’re going to accept the defaults and hit OK. And that’s a intensive process so give it a moment. We need to make sure we’re select on a rock-bake (another image got selected for some reason) Not sure what just happened, I’m not sure why it changed selection but we need to make sure we’re selected on our rock-bake image there otherwise it will cause a circular error in our in our bake. It will say that there’s a circular error in the image texture stack. So now at this point we’re going to go to the Rendering tab of the Properties Panel. And so from here we’re going to go ahead and bake it. Which is a rendering process. And make sure you’re in Blender Render for this. We’re going to look down on the bottom will see Bake, and a full render would take into account all the lighting and effects and we don’t want to do that. In fact we want to before I bake this I’m going to go ahead and save a version of it because this is sort of an intensive process and it’s not unusual I’ve seen crashes occur at this point. So I’m going to go ahead and File, Save As. I’m going to hit my increment button and save it as rock-3 and save. There we go now we’re ready to make sure, in our data panel, we’re selected on our new UV and then in our image we’ve got our selected our rock-bake that we’ve created. And down here, rather than full render, we’re going to do textures only. And then I’m going to TAB into Object mode so you can see what’s going on there. And we’re going to go ahead and hit Bake. And then you can see it creating the new pattern. And this is going to be all jumbled up. Don’t worry about that. What has happened is we have remapped the UV to match a texture that we have not yet applied. So once this is done the first thing we want to do is is go ahead and save it because this little asterisk you see by the image indicates that this image has not been saved. And you’ll see the percentage indicator up there is gone so we’re done so I’m going to go ahead and hit Save, Image. Save as image and we’ll save it as rock-bake.png. So now that image exists in our file structure, remember we can’t apply texture to an object the texture applies to the material the material applies to the object. So as it now stands all these textures are what have been applied so we’re going to make a new one. And we’ll just call this rock-bake. And with this selected, keep in mind whatever selected here, is what you’re going to be playing with when you go to this tab. So with that selected… Oh actually we need to apply this material to that object. And the way we do that is we TAB into edit mode. Make sure everything’s selected and hit Assign. Okay so now we’ve assigned our new material to our object. But we haven’t put a texture on that material yet. So let’s come over here and go into New, it’s Image or Movie already. And so we’re going to hit Open, go to our rock-bake.png that we have made. Open image. Now we have a single texture applied to our object in exactly the same pattern that all those textures were previously applied to it . So if you go to material we see that it’s just this one. So now I can I can take that material… Let’s just go to our World tab and I had previously applied Environmental Lighting to this to light all textures at once. And so let’s turn that off and we’ll go back to the Material tab and make this material shadeless. So it doesn’t respond to shadows or light. And then it just lights it up just according to how the lighting was on the day. Now you can use that environmental lighting to your advantage. Let’s say you fly a drone and make a 3D scan of an environment that’s dark on a cloudy day, you know sometimes you fly when it’s cloudy and is too dark. You can, instead of using shadeless, you can come to the World View and select that Environmental Lighting. And you can adjust that up and make a brighter day then what was really there. Or darker, same way. So you can use that to your advantage, but in our case the lighting was okay when we did this image. And so we’ll go ahead and make that shadeless. All right, that’s how you make a rock bake. So I’m going to go ahead and save as again. That is how you take the multiple textures that are output from OpenDroneMap and bake them all into a single texture. We can actually look at that and compare it to the others. Here’s the rock-bake.png that we created. So here’s the the new image map that we now have applied. And what was on there, if we look at texturing, it was a combination of these. And I think… I’m not sure if all of these apply. I think it was all of them or some of them applied to another object. Anyway, I think all these were applied. Plenty of them anyway. Lots of them. And so that way we’ve trimmed down our total model and we’re not utilizing that space, you know, for all t those faces and for all that mesh that we’re no longer using. We’re only doing a UV texture on on the faces that remain. And so in a future video I’m going to show you how to export this into HTML what we’ll be using is a an add-on called Blend4Web that’s that can export this into an HTML document in one step. So look in the description for that. Basically, once you install Blend4Web, you basically just hit File, Export, HTML. And then you have a fully self-contained HTML file with this model in it, viewable by anybody with a browser so look for that in the description and also expect, you know, OpenDroneMap is under heavy development and also I’m fairly new to it so expect updates and corrections. I’ll post those in the description as well so take a look at that.

4 thoughts on “Bake a Texture In Blender

  • Hi, excelent video, i have a question for you. Have you ever try to export an HTML of a big map (>300mb), as im trying to see my export in the HTML player, it doesnt respond, no logo loading or anything. Have you ever encountered this? Thanks!

  • Hi, your tutorial makes total sense and I think I am following it to a tee, but, for some reason when I click the Bake button it doesn't translate the original texture to the new image/uv map. It's just white. I notice that in your video (6:48) right before you hit bake, the original image is shown on the surface, though scrambled, and the UV/Image is black as per the newly created image. Mine does not do that. Both are black. I'm in Blender Render. I've created the new UV map in the data tab. What am I missing?

  • Brilliant. I spent two nights trying to solve this multi-material problem that can result from some 3D scanning apps. I scan simple objects for architectural rendering. The renderer I use (Thea Render) treats multiple materials as multiple objects, which is a pain when trying to share assets. Using your method, I finally got the model condensed to just one material/texture (after I deleted the other now obsolete material slots). However, and I found a fix, the old images and old materials (from the deleted material slots) were still linked into the .blend. So when I exported from Blender as .obj, all the old materials came back when I opened that .obj into my renderer. Bummer. The fix was to go back to Blender and Shift-Click on the X adjacent to the "Browse Material to be linked" dropdown underneath the material slot area. This doesn't actually make the old materials disappear from that list, but it sets the users to zeros and causes that data to NOT be saved in the .blend. I also did the same thing in the UV Image Editor for each of the old images (not sure this was required). I also deleted the old UV Map. Then I saved the .blend, and re-exported the .obj. Now just the one main material in my renderer! Awesome. Thank you for such a well presented tutorial.

  • Just decided to take the plunge and switch to Blender from Sketchup for creating X-Plane scenery. While I feel I'm at the point of understanding how it all works, or at least where everything is, I've turned to YouTubing videos for tutorials on each step I take. I must tell you, this is clearly the best I've come across yet. The pacing and tone of your voice, and the clear, to-the-point, step-by-step instructions are easy to follow. Thanks so much for creating this video.

Leave a Reply

Your email address will not be published. Required fields are marked *