I thought it was about time that I posted another Tutorial, this time taking the artistic side I have decided to put together a simple tutorial on Texturing a Box.
I plan on going through the process of Drawing a simple box, Adding the UV Map and Breaking it up, then extracting the UVMap and using Photoshop to create a texture for it.
Drawing the Model
The first step is to open up blender and clear out the default model, we could just use what is there but I thought I would start with nothing...
So open Blender and press 'x' to remove all objects from the scene, this should leave you with a blank canvas, next press the 'space bar' and add a cube mesh to the scene. As we are going to just be texturing this object you will not need to worry about the different view ports, so for now press the '0' key on the number pad to view the object from the default camera.
Setting up the Viewports
Next you will need to Split the Viewports so that we can display the UV Editor for Blender, to do this move you mouse over the header between the two main Viewports and when the pointer changes to a double arrow right click.
This will bring up the 'Split Areas' option, from here split the area in a vertical manner so that you now have two versions of the main viewport.
In the header on the right hand side window you will see a small hashed button as seen in the picture below.
This will allow you to select a new window for the view port, select this button and select the 'UV/Image Editor' window, you display should look like the screen below.
Creating the UVMap
Now we start to lay out the UVMap, to do this move your mouse into the left Viewport and with the scroll wheel on the mouse zoom in on the cube. You should have the complete object selected, press 'Tab' to go into edit mode and the cube should highlight with a pink shade.
If you press 'a' now the object will be unselected and we can start to break apart the object to make texturing it easier.
On the Header for the Left viewport you will see a small group of icons,
Select the diagonal line like above, this is the edge select mode. Now what we are going to do now is add some seams to the model so that when we extract the UVMap we will have a nice layout that we can add a texture to. To mark the seams you need to have the edge selected and then press the 'Control and E' key on the keyboard.
Select the edges by moving your mouse to the edge, and holding down the shift key right click on the edge. In the image below you can see the edges that I have selected. Not that you must have shift held down to select the multiple edges.
Now by pressing the 'Control and E' keys you can mark those edges as seams in the UVMap.
You will notice that Blender will highlight the seams in a different colour so that you know which are marked.
Now we need to select the complete model we can do this by pressing the 'B' key on the keyboard and box selecting the complete image. This will highlight the model again.
At this point we need to unwrap the model, to do this press the 'U' key on the keyboard and select 'Unwrap', You should now see in the right window the unwrapped model layout out ready for texturing.
The last stage we need to do at this point is to extract a flat file that we can open in a 2d image editor of choice to design the texture.
To do this on the right viewport select the 'UV' menu and go to scripts then 'Save UV Face Layout'.
This will give you an option to save the layout as a tga file. Save the file to an easy to get to location.
Normally when I am working on a Model I will create a directory and in that save the .blend file as well as any textures and such relating to that file, this includes the exported images for my XNA Applications.
Designing the Texture
Moving onto Photoshop we will now load up the map and start a basic texture, now this article's purpose is not the actual artwork but more the process so the texture is not going to be that great.
For my artwork I use Photoshop, but this process should work with most of the 2d imaging applications out there.
Load up the UVMap texture into Photoshop, when done the image should only have the one layer, start by adding another layer to the image. This will allow us to use the image map as a template and edit the actual texture on the new layer.
Zoom in on the image so that you have a full square viable in the viewport, then using the rectangle select tool select the viable square. When blender exports the image you will see that it puts red dots on the UV map where there are vertexes, this will also make it easier to select the square you want.
Now with a colour of your choice use the fill tool and fill in the selected area. Do this with all of the squares for the texture. For the purpose of this example make sure you use different colours so you can see how it looks on the model.
To save some time I have gone ahead and coloured each of the squares.
In Photoshop hide the layer that hold the exported texture and save the new texture to disk, making sure you do not overwrite the exported texture map. I normally use the png file format for my exported textures. Once done swap back to the Blender Application.
Inside the blender Application go to the right side viewport and select Image and then open. From there browse to your textures image and load it up.
You should now have a nice image in the background of you UVMap viewport.
Now we need to apply it to the Model.
Applying the Texture to the Model
We need to now enter the material editor in Blender. In the blender application this is called the Shading Menu, Press 'F5' and the buttons on the bottom section will change.
Select Add New, this will create the default material for your model, next press 'F6' to add the texture.
You will see a Texture type drop down as shown below, select Image.
The menu will change to be like the below image.
Select Load from the far right hand panel, and select your texture and swap bake to the materials section by pressing 'F5'
On the far right you will see a menu tab 'Map Input' Change it so that it looks like the following.
Now if you press 'F12' and do a render of the scene you will see that our cube has now been textured.
Save you image and scene and you are right to go. When doing this process you're able to put as many seams as you like, for some more detailed models this would allow you to put allot of the objects on the one texture file, and save load up times.
For those following this article for XNA Game programming you will now be able to export this model out and use it in your games. Note that you will need to make sure that all of the textures are named correctly as well as located in the correct locations for them to work. If you are using the FBX Exporter that is shipped with Blender you will need to change the location of the textures inside you fbx file before building your application. But I do plan on writing that one up next.