Tuesday, December 25, 2012

About BSP

BSP stands for Binary Space Partition. It is the method used by Mental Ray to speed up raytracing. Mental Ray partitions the scene in order to roughly know where each polygon is located in the scene.



Optimizing the BSP settings may be necessary to be able to render your scene. At one end, non-optimized settings may cause the scene to render very slowly; at the other end, they may cause Mental Ray to hog up too much memory, possibly resulting in out-of-memory errors ( For large scene containing millions of polygons). 

A scene consist of many polygons (triangles). Mental Ray needs to do all kinds of calculations on these. To do this as quickly as possible, Mental Ray needs to be able to find out efficiently which polygon is located in any given part of your scene. Therefore your 3D scene is split into cells (voxels, or: '3D pixels') using the BSP algorithm. For every voxel the polygons that are present are listed.

 BSP Tree
It starts to split your scene into two voxels and determines the number of polygons in each voxel. If the number of polygons is larger than a set number (BSP size), it splits that voxel (because finding a specific polygon in a very large list is still not too quick). This process is repeated until the number of polygons in that voxel is smaller than the set BSP size, or if the maximum number of splits (BSP depth) has been reached. These voxels at the end of the splitting process are called leaves (compare: leaves on a tree, at the end of a branch). This entire operation constructs a tree in which Mental Ray can quickly lookup which polygon is in a specific part (leaf voxel) of your scene. Mental Ray now only needs to consider the few polygons that are in a specific voxel when doing calculations. In this image, B, D, E, G and H are leaf nodes.

No comments:

Post a Comment