Jump to content
  • Advertisement
Sign in to follow this  

how to depth sort a bsp

This topic is 4576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, i hear a lot that a bsp tree is the best choice for a datastructure for a scenegraph implementation (is this still true?), mainly because it is pretty easy to do depth-sorting. now how is depth-sorting done in a bsp-tree. no real code please ;) just the algorithm, described in some words. thanks a lot! PS: is depth-sorting still a must, to do correct alpha-testing, or are there other methods?

Share this post

Link to post
Share on other sites
For alpha, depth sorting is a must (if you want pixel-perfect blending).

Binary space partition tree is pretty simple. As the name includes, there is always "two spaces" : the front and the back (or left and right). As you know the every bsp node is defined by a plane so it is easy to find out which triangles are in front of the plane and which are on the back side.

In order to get the correct sorting information from BSP you'll need to know the location of the camera.

By evaluating the BSP tree recursively you can produce the correct drawing order.

The logic goes something like this:

For each node you must find out an answer to a question

"which side of the tree must I render first?"

So if you camera is in front of the node plane, logically, first you'll need to draw the nodes behind the current node. Then the node itself and then the other side.

So :

If this node has no front or back nodes, draw this and return.

If camera is in front of the node, then draw the nodes behind, then the current node, and then the nodes in front.

Else if camera is behind of the node, draw the nodes in front of the node, then the current node and then the nodes in behind.


I hope I got it right. It's been a while that I did any BSP stuff.

I am 100% sure that BSP isn't the most efficient way of drawing things. It works best with lowpoly stuff, and perhaps shouldn't be applied anywhere else than arranging translucent objects.

Best regards

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!