3dcameraorthographicbsp-tree

Orthographic projection and BSP-tree to render objects from back to front


I am building a BSP tree from triangles in 3d space. All triangles have already been transformed to view space before constructing the BSP tree. Therefore I use the point (0, 0, 0) as a position for the viewer's eye and traverse the tree from far to near and add all visited triangles to a list.

I then iterate through the list and transform the triangles with an orthographic projection and draw them to screen. This works most of the time but sometimes I get strange artifacts because of wrong triangle orderings. This does never happen if I use a perspective projection instead.

Why does this happen with an orthographic projection? Are BSP trees not working when solving the visibility problem under orthographic projections? Or do I need to adopt my eye position?


Solution

  • I'm pretty sure you can use a BSP tree for an orthographic projection, but it will require adjusted math compared to a perspective projection, as despite placing your viewer at 0,0,0, you can't sort polygons with respect to that point. An orthographic projection effectively places the viewer at infinity. Assuming you are looking down the standard -Z axis you need to traverse your BSP tree as if the viewer is at 0,0,∞. If you're using standard ax+by+cz+d=0 for your split planes the math is very simple actually, as you basically only need to consider the sign of c to determine which side of the plane to traverse first. (If c is zero you can traverse either side first.)