0

I am trying to understand the Quake3's source code.

Does anyone know what the function R_MarkLeaves() in ( tr_world.c) file is doing?

I think this has to do something with portal culling ?

I need to know how this works so i can also implement this in my code to speed up the rendering.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
revolutionary
  • 3,314
  • 4
  • 36
  • 53

1 Answers1

0

R_MarkLeaves() marks the precomputed PVS (potentially visible set) of leaf nodes (convex hulls) given the location of the camera / eye. The BSP tree traversal solves the drawing order problem (depth sorting) for software rendering, but at the time, it still resulted in too much overdraw. The PVS is used to prune leaf nodes that are demonstrably not visible from the current node / position.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90
  • Hi Brett, Thanks for your reply. So this means that there is a better way to solve the overdraw problem ? Because i am already checking the cluster-visibility before drawing each leaf, although without using R_MarkLeaves(), but I see that even some geometry behind the opaque walls which should not be visible is not being culled. ( e.g. in the q3dm01.bsp map, when I am in the corridors, my code still draws the dragon tounge in the hallway which is not visible) Am i missing something in the PVS rednering or is that the best that the quake3 bsp does ? – revolutionary Mar 05 '12 at 00:08
  • @user565223 - I seem to recall that some geometry, like the 'dragon tongue', are Bezier surfaces - i.e., subdivided at run/load-time. I doubt they are part of the static render, because it would mean an explosion in the size of the precomputed geometry sets. These elements are probably rendered like the other dynamic elements (players, pickups, etc.). If a region that contains such elements is potentially visible, it's quicker and easier to let the HW take care of it. – Brett Hale Mar 05 '12 at 06:49
  • Thx Bret, yes you are right, that is a Bezier surface. I pre-compute all the geomtery of my bezier surface at load-time. when I render, some parts of the map, show the bezeir-surface as potentially visible but the surface is infact hidden but still gets rendered. And its quite expensive to render the surface because it contains a lot of faces. What do you mean by let HW take care of it ? Because my pre-calculated bezeier curve is passed to the GlDrawArrays type function. – revolutionary Mar 06 '12 at 12:59
  • The Bezier surface might be subdivided into hundreds of triangles. If these were subdivided into convex hulls, it would result in lot of extra BSP tree nodes, and add a lot of extra PVS entries. Since such surfaces are used sparingly, and Q3 requires hardware support anyway, it's not cost-effective. By default, GL rendering will do the right thing with the depth buffer test, but the HW at the time might have benefited from switching between `glDepthFunc(GL_ALWAYS)` and `GL_LESS` mode (default). Is this happening? – Brett Hale Mar 06 '12 at 13:58