July 7th, 2013
Creating Blender Meshes & Importing them into UDK
It has been a while since I posted but that doesn't mean I've been idle. There is so much to learn about blender and UDK that it is often intimidating to know where to begin. I have been focused on Blender, learning how to create meshes, simplify them and add texture to them.
I have learned a lot and I thought I'd jot down the important stuff that is a combination of information from a variety of sources.
If you are going to apply a texture to your mesh/object you need to view your object as textured solid from the start. I wasted an entire day building a complex object to find out that it was a mess when it came to applying the texture. What do I mean by this? Well, each face has 2 sides to it. One side is not textured and one side is textured. The is referred to as the face's Normal. When you add faces by hand (click 3+ vertexes and press f) blender doesn't know which side is textured. If you are not viewing the object as textured, you will end up with a lot of faces with the texture side facing the wrong way. If your object is complex, like a house/trailer, you can forget trying to fix it if you didn't start off viewing textures from the get-go
To view your object as textured, in your 3D View press CNTL-N to view the properties panel and select 'singletexture' for shading and check 'Textured Solid'.
Starting from a cube
For a project I am working on I needed to model a trailer. I watched some clever tutorials on building homes from floor layouts. They started with a plane that they extruded along the walls to build the house. Once complete they extruded the planes along the z axis. This was great except for one big problem: The faces on the extrude randomly faced inward and outward.
I recommend you don't start with a plane but with a cube. Blender then knows which way textures face because the cube starts out correct.
If you extrude cubes a lot, you are going to get a lot of vertexes, edges and planes. Reducing these as much as possible is important to improve render time. My goal with my trailer object was to eliminate all non essential vertexes/edges/faces to maximize performance. I have merged so many vertexes and created so many faces that it is second hand. I took it to an extreme however and when it came time to apply the texture to the faces, the face geometry was too big and complex and it made a mess out of things. In the end, I settled for smaller rectangles/squares when at all possible.
Example: even though the floor could be 1 rectangle, I chose to break it into about 20 rectangles so the texture could be unfolded for each rectangle.
So.. the rule of thumb is to not make faces of your model too large or your texture will look overly stretch. Break large faces into smaller faces to improve detail.
UV Map Texture
My goal with my object was to create one 1024x1024 image that contained all the textures I would need for my model. This required some planning. My image ended up containing 6 different images that I appropriately placed unwrapped faces onto:
I downloaded the images I needed from http://www.cgtextures.com. I then put them together into one image via photoshop. I knew the primary detail would be the white siding. The second largest detail would be the red siding. The remainder did not need as much detail. I may revisit this layout so that I can add curtains and other window details.
When you unwrap faces with a non-organic object like this, do it one face at a time. Blender does a much better job creating a face on the UV map you can work with.
For the trailer, I determined the largest face for each texture and based the size of the remaining faces mapped on the UV image from that. As you can see from the above image, you have complete control over the orientation, position and scale of the faces on the UV map.
Note: I heard that images for UDK must be a factor of 2 (ie: 128x128,256x256,1024x1024,etc). I am unsure if this is true but I wasn't taking any chances.
Here is an excellent tutorial on UV map editing:
Collision map for UDK
If you intend that your blender object lives in UDK, you will need a collision map. It shouldn't be anything fancy. For my trailer I create 1 cube that surrounded it. Here are the rules for collision objects:
1. You can have as many as you want
2. give each collisioin object the name UCX_* (* can be anything).
3. The collision objects do not need to touch each other
4. A collision object can not have any convex points
5. Keep it simple when at all possible
Exporting for UDK
When you have your object complete, export it to FBX format. This will not include your UV map texture but it will include your mapping of faces onto the UV map texture.
Importing into UDK
I don't know what it is about tutorial videos but no one seems to cover all the parts of importing into UDK in a clear step-by-step manner. I had to watch 4 different videos to understand everything I needed.
Here is what you need to do:
1. You need a Targa version of your UV map texture. You just need to save your image in photoshop as a targa. In the end I had a PSD (photoshop), JPG and TGA of my image.
2. Import the TGA as a texture in the content browser
3. right click in the content browser and add a new material
4. drag your TGA file into the material editor
5. connect black square on the texture to the 'diffuse' black square in the material and save the material:
6. import your FBX file
7. open the object and expand the LODInfo section until you get to Material entry
8. select your material from the content browser
9. click the green arrow on the Material section of the LODInfo on the object
And voila, you are done.
I must say, I am very impressed with the results in UDK. It looks really good and scales nicely. I am very excited about the project I am working on. In a few months I will post a link to it for the Oculus. It will be great. Really great.