BSP Tree Optimization in Flash 10

Binary Space Partitioning trees are the new trend to cure the lack of Z-Buffer when building 3D applications for the Flash Platform. Thus, building a fast and robust BSP system is one of the key for a successful 3D API targeting Flash. I won’t discuss BSP theory here because it’s very easy to find good documentation. I’ll rather let you play with a little experiment and discuss what it actually features…

The Experiment

BSP tree optimization experiment
BSP tree optimization experiment

What It Does…

  • load a *.3DS file and use it as a mesh
  • load a *.PNG texture and use it as a material
  • display the mesh using a BSP tree

The vertical slider enables you to play with what I called the BSP precision. This value represents the thickness of the partition planes used to build the BSP tree: the lower the precision, the better the final rendering. When the precision is higher, the BSP is less deep and a lot faster to render. But if the precision is too high, some artifacts occur and the rendering is corrupted. The idea is to find the best rendering quality/number of artifacts ratio.

When checked , the “Optimized BSP” checkbox enables the build BSP where each partition plane will be chosen carefully. This very choice is based on the number of polygons that would have to be cut if that plane was ever used as a partition plane. This way, the final BSP tree features a lot less polygons and is faster to walk through/render.

And the “Wireframe” checkbox speaks for itself I guess… Anyway, wireframe rendering makes it possible to see how the BSP tree actually divides more or less polygons depending on the settings you chose.

And The Good News Is…

Keep an eye on the Triangles Per Second counter (TPS, on the top-left corner of the screen) as you play with the precision slider/optimization checkbox. Changing those values of the BSP tree has a huge impact on the amount of rendered polygons (and the overall performances of course!).