Okay, so in a previous video I showed you how you could import Google Maps 3D data into Blender. And in this video I wanted to show you how you can take that 3D object and tidy up the mesh, tidy up the materials and tidy up the textures and the UV maps in order to make it more useful in your projects. So the first issue is that the 3D data comes in in lots of these little tiles and it would be nicer if it was joined together all as one object. So I'm going to go over here, select the collection, right click, go to select objects and that will select all of the objects in the collection. Then I'm going to press Ctrl J to join them together. So because of the way that these tiles are arranged there's going to be lots of overlapping vertices inside the mesh. So what I'm going to do is I'm going to press Tab to go into Edit Mode and then I'm going to right click, go to Merge Vertices and by distance. And you can see we've managed to remove about 300,000 vertices which is pretty good. If I go back into Object Mode you can see that the mesh is still pretty much intact. So now that we've joined all of our objects together we can go over to the Material tab. We can see here that we have basically hundreds of materials and each one flies to one of the original tiles that we had. And what I want to do is basically combine all these materials into one with a single texture and a single UV map. So first of all I'm going to duplicate the object. So with the object selected I'm going to press Shift D and then press Escape. And you can see in the Outliner here that we have two objects now. So I'm going to turn off the visibility of the first one and select the second one. And then we could go through and delete all of these materials one by one. But there's a quicker way to do this and that's using a script. So if we just pull this workspace into two and then change it to the Text Editor. And if I create a new text and then I'll put the code in the description you can just paste that into here. So here is the code and basically what this does is it takes the Active Object and goes through each material slot, which is the ease, and then just removes them. So if I go over to where it says Run Script and press this, we can see that all the materials have now been removed from the object. The plan is to take our original object here and use the colors and textures from that and bake them onto this new object here except that this new object will only have a single material and a single texture. So in order to do that, we need to take our blank object and we need to give it a new UV map. So with the object selected, I'm going to go over to my other workspace here and I'm going to change it to the UV Editor. And then I'm going to go back to this object. I'm going to press Tab to go into Edit Mode. And you can see that the existing UV map is very chaotic. It's just got hundreds and hundreds of vertices all mapped on top of each other. So what we're going to do is we're going to create a new unwrapping, a new UV map for this object. Okay, so the gold standard here will be to go over to the mesh, press U to unwrap UVs and go to Smart UV Project. However, before doing this, I would advise you to save your file because it can take a very long time to unwrap. This mesh here, which is about 100,000 vertices, took about 15 minutes. So with all the vertices selected, press U, go to Smart UV Project, press OK and go and make yourself a cup of coffee or something because it's probably going to take a while. But once it's done, you should have a nice UV map like this where all of the islands are separated. So if you can't afford to gamble with time, there's a quicker way to do this, which gives you slightly inferior results, but is still a pretty good way to unwrap the model. So to do that, we need to export this object as an OBJ and then bring it into a free software called MeshLab. Link in the description. So I'm going to press Tab to go into Object Mode, then I'm going to go to File, Export, OBJ and make sure that selection only is selected. And then I'm going to save the file to a location that's convenient. Then I'm going to go over to MeshLab and I'm going to go to File, Import Mesh. Then I'm going to choose the mesh that I just exported and you should see it appear in the Viewport here. You can click to navigate. And then with the mesh selected here, I'm going to go to Filters, Texture and Parameterisation, Trivial per Triangle. I'm going to set the Texture Dimension in pixels to 8192 and I'm going to leave the Intertriangle border at two pixels. I'm going to press Apply and it should do it pretty quickly. And then if I go to Render and show UV Text Param, you should see this little overlay pop up, which has all of the triangles neatly laid out into a big grid. And so now we can export this back to the OBJ and then put it back into Blender. So with it selected again, I'm going to go to File, Export Mesh, and I'm just going to disable Normal and Face Color and leave Texture coordinates enabled. Press OK, and that will save it back to the OBJ if all that we just created. So now we can go back to Blender. And in Blender, I'm going to delete the Duplicated Object. I'm going to go to File, Import, OBJ, then I'm going to select the OBJ again and press Import. And now if I select the Object, press Tab, we can see that we've got that nice gridded UV map that we took from Mesh Lab. So now we're ready to bake the Texture from the original object, this one, onto the new object, this one. And in order to do that, we need to make sure that the new object has got the material. So with the new object selected, I'm going to go over to the Shader Editor. And if it doesn't already have one, you can press Add New here. And it will create a default shader with the principal PSDF. And I'm going to add a new node into this. So I'm going to press Shift A to search. And then I'm going to search for Image Texture and add that node. And I'm going to create a new image. So I'm going to click Add New. And I'm going to set the resolution to 8192 pixels. Now here you can use the 41986 pixel texture or 2048. It really depends how much quality you need for your final result. And higher resolutions will give you better quality, but we'll take longer to process. And I found that with these Google Maps meshes 8000 works the best. I'm going to set the background as black with Alpha set to zero. So it's transparent. And then I'm going to press OK. And I'm not going to link it up to the node tree just yet because it needs to be disconnected for baking. So now we're ready to set our bake settings. And in order to do that, I'm going to go over to the Render Properties panel. And I'm going to make sure that I've changed my Render Engine to cycles. So whilst making this tutorial, one thing I tried was setting the device to GPU. And I found that it produced glitchy results. So if you're having trouble with glitches, I'd recommend keeping this set to CPU. And then I'm going to go down to the bake section. And under bake type, I'm going to choose diffuse because we only want the color. And I'm going to disable direct. And I'm going to disable indirect. I'm going to select this option here, selected to active. Because we're going to do a selective to active bake in the settings under that. I'm going to choose a ray distance of 0.1. And that's going to very slightly offset the new mesh away from the existing one so that the color rays can be transferred on the inside. And in this section here where it says output, I'm going to change the margin to 1 pixel. So now we're pretty much ready to bake. Baking can take a long time. So at this point, it's a good idea to save your file. And so with this new image texture selected, I'm going to turn on my existing mesh. I'm going to select it. And then holding down control, I'm going to select my new mesh. And we're ready to press bake. And again here, depending on your computer, this may take a long time. But this time, at least we have progress bar. So now that the baking is finished, we can connect the color output to the principal BSDF in the shader editor. And if I then turn off the visibility for my original object, we can see that the texture that we baked is now being mapped onto our geometry. So we successfully transferred it. You might find that this specular value is turned up. And the principal BSDF, so you might want to turn that down. And the other thing that you'll want to do is save the image that was generated. So here I'm just going to rename the image quickly. I'm going to call it bait texture. Then I'm going to go over to the image editor. I'm going to select bait texture from the drop down menu. There it is. And I'm just going to go to image save as. And then I'm just going to save it in a location that's useful for me. I'm going to use a PNG. That's good if you want to preserve the transparency. But you can also use a JPEG. And that's basically how you clean up a mesh that's been imported from Google Maps 3D. Thank you very much for watching.