Okay people, I promised that I'd continue my tutorial on the subject of getting a blender made model into UDK.
By now, if you all followed your homework, you should have handy an item you would like to have inside of UDk, If not spends some more time building some thing awesome or using our new grid setting make a default cube. which should be a 32x32x32 cube rather then an 2x2x2 Cube.
First, a few notes:
I was wrong about the Unreal unit being 2.5 Centimeters, it's actually smaller then that. it 2 Centimeters flat.
when making a model for the Unreal engine, it's impotent to Lay out your UVs. If you don't UDK will crass when you try to import and may corrupt you package file you wish to save into.
While your at it, might as well apply materials to your model and bake and save out a 2048x2048 Targa texture for use when you get the model in game. once you have a Texture you really like, or can at least work with as a base, save everything.
Lastly, Convert everything into TRIs. STEP #03 - Prepping Your Model
I have a model i want to bring into the game. It's a sort of and open air lift cage with railing on the sides and a sort of spool at the top.
This model as you can see is 3352 faces and that actually a little on the low side when compared to Epics own static meshes.
as you can see there are no textures applied to this mesh just yet. There is not even a material set to this at all.
since I have UV already mapped out on this I quickly applied a number of materials and a few base texture I had laying around and baked myself a single image texture.
At a resolution of 2048x2048 which is fairly normal in the world of Unreal.
After removing all by one Material i replaced the Image with the newly baked targa and presto, all the ingredients needed for Static Mesh prop in UDK.
I can not stress enough the importance of laying out your UVs. They are a must in almost ever single game engine ever made ever. EVER! so don't over look this step.
A word to the wise, Unless it's a character model or something fairly organic in nature. Don't must use the UV Unwrap for this step. The LSMC Algorithm is not really meant to do manufactured items like boxes or the like. There is a algorithm that is not used in blender that is meant to handle stuff like this, but it's seems this is not an option in blender in favor for just the one and inherently hardly ever useful to me LSMC Unwrap.
Also take your time this isn't a race.STEP #04 - Exporting Your Model From Blender
Now my model is ready to export into into UDK. I make sure that all of this is a single object, and that it is named. I'm calling this one Prop_testLife01 and my Texture is save under my User\Pictures folder as Tex_testLift01_d.tga
Please note that the material and the material name doesn't really matter, it really just a place holder for the UDK own material system. So don't tweak the materials out and expect to see those changes in Unreal. that just not going to happen.
Now I will go navigate to my export menu under the files tab on the top bar.
which should make one of you View areas look like this...
And after choosing a spot to park the ASE File that will result from this. Another small panel should pop up on the screen some where that will look like this.
If all goes well, you will now have an ASE copy of your model right where you told it to be saved. For me that in the Documents folder on my C:\ Drive under the Users area.
I can verify this was a good action by taking a look at the Console window that always opens with windows version of blender.
Now go track down your ASE file, and you texture and put them in one place. I put mine on the Desktop to make it easy to find for now...
using a Plug in for Photoshop (A plug-in for Gimp also exist) I made a normal map out of the texture and saved it out into it's own File on the desktop called Text_testLift01_n.tga
Please note the "_n" so I can see that this is the normal map and that "_d" means it a diffuse map.
With these 3 files I am now ready to close down blender and open up the UDK.
Please note that using the Unreal Level Editor or UnrealEd for short is way outside the scope of this tutorial. As i said before I assume you will have some basic understanding of UnrealEd before even trying this export/import method.
for those of you who already know how to use UnreaEd, Make you self a small little level. I'm going to make a subtractive level for this demonstration so that I can keep it fairly easy. and simple to look at. STEP #05 - Importing Your Model into UDK
so here I am in UnrealEd with my very simple level. it's really basic in fact. I have a single Light, A player start 4 walls, a ceiling and a floor. no frills other then the use of stock materials.
Unlike previous versions of Unreal, Unreal Engine 3 no longer excepts directly applying the Textures alone on anything. Textures must be placed into the Materials and the materials then must be used to act as the paint for the walls.
So lets make our Material for my lift first.
I'll do this by opening up my content browser and then going to the bottom left side and press import.
I have three things i want to import all at once and all into the same custom package. So lets do that now. we'll first import the Textures and then after those are made into a material, we'll import the model and apply the material to it.
first is will ask you to locate the file(s) you wish to import, Just navigate to your desktop, or where you are keeping you textures at, and select them both at the same time.
then a new dialogue will pop up asking for some information about where you want these and the like.
There are 3 fields at the very to that are the most important parts of this.
these three fields are:
- Package - what you want the new package to be named.
- Group - what sub-folder within the package you want to store these files at.
- Name - what do you want to call this file?
The file name in this case will be fine and dandy. however, I want these two texture to be stored in a group called Textures with in my package becasue i like to keep organized. and I want my package name to reflect the Static mesh that will be stored inside this Package.
Now a package can hold just about anything that the game needs to make a game. sound files, models, level, those cool little green army men, my mother in law when she at he most cranky. anything. not only that but it can hold a lot of stuff for use later.
but in this case, we're going to make this package with only one thing in mind.
Anyways. Your import windows should look somewhat like this.
On the upper right hand side. go ahead and hit "OK To all" and it will repeat that twice for both files, and presto.
both files are in the package we named and in a sub folder we created if you direct you attention to the middle left hand side of the screen.
but our package isn't saved yet. right now it's just a place holder in RAM. Save by mousing over the root level of your package, rightclicking and clicking onto the button called "Save" and just agreeing to what it ask you.
Basically where will it go? and it will tack on the .upk extension onto the end of it.
Now you package is save.
when ever you make changes to a package... always save it when you are done messing with it.
Also never ever, add any new content, or delete anything out of the stock packages that came with it. make your own, and use those packages for storage of you custom stuff. it's just much easier and safer to do it this way. Plus you can distribute these freely after your mod/game is made.
As it sits, we have textures in a package. But there is no way we can make use of these two images directly in the engine. We are just going to have to make a material that uses these textures.
In the big middle area where you see the Texture thumbnails, Right click any where in there to bring up a creation menu. find and choose from a rolling list, which I cant seem to get a screen shot of due to it's nature. and you are again presented with a widow we've seen before when we imported the textures.
I just typed in "Materials" for a group and as a name I used the Naming convention I've been using for years. I tacked on the "Mat_" in front of the item name so that I know that this is a material made out of both the Diffuse and and Normal Maps i had already imported.
now hit Okay at the upper right hand side. and presto you have a new blank material ready for your creepy manipulation. it also automatically opens up the Materials node editor...
GASP! that looks scary and hard.
Really that couldn't be further from the truth.
now I'm not going to go into all the details of how to use this, as i am 100% fully aware that I've given you some links that will explain this in more detail in the previous part of this tutorial. so I'm going to assume that you already know how to use this. see the 3D Buzz video tutorials under "MATERIALS" heading for more details.
what I'm going to do is actually head back over to the content browser, and select the Diffuse Image so that there is a yellow box around it, and making it the active item selected.
Once selected I'll jump back over to the Material Editor, and right click in the big node editing are in the middle Locate and choose the following.
Texture > New TextureSample
because I already had the intended Texture Selected when I did this, It made a new Texture Sample node and automatically applied my selected Image.
And this is what I get.
Now I'm going to repeat those last couple of steps and grab my Normal Map into it's own separate node. so that I get something that looks like this.
So moving right along, I need to make a few connections from my Texture Samples (On the Right) into my master node (On the Left) in order for anything to happen.
I'm sure all you blender heads, have some idea of the theory behind all this.
On the Master node, you can see a whole series of Black sockets with labels of what channels they receive on the Right side of it.
On our Texture sample you see much the same thing only no labels. what we are going to do is drag from the black box on the left of the Texture Samples, and put the wire that come out of this onto the proper channel of the master node.
Diffuse and Normals are our main concern. it really just drag and drop easy to do.
And really now our materials is done and ready to use. I can now close this Editor and save my package and get ready to import our model.
And here we go, our new material saved, and ready to go onto our model which we have yet to import.
Now using what I've already told you, Import the model using the same method you imported the textures.
doing this will bring up a windows asking what it is you want to import, use this to find you ASE version of your model.
Following the same steps as before, put this into the package we've been working with this whole time and in a group called "Meshes"
And if all goes well, You should now have a model in the content browser that looks like this.
If you Followed my recommendation and build the material first, then the model should have been imported with the Material already applied automatically.
If not, then you may have gotten a model that looks like this.
Don't panic! this is easy to fix.
we'll start by double clicking the Mesh file and opening up the editor for editing meshes...
this will present you with a screen that looks like this.
over to the right hand side you see a menu, Fully expand the "LODInfo" entry until you see an entry that says "materials" with a string Value of None. It will look like this.NOTE: a string value is anything that is plain text, numbers or letters. in this care None is what this value is. there is nothing then for it has a value of None.
Applying the texture is as easy as it was to get the Images into the material editor before. this time well be making the Material "Mat_testLift01" the active selection in the content browser and as soon as we return to the mesh editor we hit the green arrow button on the right hand side materials line of the menu.
what this will do is use what ever is selected in the content browser, and automatically fill in all the required information needed to make this work.
Be aware that this will only accept a material and not the texture itself. even if you just make a Diffuse and no normal map, you will still need to make a material out of that texture and apply the material. There is just no way around this fact. Trust me on this one, I know I tried... I failed... I got over it... I got use to it...
Once the material is referenced in that box. It will automatically apply it.
and now this is what it will look like.
wow we're really starting to come along here aren't we.
Okay now Direct you attention to the text in the upper left hand corner of the preview screen.
there is some data here I wold like to point out.
On the third line it says the following.
"UV Channels: 2
This is true. I didn't explain this before but there are in fact two UV Channels. and i make them both back in blender. the first channel is for laying out where the textures are sampled from in the material. the second i made by using "Unpack Lightmap" and setting it to make a new UV Channel just for this.
I mention this because it's recommended that you have a special channel just for the lightmap and avoid some funny looking shadowing artifacts on your mesh. these artifacts tend to show up clearly on the Tri Edges of a flat face and can really brake the effect.
Also while it usually works fine and dandy, for some reason, All that smoothing of the rails was lost and so I have visible faces on the railing. I not really sure what happened here but that is not typical, and was likely the result of something i did rather then the script, blender or UDK.
I just wanted to point this out.
Now that the Mesh is imported into UDK. Exit out of the Mesh editor, and save you package.
Congratulations, you now have a fully imported 3D mesh and Textures from Blender to the UDK. However our work is not finished...
First, if I was to jump into game right now to test this. it would fail to function as a platform I can get onto and ride. I would fall right trough the floor in fact.
this is because there is no collision mesh, or as some of us call it a Collision Cage, to keep us from walking right through this.
There are a number of ways to get around this.
First of all I'd like to stress that there is a way to automatically generate Collision Meshes with in the Mesh Editor in UDK. This is all well and good in many cases where we won't expect a player you be able to get inside of empty space and move around while being blocked from just walking off by the rails.
The general rule of thumb here is to keep you collision as simple as possible. Use as few of face as you can get away with while still keeping the Collision areas tight with the visible geometry as you can.
I'll goe into detail on this later but for now. play around with waht you have here and get a feel for how this works so far.
Happy Blending Guys...