Tutorial 1: Getting Started with SabreCSG

Create Your First Brush

To begin using the SabreCSG tools in Unity, once you have imported SabreCSG, you will need to create a CSG model in your scene.

To do this, from the menu bar select GameObject -> Create CSG. This will add a blue volume to the center of your scene. Once you hit the Rebuild button (or press Ctrl+Shift+R on PC, Cmd+Shift+R on OSX), the brush will be converted into your level’s geometry. Brushes, which are primitive 3D volumes, are the building blocks for your level in SabreCSG.

To learn some of the basic brush tools, please see the Resize Tool portion of the Reference Manual.

0, create and rebuild brushesCreating, Rebuilding, and Moving your First Brush

In the gif above, you can see the steps for creating your first CSG brush, rebuilding it, moving it, and rebuilding it again. The opaque, tiled volume is the actual level geometry produced by rebuilding the transparent, blue brush. Notice that on the second rebuild, after moving the brush, the original level geometry moves to the brush’s new location. To create two blocks of level geometry, you need two brushes, which you can make by duplicating the first brush (the keyboard shortcut is Ctrl+D or Cmd+D on OSX), moving it, and then clicking rebuild.

Additive and Subtractive Brushes

Brushes can be set as additive or subtractive volumes. By default, brushes are additive. When using most of SabreCSG’s tools (e.g. Resize, Clip, or Vertex tools), additive brushes are displayed in blue and subtractive brushes are orange.

Think of additive brushes like a solid block of clay. You can change the level geometry by creating more additive brushes, much as you could change the block of clay by adding more clay. You can also shape the level geometry using the Clip and Vertex modes. Subtractive brushes are another way of shaping the level geometry that you have already created. Like the clay, however, you can’t subtract from what doesn’t exist, so if you want to build most of your level’s geometry in a subtractive way, it is best to make your first brush a large additive volume. This will give you a large space to subtract within.

3, adding and subtractingAdding and Subtracting brushes

In the gif above, you can see how to duplicate a brush, change the new brush’s mode to subtractive, and rebuild. The first of these steps is duplicating the brush, which is performed with the duplicate keyboard shortcut (Ctrl+D or Cmd+D on OSX).

Brushes are different from level geometry. You have to rebuild to convert brushes into the playable level geometry. You can read more about that in the build settings.

Every time you create a new brush, it goes to the end of the Unity Hierarchy, so you can create an additive brush within a subtractive brush, so long as the addition is after the subtraction in the Hierarchy. (If the addition comes first in the Hierarchy, then it will be subtracted from by the subtractive brushes that follows it.)

You can also subtract from additions within subtractions as much as you want. For example, you could create a building in a cavern, and then create rooms within that building. It is best practice to build the whole level in a series of passes, from the most generic shapes to the smallest details. Completing a room’s details before completing the whole layout make it difficult to adjust the level because of the way order matters for subtractive level design. For example, if your level has several caverns, you would want to create these first, then create the buildings in the caverns, and then create the rooms within the buildings. Creating one cavern and its buildings before creating the other caverns (or creating one building and its rooms before creating the other buildings) makes it more difficult to revise a layout.

You may find it useful to think of brushes in the Hierarchy as a series of instructions for the level geometry. Creating a brush does not directly affect the level geometry, but it changes the instructions that SabreCSG follows when you click Rebuild. Similarly changing the order that brushes are placed in the hierarchy will change the order that these instructions are processed in.

The Additive Approach to Level Design

Let’s say you want to build a level in a desert with an arch off in the distance as a visual landmark for the player to seek. For now, let’s build the arch with sharp angles, more of a stone henge megalith than a true arch. It will have two pillars and a beam connecting them on the top. With SabreCSG, you can build this simple structure with three additive brushes. Or you can use the subtractive mode, which makes this process faster and easier. You can create one additive brush for the whole shape, and then subtract another brush to create the negative space of the archway. Here this means building the arch from two brushes instead of three.

arch_1_additiveBuilding our megalith additively

arch_2_subtractiveBuilding our megalith subtractively

Now to make a proper arch, it needs to curve. Using Unity’s primitive meshes, you would need to rotate and scale dozens of them to create an approximation of the right shape, and then it would be impossible to align the materials correctly. To create an arch correctly without SabreCSG, you would need to rely on additional 3D modeling software.

The easiest way to build an arch in SabreCSG is to create a prism brush, adjust its scale and the number of sides in its properties, clip away the half you don’t need, and then subtract it from an additive block.

arch_3_subtractive_curveCreating an arch by subtracting a modified prism

If you prefer working with additive brushes, you can also create an arch by vertex editing a number of additive brushes. This requires more brushes than when using a subtractive brush, but it gives more freedom for adjusting the material UVs around the arch. The gif below shows the start of making an arch from additive brushes. To create an additive arch that looks like the subtractive arch, you should create a prism to use as a guide.

arch_4_additive_curveStarting a “curved” arch with the vertex tool

Now let’s say you want to create a one-room house in your desert level to give the player somewhere to start. The house will have four walls, a ceiling, and a floor. You can create all of this with additive brushes, one for each wall, one for the floor, and one for the ceiling. Using the same technique from the arch, you could then subtract the doorway from one of the walls.

You could also make the house by creating one additive brush that is the same size as the building, and then subtracting a slightly smaller block from it to create the room within the house. Then, you can subtract the doorway from one of the walls. Instead of the 7 brushes necessary to create the house additively, you can build the house subtractively with 3 brushes.

house_1_subtractiveCreating a house by subtracting the room from an additive brush

The Subtractive Approach to Level Design

Let’s say you want to build a cave level now. The whole level will take place inside, with the exception of an occasional shaft of light from holes in the ceiling. Building this style of level calls for a different approach than the desert level. Here, each room should be a subtractive brush, which requires that you have something to subtract from. The first step for subtractive level design, then, is to create a large additive brush from which to subtract rooms and corridors.

With a subtractive approach to level design, it is often easier to use Unity’s wireframe view mode, and work from an axis-aligned isometric camera.

Once you have your large additive brush, you can create a room for the player to start in, and another distant room for the player to seek. At this point, if you rebuild the level, both rooms will be separate. We need to create a tunnel for the player to move from one room to the next.

Later on, if you fill each room with decorations and enemies, you may not want the player to be able to see one room from the other, so we will make the connecting hallway a curve to break the line of sight.

As with additive brushes, you can use vertex mode to create more complicated shapes with your subtractive brushes. In this case, we want the corridor to make a ‘C’ shape and keep roughly consistent width the whole way.

subtractive_design_1Some subtractive design

The gif above shows subtractive design from an axis-aligned isometric camera.

Now if you rebuild the level, you should have a hallway connecting two large rooms. These rooms are simple and bare, so we will add a pillar in the middle of the second one. Level geometry like pillars can break lines of sight, so that the player needs to explore the space in order to see all of it. The pillar also prevents the player from walking from the entrance of the room to its exit in a straight line. Instead, it creates an interesting path for the player to move along. Hidden information and visual uncertainty (often referred to as “occlusion” by level designers) can make a room feel mysterious or tense. How you want the player to look around and move through the room will depend on the kind of game you are making.

For now, the pillar is a simple way of making the room more interesting. We should also add some elevation difference so that when players enter the room, they can see the rough layout and form a plan for navigating the room safely, even though some information about the room is still hidden by the pillar.

To makes this change, let’s first lower the second room’s floor, add a platform for players to stand on when they enter, and then add a ramp down one side. With these two simple changes—the pillar and the elevation—this room is now much more interesting.

Both of the rooms of this cave are pretty square, though. Even with the pillar, it is too easy for the player to read the whole space at a glance. We can expand this second room and make it more interesting, and less square. By expanding the space in this way, we introduce more uncertainty and draw players forward to explore it.

Where Next?

To make the most of SabreCSG’s tools, you will want to use additive and subtractive brush modes together. Exactly how you use these modes will depend on the kind of level you want to make. Some, like the desert level, benefit from a more additive approach, where each building is an additive brush and rooms are subtracted from them. Other levels that are entirely inside, like the cave level, benefit from a subtractive approach to level design, where you start with a large additive block and subtract the rooms from it. Each approach can handle either type of level design, but by knowing which approach is most appropriate, you can rapidly build your levels and test your ideas.

If you haven’t already, reading through the Reference Manual, especially the Brush Tools will give you a good grounding for how to use the various features of SabreCSG.

Next Tutorial – A Theory of Level Design