The dangers of using CSG subtract
On the face of it, CSG subtract seems like one of the most appealing construction tools available in Radiant editor series. Using a brush to make a nice hole in another brush seems all happy and smiley - but it hides a darker truth of non-optimal cuts, unnecessary triangles, and dangerous microbrushes. Read on, if you dare.
This tutorial assumes you are already familiar with basic brush construction, including creating brushes, the clipper tool and edge manipulation, and that you have compiled and run at least a test map. Understanding the difference between structural and detail brushes is also helpful but not by any means essential.
To show you some of the problems that CSG subtract can cause in a map, I am going to take a very simple example. To the right you can see the floor brush of a room, 384 units square. I have hidden the walls and ceiling so that we can see what is going on more clearly.
In the middle of this floor, I want a section that is a seperate brush, 128 units square, which I can texture differently. This could be for a jumppad, weapon spawn marker or whatever.
This is what happens when I select my 128 unit square brush and use the CSG Subtract tool. A few of you may be thinking that this seems OK, and to some extent, it is. We've got the central square brush where you want it, and a solid enough floor around it. However, the brushes here could have been built better.
To understand why those cuts aren't the best ones, we need to look at what will happen when we compile this map and load it into the game. Part of the compiler's job is to divide all the brush surfaces in the map up into triangles, which it does using all the vertices that touch any edge of a given brush face, even if they're on an entirely different brush. The image to the right shows how it would split the visible surfaces of these brushes. This screenshot also shows the unwanted cuts that are created on the walls of the room because of the untidy brush set we would get from using CSG subtract.
Clearly, we are seeing quite a messy set of triangles being created here that we would much rather do without. Generally, less triangles in an object will mean that the engine can draw it faster. Based on how we've seen the compiler divide up those brushes into triangles we can see how to create a set of brushes that will result in fewer triangles being created overall.
Here I'm starting to create a set of mitred brushes that surrounds the central square brush, by dragging out a 128 by 384 brush and then carefully dragging the corners in with the edge manipulation tool. You may prefer to use the clipper for this sort of thing.
I've now completed the floor by cloning my first brush, rotating and dragging it into place three times.
This is how the compiler will divide up the brush faces when this version of the floor is compiled. As you can see, there are fewer triangles overall. In this screenshot you can see that this method also avoids creating any extra triangles in the walls because all the splits in the floor line up with the corners of the room, rather than abutting to the middle of any of the walls.
At this point some of you may be wondering what the big deal is about a few extra triangles. Remember that what we've looked at here is a very simple map, whose construction is far more basic than the standard of geometric detail you would be looking at in an actual released map. In a more complex map, the chances are that subtracting out a few bits and pieces here and there will cause far more untidy splits than the one I've demonstrated, and when you have this kind of construction applied to a whole level it can potentially impact negatively on the speed your map runs and its overall compiled BSP size, and also increase the time it takes to compile.
Read on for more problems CSG subtract can cause.