Binary space partitioning is a generic process of recursively dividing a scene into two until the partitioning satisfies one or more requirements. It can be seen as a generalization of other spatial tree structures such as k-d trees and quadtrees, one where hyperplanes that partition the space may have any orientation, rather than being aligned with the coordinate axes as they are in k-d trees or quadtrees. When used in computer graphics to render scenes composed of planar polygons, the partitioning planes are frequently chosen to coincide with the planes defined by polygons in the scene.
The specific choice of partitioning plane and criterion for terminating the partitioning process varies depending on the purpose of the BSP tree. For example, in computer graphics rendering, the scene is divided until each node of the BSP tree contains only polygons that can be rendered in arbitrary order. When back-face culling is used, each node, therefore, contains a convex set of polygons, whereas when rendering double-sided polygons, each node of the BSP tree contains only polygons in a single plane. In collision detection or ray tracing, a scene may be divided up into primitives on which collision or ray intersection tests are straightforward.
Binary space partitioning arose from computer graphics needing to rapidly draw three-dimensional scenes composed of polygons. A simple way to draw such scenes is the painter's algorithm, which produces polygons in order of distance from the viewer, back to front, painting over the background and previous polygons with each closer object. This approach has two disadvantages: the time required to sort polygons in back-to-front order, and the possibility of errors in overlapping polygons. Fuchs and co-authors16 showed that constructing a BSP tree solved both of these problems by providing a rapid method of sorting polygons with respect to a given viewpoint (linear in the number of polygons in the scene) and by subdividing overlapping polygons to avoid errors that can occur with the painter's algorithm. A disadvantage of binary space partitioning is that generating a BSP tree can be time-consuming. Typically, it is therefore performed once on static geometry, as a pre-calculation step, prior to rendering or other real-time operations on a scene. The expense of constructing a BSP tree makes it difficult and inefficient to directly implement moving objects into a tree.
The canonical use of a BSP tree is for rendering polygons (that are double-sided, that is, without back-face culling) with the painter's algorithm. Each polygon is designated with a front side and a backside which could be chosen arbitrarily and only affects the structure of the tree but not the required result.17 Such a tree is constructed from an unsorted list of all the polygons in a scene. The recursive algorithm for construction of a BSP tree from that list of polygons is:18
The following diagram illustrates the use of this algorithm in converting a list of lines or polygons into a BSP tree. At each of the eight steps (i.-viii.), the algorithm above is applied to a list of lines, and one new node is added to the tree.
The final number of polygons or lines in a tree is often larger (sometimes much larger19) than the original list, since lines or polygons that cross the partitioning plane must be split into two. It is desirable to minimize this increase, but also to maintain reasonable balance in the final tree. The choice of which polygon or line is used as a partitioning plane (in step 1 of the algorithm) is therefore important in creating an efficient BSP tree.
A BSP tree is traversed in a linear time, in an order determined by the particular function of the tree. Again using the example of rendering double-sided polygons using the painter's algorithm, to draw a polygon P correctly requires that all polygons behind the plane P lies in must be drawn first, then polygon P, then finally the polygons in front of P. If this drawing order is satisfied for all polygons in a scene, then the entire scene renders in the correct order. This procedure can be implemented by recursively traversing a BSP tree using the following algorithm.20 From a given viewing location V, to render a BSP tree,
Applying this algorithm recursively to the BSP tree generated above results in the following steps:
The tree is traversed in linear time and renders the polygons in a far-to-near ordering (D1, B1, C1, A, D2, B2, C2, D3) suitable for the painter's algorithm.
BSP trees are often used by 3D video games, particularly first-person shooters and those with indoor environments. Game engines using BSP trees include the Doom (id Tech 1), Quake (id Tech 2 variant), GoldSrc and Source engines. In them, BSP trees containing the static geometry of a scene are often used together with a Z-buffer, to correctly merge movable objects such as doors and characters onto the background scene. While binary space partitioning provides a convenient way to store and retrieve spatial information about polygons in a scene, it does not solve the problem of visible surface determination. BSP trees have also been applied to image compression.21
Schumacker, R.A.; Brand, B.; Gilliland, M.G.; Sharp, W.H. (1969). Study for Applying Computer-Generated Images to Visual Simulation (Report). U.S. Air Force Human Resources Laboratory. AFHRL-TR-69-14. https://books.google.com/books?id=0mtk5MdXJhEC ↩
Fuchs, Henry; Kedem, Zvi. M; Naylor, Bruce F. (1980). "On Visible Surface Generation by A Priori Tree Structures" (PDF). SIGGRAPH '80 Proceedings of the 7th annual conference on Computer graphics and interactive techniques. ACM. pp. 124–133. doi:10.1145/965105.807481. http://www.cs.unc.edu/~fuchs/publications/VisSurfaceGeneration80.pdf ↩
Thibault, William C.; Naylor, Bruce F. (1987). "Set operations on polyhedra using binary space partitioning trees". SIGGRAPH '87 Proceedings of the 14th annual conference on Computer graphics and interactive techniques. ACM. pp. 153–162. doi:10.1145/37402.37421. /wiki/Doi_(identifier) ↩
Etherington, Thomas R.; Morgan, Fraser J.; O’Sullivan, David (2022). "Binary space partitioning generates hierarchical and rectilinear neutral landscape models suitable for human-dominated landscapes". Landscape Ecology. 37 (7): 1761–1769. Bibcode:2022LaEco..37.1761E. doi:10.1007/s10980-022-01452-6. https://doi.org/10.1007%2Fs10980-022-01452-6 ↩
Naylor, Bruce (May 1981). A Priori Based Techniques for Determining Visibility Priority for 3-D Scenes (Ph.D. thesis). University of Texas at Dallas. Retrieved June 5, 2025. https://www.proquest.com/openview/94daf3b8677f8ca4567915515efeefac/1?pq-origsite=gscholar&cbl=18750&diss=y ↩
Fuchs, Henry; Abram, Gregory D.; Grant, Eric D. (1983). "Near real-time shaded display of rigid objects". Proceedings of the 10th annual conference on Computer graphics and interactive techniques. ACM. pp. 65–72. doi:10.1145/800059.801134. ISBN 978-0-89791-109-2. 978-0-89791-109-2 ↩
Naylor, Bruce; Amanatides, John; Thibault, William (August 1990). "Merging BSP Trees Yields Polyhedral Set Operations". ACM SIGGRAPH Computer Graphics. 24 (4). Association of Computing Machinery: 115–124. CiteSeerX 10.1.1.69.292. doi:10.1145/97880.97892. Retrieved June 5, 2025. https://dl.acm.org/doi/pdf/10.1145/97880.97892 ↩
Teller, Seth J.; Séquin, Carlo H. (July 1, 1991). "Visibility preprocessing for interactive walkthroughs". ACM SIGGRAPH Computer Graphics. 25 (4). Association of Computing Machinery: 61–70. Retrieved June 5, 2025. https://dl.acm.org/doi/abs/10.1145/127719.122725 ↩
Chen, S.; Gordon, D. (October 1991). "Front-to-Back Display of BSP Trees". IEEE Computer Graphics and Applications. 11 (5): 79–85. doi:10.1109/38.90569. S2CID 19056967. https://www.researchgate.net/publication/3208236_Front-to-back_display_of_BSP_trees ↩
Teller, Seth (1992). Visibility computations in densely occluded polyhedral environments (Ph.D. thesis). University of California at Berkeley. Retrieved June 5, 2025. https://www.proquest.com/openview/80322259984cf6c676a345676ab1d74a/1?pq-origsite=gscholar&cbl=18750&diss=y ↩
Naylor, Bruce (1993). "Constructing good partitioning trees" (PDF). Graphics Interface. Canadian Information Processing Society: 181–191. Retrieved June 5, 2025. https://www.researchgate.net/profile/Bruce-Naylor/publication/2492209_Constructing_Good_Partitioning_Trees/links/55cc86be08aea2d9bdce442d/Constructing-Good-Partitioning-Trees.pdf ↩
Radha, Hayder (1993). Efficient image representation using binary space partitioning trees (Ph.D. thesis). Columbia University. Retrieved June 5, 2025. https://www.proquest.com/openview/a80bc19b1374b928afa8844a8ed05ef4/1?pq-origsite=gscholar&cbl=18750&diss=y ↩
Radha, H.; Vetterli, M.; Leonardi, R. (1996). "Image compression using binary space partitioning trees" (PDF). IEEE Transactions on Image Processing. 5 (12): 1610–1624. Bibcode:1996ITIP....5.1610R. doi:10.1109/83.544569. PMID 18290079. https://infoscience.epfl.ch/record/33877/files/RadhaVL96.pdf ↩