thumb|300px|CSG objects can be represented by binary trees, where leaves represent primitives, and nodes represent operations. In this figure, the nodes are labeled for [[Intersection (set theory)|intersection, for union, and for difference.]]

Constructive solid geometry (CSG; formerly called computational binary solid geometry) is a technique used in solid modeling. Constructive solid geometry allows a modeler to create a complex surface or object by using Boolean operators to combine simpler objects, potentially generating visually complex objects by combining a few primitive ones.

In 3D computer graphics and CAD, CSG is often used in procedural modeling. CSG can also be performed on polygonal meshes, and may or may not be procedural and/or parametric.

CSG can be contrasted with polygon mesh modeling, boundary representation, and box modeling.

Workings

The simplest solid objects used for the representation are called geometric primitives. Typically they are the objects of simple shape: cuboids, cylinders, prisms, pyramids, spheres, cones.

Nearly all engineering CAD packages use CSG (where it may be useful for representing tool cuts, and features where parts must fit together).

The Quake engine and Unreal Engine both use this system, as does Hammer (the native Source engine level editor), and Torque Game Engine/Torque Game Engine Advanced. CSG is popular because a modeler can use a set of relatively simple objects to create very complicated geometry. This can be important for some manufacturing or engineering computation applications. By comparison, when creating geometry based upon boundary representations, additional topological data is required, or consistency checks must be performed to assure that the given boundary description specifies a valid solid object. This is a desirable quality for some applications such as ray tracing.

Another approach decouples the detection of primitive shapes and the computation of the CSG tree that defines the final model. This approach exploits the ability of modern program synthesis tools to find a CSG tree with minimal complexity.

There are also approaches that use genetic algorithms to iteratively optimize an initial shape towards the shape of the desired mesh.

Notable applications with CSG support

<!--Listed applications should be notable with a sourced Wikipedia article.-->

Generic modelling languages and software

  • HyperFun
  • PLaSM

Ray tracing and particle transport

  • PhotoRealistic RenderMan
  • POV-Ray

Computer-aided design

  • AutoCAD
  • Autodesk Inventor
  • Autodesk Fusion 360
  • BRL-CAD
  • CATIA
  • FreeCAD
  • NX CAD
  • SolveSpace
  • Onshape
  • OpenSCAD
  • PTC Creo Parametric (formerly known as Pro/Engineer)
  • Realsoft 3D
  • Rhino
  • Solid Edge
  • SolidWorks
  • Tinkercad
  • Vectorworks

Gaming

  • Dreams
  • Godot
  • GtkRadiant
  • LittleBigPlanet
  • Roblox
  • Unity, via free or paid plug-ins from the Unity Asset Store.
  • UnrealEd
  • Valve Hammer Editor

Others

  • 3Delight
  • Aqsis (as of version 0.6.0)
  • Blender – primarily a surface mesh editor, but capable of simple CSG using meta objects and using the Boolean modifier on mesh objects.
  • CGAL – a library of geometric algorithms and data structures, in particular Boolean operations on polygonal meshes.
  • Clara.io
  • Geant4
  • Magica CSG
  • MCNP
  • SketchUp
  • Womp

References