5

I have a BSP tree loaded into memory. I first find out what leaf I am in. Next, I decode the PVS. Then, I run through each region in that PVS and see if it lies within my frustum.

I have been told that this is the incorrect way to render and that I should actually be doing a back to front rendering by traversing the BSP tree. How exactly do I do this? I have seen a number of different methods of doing this, that's why I ask.

For instance, the Quake 3 BSP rendering says: Traverse the BSP to determine in which leaf the camera is positioned. Retrieve and decompress the PVS for this leaf, iterate through PVS and mark leaves in the BSP. Traverse the BSP near to far If a Node is not marked, skip it. Test the Node Boundary Box against the Camera Frustrum. Add the current leaf to the rendition list

Is this still the standard way it is done today or at least for simpler games.

tomdemuyt
  • 4,572
  • 2
  • 31
  • 60
  • front to back is the preferred rendering nowadays; back to front was only necessary for the painter's algorithm (i.e. before compressed, high-bandwidth z-buffers made them preferable). front-to-back allows for early z-rejects (everything behind what you've drawn will be rejected, in modern hardware, before much work other than determining and checking its z value is done). I'll comment again when I get a bit more. – std''OrgnlDave Jan 16 '12 at 15:07

1 Answers1

1

As OrgnlDave said:

When you draw a primitive, the pixels placed in front of the z-buffer will be paint and the program shader will be executed. But if the pixel is behind the scene then the pixels is rejected. There is no obligation to made such of drawing, front to back, but the gain in performance is worst it.

However if you using blend object you will need to draw this one after every solid object and do it from back to front. Because you need to blend the color with the object placed just after.

AxFab
  • 1,157
  • 8
  • 11
  • @OrgnlDave Well Said. Pixel fill is expensive. It is the one point of the pipeline where write access is needed to a shared resource. The Vertex shaders can run in parallel and generate geometry lists simultaneously however when the Pixel Shader is writing to the Color Buffer or the Z Buffer, only one program can access the same memory at a time. Render Opaque geometry from front to Back, to eliminate pixel fill on objects that are covered up, and then render Non-Opaque geometry from back to front, so the obscured geometry will have a weight in the alpha blend. – Dan Jun 03 '12 at 19:02