Monday, 2 January 2012

UDK vs CryEngine 3 SDK: Whiteboxing

Today 's post is focussed on the whiteboxing tools available in UnrealEd and Sandbox. And I've just realised I haven't written a glossary entry about whiteboxing, so I'll quickly explain what it is. Whiteboxing is the process of producing a very crude version of the level's layout. It focuses on the playable space and its purpose is to evaluate things like scale, navigability and timings. 

Why should I care?

As an evaluation tool, a whitebox level will be modified many times, and sometimes started over from scratch. This is why whitebox geometry must be cheap to produce and easy to modify, so people (especially artists) don't feel like their time is wasted. Ideally, the whiteboxing tool would be simple enough so you don't actually need modelling skills to create those basic shapes, allowing level designers to completely own that stage. That's why the tools must be easy to use and their result easy to modify.


In UDK

Maybe one of Unreal's most famous features, UnrealEd's whiteboxing tool is called BSP, for Binary Space Partitioning, even though what we're actually doing is CSG. Note that BSP can also stand for bespoke geometry.
The basic idea is to define shapes and tell each shape if it's adding "matter" or removing (subtracting) it. Then, those shapes are applied in a certain order to create the actual geometry. Those shapes are called brushes. This way, you can quickly create solid objects and cut holes in them to create rooms, door frames, windows, cars, etc. This way, you can generate in a few hours things like this:



You can apply a material on each face of the created brushes, in order to colour code the level, or simply making it more navigable (although whitebox, as the name suggests, is supposed to be a textureless world, things tend to get confusing when floors, walls and ceilings are all the same).

Brushes are created using something called the builder brush (let's say it's a preview of the brush you're about to create). Several starting shapes are available, the most useful being: cube, cone, cylinder, and 3 types of stairs. For each of these, you can define a few settings (such as dimensions) that will further define the shape of the brush. You can also do CSG operations on the brushes. If you need to make even more detailed modifications, then you've got the geometry mode, which will allow you to modify the brush pretty much the same way you would modify a mesh in a modelling package.


The important bit about BSP in Unreal is that it's not exactly WYSIWYG. While the addition of new brushes can be seen in real time, you need to rebuild geometry (a one-click operation) in order to see in the 3D view any modifications to the geometry. Because yes, most if not all of the BSP work is usually done in the 2D views (because of that rebuild thing, and because of "sticking to the grid" considerations). The rebuild time usually isn't very long but be aware that it invalidates static lighting. Here's an example of a map made from BSP viewed from the top (it's a slightly different version of the map you can see in the first two pictures).

Blue shapes are solids, yellowish ones are subtracting matter from the solids.
In CryEngine 3 SDK

The CryEngine also has the ability to create geometry from within the editor. It's called solids. Basically, it lets you create meshes with per polygon collision. Within two hours, I managed to make something vaguely resembling a mansion courtyard (let me remind you that I'm not an artist):

Not really impressive nor detailed, but I didn't plan anything and it was my first time using the tool.
UPDATE: There's a very nice feature which I thought was general but is actually specific to solids. When you select a solid, its dimensions are displayed, which is obviously very useful when blocking out a level.


It is possible to edit those meshes pretty the much the same way as you would in 3D package (with a much more limited tool set of course), and it actually does look very much like 3DS Max.



And actually, it's looking too much like 3DS Max. The thing is, each solid object is considered as a single mesh (i.e. a bunch of vertices arranged in a certain way). This means a few things:
  • If you want to apply different textures on different faces of the solid (e.g. the inside and outside of a wall), you need to assign Material IDs to those faces and use a specific material.
  • When you edit the solid, you may need to move more vertices than you'd think necessary, in order not to break the topology. Meaning you'll start needing modelling skills.
You can do CSG, but the ultimate goal is always to alter ONE solid. You can't cut a hole through two solids at the same time. Also, the really annoying thing is that doing a CSG operation only leaves you with the result, meaning you always need to store a backup of the shape you want to carve if you need repeat it somewhere. This also means that you have to be pretty confident about what you're doing, because the next time you'll want to modify a cut-out, it might not be so easy.

Why? Because the resulting mesh topology after a CSG operation is bad. Very bad. It's even worse than what Sketchup produces. Let's have a look at my arches:


"Shit, the ceiling is too low! Oh well, I can just push it up a bit."

WTF? Looks like it's been sliced by an hyperactive samuraï.
"Err, the cuts on the roof, was that really necessary?"

And obviously, when I look at the ceiling I wanted to move, it doesn't get any better:


Also, we can see that my arches were cutting too deep into the ceiling, and you just have to look at the edges to see it's going to be quicker to start over than trying to fix the problem. Which, in a whitebox phase, is kind of a problem.

Another issue with this is performance. CSG operations are expensive. By the time I added the 6th arch (because I can't do all of them at once), the operation was already taking significantly longer to complete. And in the above picture, selecting a face was a real struggle (and I've got a decent computer).

So obviously, we could get around most of those problems by adopting a modular approach and using building blocks, but in that case, I consider we're past the whiteboxing phase (in most cases).

Now, on the upside, anything you do with the solid is done in real time in the perspective view (I might be mentioning this a few times during this series, but Sandbox really feels like it's been designed so you do everything in the 3D view), and provided you know what you want to achieve, you can get there quite quickly (thanks to a few things I'll mention in another article). The only real problem is iteration. That said, while Unreal's BSP can very well be part of the final geometry, CryEngine's solids are clearly meant to be temporary. Which is fine when you've got environment artists at your disposal :)

Conclusion

It might be biased, as I know one system much better than the other, but as far as whiteboxing is concerned, Unreal's BSP geometry is clearly way ahead in terms of usability and, more importantly, iterability. That said, we must keep in mind that solids are quite new to CryEngine (I recall them not working at all in CryEngine 2), and despite all the issues, they can get the job done in a more than reasonable amount of time once you get used to it. Just don't change you mind too often.