Thursday, September 19, 2013

Pre-Update "Under The Hood" Blog Entry

Pre-Update Blog: Thursday September 19, 2013

Contributing writers: DeathSheepfromBelow, Petalstorm, Robin, and VDG

Hey everyone, I know you’re all waiting on the edges of your seats for some KS info - and that’s coming Soon™. What I want to show you guys is a quick and dirty “under the hood” look at what we’re working on, using very specific example.

A week ago some of you may have seen an image teased on Facebook of a potential - and let me stress that - potential - City Hall model. Until we have final tools for asset creation, everything has gone, and will continue to go through, multiple iterations until a final look is settled on. This blog is about one of the City Hall concepts that was generated by our team of artists (2D and 3D) and tested in the Unreal engine.

Front view in Sketchup
Front view in Sketchup
Why go through the effort of making a mock-up of a concept and then importing it into the engine? Many reasons - one of the most important ones is to give an idea of scale and how it might look inside the engine from the perspective of the player. It can also influence some necessary changes that wouldn’t be apparent on just pen and paper or in a 3D modelling application.

After the initial concept sketch was done on pen and paper, the sketch was brought to life in Sketchup, a very popular architectural and 3D modelling tool.

Currently we are using Blender and Sketchup as our tools. Sketchup is an awesome tool for beginners and it great for architectural modeling - the video game Uncharted even made use of it (

Sketchup Design
One of the concept models, as viewed in
Blender is a power open source 3D modelling tool that is capable of beautiful renders (I’m obsessed with their Cycles renderer,) cloth and fluid simulations, animation, video editing, sculpting, and so much more. However, it is has an extremely steep learning curve, unlike Sketchup.

So here comes the fun part: how to get this model from Sketchup to Unreal. As it so happens, much like image files, there’s no one universal file “type” for 3D models - there’s a considerable variety. Some save just the basics - the shape of the model and how everything is connected. Some file types save everything - from materials, to morphs, to animations, to particle effects. Sketchup happens to only export the most basic file type - simply known as OBJ. The Unreal Engine, however, only accepts model types with the FBX extension, which is currently a proprietary format for the Autodesk suite of tools (like Maya.)

So, how do we get from Sketchup to Unreal? Well, we have to use a program that sort of acts like a “converter” - that’s where Blender comes in. Blender can fortunately export to the FBX file format, although it is not perfect and can be a bit buggy. So we import the OBJ file into Blender, do some quick checks to make sure everything is still connected, and then export to the FBX format with the correct options selected.

And this is what imports into the Unreal engine:

View of the original mesh in Unreal
The model imported into the Unreal Editor.
Not what we modeled. Not at all.

Second view in UDK
Doesn't look better on this angle either.

To summarize, this took some time to fix, and it took some good people. There are some very complicated parts as to what occurred here and why this building could function as Grade A Architectural Nightmare Fuel, but I’ll cover the most basic thing that went wrong in the process.

3D models are comprised of vertices, edges, and faces. The vertices are essentially points plotted on X, Y, Z coordinates. Edges define how vertices are connected to each other. Faces define the “area” that fill an area between vertices and edges and will ultimately display the texture applied to the model. Every face has what is called a “normal” which defines the direction the face is pointing.

Inside/Outside view in UDK
A view of the model from the outside and inside
In Blender and Sketchup you can see a face from both sides since both of those programs consider a face to have two sides. However, this can actually become a memory hog for your computer. In almost every single video game engine, a face is only considered to have one direction.  If you look at the side of the face that is in the opposite direction of the normal, what will happen is you’ll simply see right through the face as if it wasn’t there.

Why did this make our model look like a bonafide freak show in Unreal? Since normals don’t matter in Sketchup the program doesn’t bother to set them correctly. When we imported it into Blender it couldn’t tell where the inside or outside of the model was based on the data stored and imported from the OBJ file, and that carried through into the FBX file.

Normals correction
Before and after of fixing the direction of
the normals on a face.
What we had to do was manually correct each and every single aberrant face on the model in order to get it display correctly in Unreal.  This means making sure the normals are pointing outwards from the model, rather than inwards. This was an incredibly time-consuming task because this model has over fourteen thousand faces (that’s actually low for a 3D model.)

Periodically, we had to test-import the model as we fixed these normals. This helped us to find areas we may have missed due to some of the faces being incredibly small ( and due to the fact that, after staring at the same thing for hours on end, you tend to start missing things ).

And this, below, is our final result in Unreal.

View of final mesh in Unreal
View from the front

Second view of final mesh in UDK
Yes, this is what we had modeled.

This isn’t to knock Sketchup and Blender - they’re both incredible tools (and free!) but they have some serious limitations when it comes to using them with other programs (especially Unreal.)

As I mentioned earlier, FBX is a proprietary format, but it is also the preferred format for importing into Unreal. Right now Blender only speaks an outdated version of it, but more importantly, it simply doesn’t do nearly as well with game assets as the proprietary tools do. Thirteen hours using free tools, against roughly three hours using a trial version of the alternative. For a relatively simple, low-poly mesh building. Multiply that by somewhere between “several dozen” and “a few hundred”, for just the building exteriors. That doesn’t count the time spent on the learning curve.

Well that’s it for this blog. If you have any questions, comments, concerns, then join the discussion on our forums (!