How to traverse a BSP tree back to front

926 views Asked by At

Hi I am writing a Quake level renderer. I am getting to the point where I need to take transparency into account. I know a binary space partitioner (BSP) tree is formatted in a way that the data is sorted by distance, or at least that is what I heard but I am at a loss for how to achieve this. I have my BSP tree built and my PVS decoded.

Do I: 1. Figure out what leaf I am in. 6 for example. 2. Render from max to leaf 6, granted that these leaves are in my frustum and PVS. 3. Render from min to leaf 6, again taking the PVS and frustum into account.

Is this not how a BSP tree works?

So that is question #1. Question number two deals with the PVS. I know in the old days, when space was an issue a PVS was great because it was compressed. The way I have it now, I don't decompress the PVS every time I render a frame, I do it once and store the leaves' visibility in a vector which I traverse during rendering. Does this make sense or is it counterproductive?

So again to recap, can I assume a BSP tree is structured so that the leaves are already sorted by distance and at leaf 6 (of 9 total leaves), I should render 9, 8, 7, 6, 1, 2, 3, 4, 5 (assuming all 9 are visible in leaf 6's PVS) like that again taking into consideration the PVS and frustum.

Thank you.

1

There are 1 answers

0
Sebastian Mach On

To render back to front I would propose to first traverse/recurse the node the camera is in (the near nodes). Once you are done, you traverse the far nodes.