Level Modeling Basics

Hey, I figured I would like to make a tutorial about modeling “modular” video game level pieces with Blender for unity. This rather lengthy tutorial will cover modeling, texturing, and finally importing to unity.

This tutorial will assume a few things: You have the latest version of blender with a basic understanding of how to use it. If you’ve never touched it before, I recommend taking a few tutorials aimed at teaching you the software, as that is beyond the scope of this tutorial. You will also need an image manipulation tool like Photoshop or The Gimp. Obviously, we will be putting it all together in Unity 4.x (free version or greater).

Today, I need to make a tunnel section for one of my levels. This tunnel will be straight, and relatively narrow. It should be made out of dirty concrete. I know I will need source textures of concrete for this model.


First, we start with a plane. For most models, starting with a cube is best, but for our purposes a plane will suffice. This will serve as the floor.


Because I’ve decided to use 1 unit (blender/unity unit) as one real-world meter, we need to size our model accordingly. The player in my game is nearly 2 meters tall so I want my tunnel to be about twice that. I decided on a tunnel piece that is 4x4x4 in dimensions. It is small enough for more modular tunnel designs. Using the extrude (e) tool in blender, I pulled out walls. I topped it off with a ceiling by making a face between the top wall edges. It is highly important that you make sure the “connection points” are snapped exactly to the unit grid, otherwise things will get very frustrating while you’re trying to put your level together in Unity.


Adding more topology, I then pitched the ceiling a little and beveled the edges of the wall for a nicer look. Be careful not to add too many vertices to keep in-game performance at its best. Usually, the goal should be to use as little vertices as you can get away with while still retaining the detail you need. My tunnel segment ended up with about 16 vertices total and 8 total faces.


Next, we need to make sure our normals are pointing in the right direction. Normals are the term for the direction of the face. We want our faces pointing so that the player can see them from inside the tunnel. To check them, there are a number of ways, but my favorite is to set the view to textured. On an untextured model, the faces show up as white. It may take a moment to get oriented with what direction they are facing. If your normals are not correct, use the “recalculate normals” key (ctrl+n), or manually flip the normals on each incorrect face if that doesn’t work right.

Now we need to prepare a texture for our model. Normally, I would sift through my texture library to find one, or even take my digital camera out and photograph a real concrete wall that suited my needs. Since it’s the middle of winter and I’m not going outside, I decided to source a good concrete wall from a decent free textures website, cgtextures.com. I loaded my texture into photoshop.


It may take some adjusting to get everything straight and level. We need to crop this image to a more usable area.


I selected a good portion of the texture. When selecting your area, make sure the selection is perfectly square. This can be done by holding shift while dragging the selection box.


The texture also needed to be scaled to the nearest power of 4 so the texture is graphics-card friendly. Since my cropped area was about 1700×1700 pixels, I dropped to 1024×1024. Scaling up might lead to ugly artifacts, so it’s safer to scale down. Other powers of 4 that are common for game textures are 2048×2048, 512×512, and 256×256. It can also be rectangular, as long as at least one of the dimensions is a power of 4. Choose whatever suits your needs but keep in mind: smaller textures on a larger model can look like garbage.


Next, we need to make the texture tileable. This means it can be repeated in a pattern with no visible seams. To do this, a shortcut in photoshop is to use the Offset tool. (In the gimp, we can use the Make Seamless tool which might simplify this process tenfold) Our texture only needs to repeat along the x-axis, so we offset it by half the size of the image (the image is 1024, so half is 512). You should be able to see the seam in the middle. Our job is to eliminate that seam.


You have many tools at your disposal in photoshop. One of my good friends is the Patch tool. Select an area around the seam, then drag the source area somewhere so that photoshop will calculate how to “patch” the area. It can take experimentation to get good results.


You should be working towards a seamless texture. Personally, I would remove the dark stain on the left half because it is a rather unique feature and would be easily noticed in a repeating pattern.


This step is optional. If your game/level has a particular color scheme (it should), it might be useful to match the colors of your texture to that scheme if they don’t already. Here is a sample scheme I put together for my tunnel levels. Look up Color Scripts and other color theory on the internet, they should give you good ideas about how to compile a scheme.


Making sure your color scheme file is open in photoshop along side your texture, use the Image>Adjustments>Match Color tool. Set the source to your scheme. It may produce some unwanted results. Tweak the options, or even revisit the color scheme file to adjust it to your liking. Once your texture fits into your color scheme, we can move on.

Save your texture to your game’s assets folder, and make sure Unity loads it in properly.


Also optional: Creating a Normal Map (a separate texture that defines how “bumpy” it looks in Unity). There are plugins for Photoshop and the Gimp you can search for and install. I am using the Nvidia normal map plugin for Photoshop. This tutorial won’t go over how to make a nice normal map, but there are plenty of articles around that explain it in great detail. As a best practice, I name normal map files the same as the base texture, but with _n appended. (example “Concrete04.png” and “Concrete04_n.png”). I picked up this practice when making custom mods for The Elder Scrolls: Oblivion, as that was their texture naming convention.


Back to Blender: We need to start UV mapping our model. It makes it easier to unwrap the faces if we mark some edges as seams. Using the Mark Seam command (ctrl+e, find Mark Seam) makes selected edges into seams. Seam edges are red. It helps to imagine the UV map as a template for one of those paper figures. Seams are areas where the figure is “cut”. I marked seams on the bottom corners. Marking as Sharp (blue edges) seems to act as a “fold” in our paper model analogy.


I also added a new edge on the top middle, and marked that as a seam too. This means I can have the texture properly fit on each side.


Before we can texture, we need to set up our material. My best practice is to name the material after the texture’s name so it’s easier to keep organized in Unity. It’s fine to stick with the default material settings Blender gives you.


We also need to assign the texture to the material. On the texture window, add a new texture (name it too), and set the type to “Image or Movie”. Load in the texture you just created.


Make sure to have one of your panels in blender as a UV/Image editor. Select all your faces and apply the texture to them by clicking the texture list in the UV editor. For now, our texture is applied, but not correctly. We need to unwrap the faces of the model so we can align the texture.


There are many methods to unwrapping UVs from faces. An in depth look at UV unwrapping is out of the scope of this tutorial. Because we marked seams, the default Unwrap function should work with only minimal adjustments. You will probably have to move, scale, and rotate your UVs in the UV editor until they fit the texture appropriately. You may also have to unwrap faces individually to suit your needs. UV mapping can be extremely complicated.


Once you have mapped your faces to the texture properly, we can export it to unity.1_3_13_modeling22

Make sure you named your object in Blender so that you don’t end up with like 26 different “plane” objects in your game assets folder. It helps you stay organized and is all around a best practice for any 3D modeling workflow. I tend to name an object as soon as I create it.

Use the .fbx Exporter for blender and export your entire model to the game’s assets. You may need to install a better version of the plugin if unity has trouble importing your .fbx files. If you are having problems with the exporter, look up a tutorial on fbx files from blender to Unity for more information. Blender versions change and may break exporter plugins, so make sure you have the appropriate exporter for your version. You may also need to make sure Python is installed correctly too.

Now on to Unity3D:


By default, Unity imports .fbx files with a few weird settings. Change the scale factor to 1 (if you so desire), and the Normals to “calculate”. Leaving the normals to Import will make the shading look unusual on your model. Apply your changes. I also like to go to the Animations tab and turn off importing animations (unless your model animates).


Importing the file should have automatically created your material as well. If all the files are in the right place, it should auto-locate your texture. The texture does need to be in your game’s assets before this will work right. If you created a normal map to go with your texture, set your material type to Bumped Diffuse ( you can use Bumped Diffuse Specular for shiny materials). Load your normal map to the material. It may require you to “fix” your normalmap texture so it renders properly.


If everything goes right, you should have a nice modular piece to put levels together with. Most levels are made with dozens of different modular pieces. It’s handy to open Snap Settings from the edit window to snap your object to the grid, and then move it while holding CTRL to keep it snapped. Depending on your needs and complexity, you may use a mesh collider or a box collider. Box colliders are faster, but usually require more than one. Mesh colliders are more precise, but can cause problems. Unity mesh colliders don’t collide with each other unless the mesh is marked Convex. If your objects are falling through the floor, it may be due to mesh colliders not responding to each other.


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