Welcome back to this Hotgates tutorial series. Now that we have some solid understanding of the Unreal Engine Editor’s UI, we will use BSP to quickly prototype our first simple level. In this tutorial we will learn what BSP Brushes are, how and why we use them. We will also take a look at measurement units and how they relate in the context of Unreal Engine 4. Last but not least we will learn how to achieve a correct sense of scale in Unreal Engine 4.
BSP explained as simple as possible
Everything we see on a screen that we consider “motion”, are actually still images displayed consecutively on the screen. The speed or more correctly the frequency at which these images are displayed is called frame rate. Frame rate is expressed in frames per second or FPS. The human eye operates in different ways when it comes to motion. Many people will report the illusion of physically moving when their peripheral vision sees images with a FPS of 60+. That’s partly why VR games need to maintain a fast FPS of at least 90. Anything displayed on a screen that is above 20 FPS is interpreted as movement by our brain. Higher FPS, besides providing a smoother gaming experience, is also less taxing on our eyes and brain.
Applications that use 3D models to generate images must perform calculations for every frame of an animation. They do that to determine the spatial relations between the 3D models that make up the scene. Calculations about how they intersect and/or how they may occlude each other or where they move must be done. 3D models are not just monolithic objects, they are comprised of many smaller pieces known as polygons. The number of polygons in a scene may range from a few hundreds to many millions. Trying to calculate the spatial relations between all those polygons by brute force would require an insane amount of operations. As a result we would get lower rendering speeds and thus, lower FPS.
To reduce these calculations programmers use Binary Space Partitioning Trees, also called BSP Trees or Partitioning Trees, instead. The reduction in calculations occurred because BSP Trees provide a computational representation of space and geometry. At the same time they also provide structure, a “spatial sorting”. In other words, a 3D scene is split in two using a 2D plane, then that scene is divided in two using a 2D plane again, and so on. The resulting data structure is a binary tree. The image below is just a simple example of how a binary tree can be used to split a scene and sort four geometric objects.
This technique is widely used, especially in video games. Because the location of objects in a scene can be specified using less calculations, the renderer can create what a player sees much faster. Epic Games’ “Unreal Tournament”, John Carmack’s “Doom” and “Quake” are a few games that used BSP. Beyond video games BSP is also used for collision detection in robotics and rendering in CAD (computer-aided design).
3D object: Dimensions and parts
A 3D Object is a solid object that has three dimensions: length, depth and height. In 3D modeling those values are represented as values in the X,Y and Z axes. Each application uses their own coordinate system. Unreal Engine 4 uses a left handed coordinate system where the vertical direction is usually represented by the Z axis. +Z axis UP. The axes are as follows:
X – forwards, backwards
Y – left, right
Z – up, down
A 3D object is made of three parts, Faces, Edges and Vertices.
The face is the flat surface of a 3D object.
The edge is a line where the two edges meet.
The vertex is the point where two or more edges meet, a corner.
BSP in Unreal Editor
Run the Unreal Editor and create a new level if none was loaded on start up. Go to the Modes Panel, make sure you are in Place Mode (Shift+1). On the left you will see some tools, the sixth from above is the Geometry or BSP tool. We will use the BSP tool to quickly prototype (also known as “blocking out”) our level. In Unreal Engine 4 the BSP tool comes with seven Brushes (shapes). Βy adding and subtracting these brushes we can create highly complex objects. In 3D modeling this technique of adding and subtracting simple objects to create complex ones is also known as Constructive Solid Geometry (CSG). You may see or hear CSG and BSP both being used to refer to the geometry in Unreal Engine, don’t be confused they are both the same.
BSP has been a part of Unreal Engine since the beginning. Earlier versions used BSP for the final level design, but now static meshes have taken up this role. As the complexity of the models has increased, the use of BSP has become more expensive in performance. That’s the reason you should use BSP only to prototype a level and once you are satisfied with how a level looks and plays then replace the BSP brushes with static meshes.
Using BSP in Unreal Engine 4
As mentioned earlier, in Unreal Engine 4 the BSP tool comes with seven Brushes (shapes). Each brush has its own attributes which you can adjust in the Details panel. You can also use the Transform Tools to move, rotate, and scale them as you like. In Geometry Editing mode (Shift+F5) you can edit the vertices, edges and faces of a brush, to create complex shapes. Without further ado the seven brushes are:
Box: You can adjust the size of the cube in the X, Y, and Z axes. You can make the cube Hollow and adjust its wall thickness when it is hollow (a quick way to create a room). You can also make it Tessellated, which draws extra internal faces for each cube face. The Tessellated option can not be enabled while the Hollow option is in use and vice versa.
Tessellation : “A tessellation of a flat surface is the tiling of a plane using one or more geometric shapes, called tiles, with no overlaps and no gaps.”
Cone: You can adjust the height of the cone in the Z axis, the outer radius, the number of sides and whether to align a face of the cone to the grid. You can make the cone Hollow as well and adjust its inner radius and inner height.
Cylinder: You can adjust the height of the cylinder in the Z axis, the outer radius, the number of sides and whether to align a face of the cylinder to the grid. You can make the cylinder Hollow as well but you can adjust only its inner radius. A hollow cylinder acts like a pipe and not as a room like a cube and a cone do.
Curved Stair: You can adjust the Inner Radius of the stair, which influences the total radius of the stair as well. You can adjust the step height and width which influences only the outer radius of the stair. The angle of curve influences the total arc of the stair and cannot exceed 360 degrees as the stair cannot wrap over itself. You can adjust the number of steps, the height of the first step. Lastly you can adjust whether the stair bends clockwise or not.
Linear Stair: You can adjust the length, height, width and number of stairs and also the height of the first step. This stair does not bent.
Spiral Stair: You can adjust the Inner Radius of the stair, which influences the total radius of the stair as well. You can adjust the step height, thickness and width which influences the outer radius of the stair as well. The number of steps influences the height of the stair. The number of steps per 360 degrees influences how many steps will be in one whole spiral rotation. The sloped ceiling and floor toggles between a sloped or stepped surface for the underside and the surface of the stair respectively. This is a spiral stair that can repeatedly wrap over itself.
Sphere: You can only adjust the radius of the sphere and the Tessellation value, the higher the value the more polygons it will have and the smoother it will look.
All BSP brushes have two modes:
Additive: This creates solid objects. This brush will add geometry to your level. You will use the Additive mode to create boxes, walls, floors, ceilings, and so on.
Subtractive: This creates empty objects. This brush will subtract/remove solid space from any additive brush that you’ve previously placed in your level. You will use the Subtractive mode to create an opening like a cave entrance, windows or doors on walls, and so on.
If you have a complex BSP object in your level that you like, you can convert it to a Static Mesh and save it in the Content Browser. Keep in mind though that a static mesh created this way will have no UVs or additional Material info. No need to panic though, you can always export the static mesh as an .fbx file from the editor and import it into the DCC application of your choice. This is not the recommended workflow, you should use a DCC application for the creation of your assets.
For a more detailed guides and articles about Geometry Brush Actors please refer to the “Sources, inspirations and interesting reads” section at the end of this tutorial.
Real world units of measurement
Learning about what BSP brushes are and how we use them is only aspect of level creation. Τhere is another fundamental aspect of level creation that most people overlook when learning the basics. Μeasurements in the real world and how they relate in the context of Unreal Engine 4. By definition when we say measurement we mean determining the size, weight, volume, or the amount of something (such as distance) either a in real world or in Unreal Engine 4.
In the real world, we use the U.S. Standard or the European Standard units of measurement to measure distance. Unreal Engine uses Unreal Units and we measure the dimensions of an object as a 3D vector in 3D space in the X, Y, and Z dimensions. In a 2D game world we measure the dimensions on the X and Y dimensions.
In the U.S. and Great Britain they use the Imperial system that involves the use of inches (in), feet (ft), yards (yd), and miles. Most of Europe uses the Metric system that includes millimeters (mm), centimeters (cm), meters (m), and kilometer (km). For your convenience I have put together the following three tables. They include a set of conversions between the U.S. and the European units of measurements.
Most modern smartphones have some sort of unit converter. In case you need one all you have to do is simply type Unit Converter in the search field of Google search. A converter will conveniently appear right below the search field.
With a strong understanding of real world measurements, we can now move on and discuss how we measure things in Unreal Engine 4.
Basic unit of length in Unreal Engine
Ever since the first Unreal Engine we use the Unreal Units or (uu) for measurements in the Editor. By default 1 uu equals 0.75 in or 16 uu roughly corresponds to 1 foot and 52.5 uu to 1 meter. Distances, brush and static mesh dimensions, collision cylinder sizes are always measured in uu. The grid used in Unreal Editor is also based on Unreal Units. In Unreal Engine 4 the default value of 1 uu is equal to 1 cm. Thankfully the engine allows you to adjust the ratio between an Unreal Unit and any real world measurement unit. This can be adjusted for each project individually. as you can see in the following screenshot.
Common measurements in Unreal Engine 4
When designing the levels for your game, it’s important to know the common measurements that are used in your game world. With the arrival of VR, having a correct sense of scale has never been more important. In traditional 3D games the scaling of the game world varies depending on what the developers want to achieve. Usually the character in the game would be your scale reference. In VR though, you are the scale reference. For the purposes of this tutorial we’ll use measurements to reflect a game that aims for realism.
By default in Unreal Engine 4, 1 uu is equal to 1 cm and the player character is 192 uu tall, (96 uu half height from the center of the collision capsule to the top or bottom). Keeping these dimensions in mind here are a few ways to calculate some of the most common measurements used in a game.
Player character reference
The first thing to do is to place the player character in the level. We can also create a BSP brush with the same dimensions as the player character. This will allow us to move the player reference around the level to get an immediate sense of scale. The dimensions of our reference should be 192 uu in height (H), 110 uu in width (W) and 110 uu in depth (D). We must also take into consideration that the player will at some point carry a weapon. These are the dimensions of the default first person character, you can use your own character’s dimensions if you wish.
In most games there will be indoor areas the player will visit. It is only natural to want to get the scale of the rooms right. A simple way to find the correct scale for our walls is to simply place our player reference next to one. Usually a wall height between 50% to 100% of the character’s height will work just fine. In our case this would mean (player height x 1.5 or x 2) 192 uu x 1.5 = 288 uu (H) or 192 uu x 2 = 384 uu (H). Anything above those numbers will work fine. Usually though a wall size of 300 uu (H) or 400 uu (H) is preferred.
The wall thickness or depth depends on the material the wall is made of, as in real life. It is not uncommon to use simple planes as walls in order to save on the overall polygon count. Usually a depth of 10 uu (D) to 20 uu (D) will work fine.
In the same way as walls we can determine the dimensions of a doorway. By placing our player reference inside a doorway we can quickly decide if the scale is eight or not. When designing doorways always keep in mind that a door frame will be placed there and it will take away from the dimensions of the doorway opening. The dimensions of the door and the doorway depth, both depend on the wall’s depth. The dimensions in the following screenshot are deliberate. Observe how the player reference helps as notice that the doorway’s sense of scale is off.
The placement of a window might seem an easy task. Placing the player reference will help you choose the right height and scale for your window. The dimensions of a window depends also on the wall’s depth.
When designing a staircase you need to take into consideration the area the staircase will be placed in. What people tend to forget, is the value of your player character’s Max Step Height. This is a very crucial value because if the step height of the staircase is higher than the Max Step Height value of the player character, the player will not be able to go up the stairs.
Hotgates’ suggestion: Iterate, iterate, iterate
All these ways to determine a proper scale for the level are very useful. The best way is to actually play your level, over and over again until the sense of scale feels right. What looks right from a 3rd person perspective doesn’t necessarily work in first person view. In a traditional 3D game you may get away with not getting the scale right in some places. In VR getting the sense of scale wrong will not only break immersion, but it can render your game unplayable altogether.
Summary. Where do we go from here?
With the knowledge you have gained, the next task should be easy. I want you to block out the simple house as seen in the rough sketch below. I have deliberately omitted to include any dimensions. Based on what you have learned you should have no problem recreating the house while getting the sense of scale right.
You can use your own plan or make it more complex if you feel like it. Don’t worry about making it look nice. Experiment with the brushes, change their values to see the effects of your actions. Have fun with the editor. In the coming Hotgates tutorials we’ll create the above house with BSP. We will import some assets from a DCC (Digital Content Creation) application such as 3ds Max, Maya, or Blender to replace those BSP brushes. We will also take a first look at applying materials on both BSP brushes and Static Meshes. Until then take care and keep it Unreal.
Sources, inspirations and interesting reads:
There is a fascinating article written by Alex Wiltshire on pcgamer.com about how many frames per second the human eye can really see.
For more information about Binary Space Partitioning please refer to “A Tutorial on Binary Space Partitioning” by Bruce F. Naylor.
The wiki at Unreal Engine’s official site has a very useful and comprehensive tutorial about using BSP to block out your level, which you can read here.
Last but not least is the Official Unreal Engine Documentation about Geometry Brush Actors.