---
title: "Binary Space Partitioning (BSP) Tree"
canonical: "https://documentation.chaos.com/space/DOCSGUIDE/113291960/Binary%20Space%20Partitioning%20(BSP)%20Tree"
format: markdown
---
<span style="color: #000000">One of the basic operations that V-Ray must perform is raycasting. Part of this process is determining whether a given ray intersects any geometry in the scene, and if so, identifying that geometry. The simplest way to implement this over the entire scene would be to test the ray against every single render primitive (triangle) in the scene. Obviously, in scenes with thousands or millions of triangles this is going to be very slow. To speed this process, V-Ray organizes the scene geometry into a special data structure called a </span><span style="color: #000000">*binary space partitioning*</span><span style="color: #000000"> (BSP) tree. </span>

<span style="color: #000000">The BSP tree is a hierarchical data structure, built by subdividing the scene in two parts, then looking at each of those two parts and subdividing them in turn, if necessary and so on. Those "parts" are called </span><span style="color: #000000">*nodes *</span><span style="color: #000000">of the tree. At the top of the hierarchy is the root node, which represents the bounding box of the whole scene. At the bottom of the hierarchy are the </span><span style="color: #000000">*leaf nodes*</span><span style="color: #000000">, which contain references to actual triangles in the scene. The BSP tree serves as an index to all the triangles in the scene, making raycasting calculations go much faster. </span>