Constructive Solid Geometry
Table of contentsIntroduction
Subtract [PRO only]
Intersect [PRO only]
Split [PRO only]
Optimising Your Objects
See how a vertex is created at every point that an edge from one object intersects a face from the other object. Each new vertex is joined by an edge to an extra vertex in that face. These vertices are a byproduct of the CSG operations resulting in unnecessary polygons. You can read how to optimise your objects in the Optimising Your Objects section.
The union function is different from all the other functions, in
that it doesn't really change the shape of your geometry (unless
you have unseen detail where the objects intersect), it just merges
the two objects into one object. For this reason union should be
used with consideration as it can create extra polygons (even when
optimised) that could be saved by leaving the objects separate.
However, uniting two objects removes overlapping polygons and can
prevent artifacts happening when rendering objects at distance.
The image below compares the pre-CSG scene to the post-CSG,
Due to the extra vertices created, vertex-snap is turned off on objects after CSG has been performed on them. Often you may wish to turn vertex-snap back on again; to do so simply right click on a window while the object is selected and click 'Properties', or click on 'Object Inspector' in the 'View' menu. The snap mode can be changed via a drop down menu.
One last thing to note is that the CSG union operation can be used on any number of objects at a time. The only thing to be careful of is that each object adds more and more unnecessary polygons to the calculations, so the time taken to perform the operation will increase exponentially with object numbers. This will also mean the resulting object will be a lot harder to optimise. A better idea for large numbers of objects is to merge two objects at a time, and optimise between unions.
Try it out: use both objects as the operator and see what kind of results you get.
The operator defines the shape to be carved out of the other object. In the above picture you can see the cylinder operator has carved a cylinder shape out of the cube. You can also select whether you want the operator to be deleted after the operation in the options, accessable via the 'View' menu, or by pressing Ctrl-Alt-O. Then click on the CSG tab. The other option in the menu allows you to choose how many polygons need to be involved in a CSG operation for the progress bar to show.
As with union, any number of objects may be used in subtraction, but only the last selected one will be used as an operator. Subtraction with more than two objects is like performing multiple, separate CSG subtractions using the same operator. Handy if you want to take a chunk out of a scene made of more than one object.
Intersect, like union, doesn't use an operator, and any amount of objects can be used in the operation. Just note that with more than two objects, only where ALL of the objects are intersecting will new geometry be generated, not just where two objects intersect.
In the image above I have moved the 'cut-off' object to the side to make it more clear what is going on. Two objects are generated; the 'cut-off' you can see is identical to the result of the intersect operation, and the other part is identical to the result of the subtraction operation. The split operation only allows two objects at a time to be used, and an error message will appear if you attempt to use more than two.
Step 1: Merge Adjacent PolygonsThe first stage in optimising is to merge adjacent, parallel polygons. For example, the image below shows merging of the polygons on top of the cube face.
To merge polygons, simply enter polygon mode, select all the adjacent polygons you want to merge, then click the 'Merge' button located on the menu. This will delete the edges separating each polygon, creating one big polygon. Continue merging to remove the remaining excess polygons.
Step 2: Delete Isolated VerticesThe next stage in the optimisation is to delete all isolated vertices. Isolated vertices are vertices that only join two parallel edges, and should be removed otherwise the polygons we just removed will re-appear during triangulation. Enter vertex mode, select all of the isolated vertices, and hit 'Delete' on the keyboard. Job done.
Step 3: Fix Concave PolygonsNote that some concave shapes of polygon render oddly, so you may have to join some vertices to separate the polygon into a set of convex polygons. Below on the left you can see a concave polygon rendering wrongly, and on the right I have joined the vertices (using the Vertex Connect function) to fix the problem. This results in a set of convex polygons. This stage is not always necessary. Alternatively, you can use Triangulation to create convex polygons also.
To end this tutorial, here's an image of the kind of thing that is possible
using a combination of all the CSG functions. Have fun with CSG!