2) There is also Painter's algorithm to remove non-visible surfaces. This algorithm described in many good graphics books. But i think it might be too slow for rendering small polygons. In this case i recommend you to use z-buffer (render terrarian with just updating z-buffer, and then render all objects with normal z-buffer testing), or, if your terrarian polygons will be as small, as object's polygons, you can make a rendering list and sort all (terrarian and objects) polygons by av. z-value and then render them in back-to-front order. That's the way we used in our little 3d landscape engine (look at the demo http://codexorg.webjump.com/eng/codex/main.htm )
Ideas for Hidden Surface Removal
http://codexorg.webjump.com
But you can accelerate this (as maded in all 3d games, i belive) if you will render all faces you know will not intersect with each other (terrarian surface, for example) with just z-buffer update mode (no comparison)
and then render all other objects with z-buffer compare mode (as i already describe in previous posting)
http://codexorg.webjump.com
To start out, the world will be made up of two discrete types of objects. The first will be a simple triangulated heightfield as the underlying terrain. The second will be structures of arbitrary geometry resting on that terrain (houses, towers, bridges, etc...). In the end, I'm hoping to turn this engine into a role playing game of some variety. Well, as for VSD, I thought that using separate methods for the two different types of geometry would be the best approach.
For the terrain I thought I'd just test where the viewing frustum intersects the terrain and render everything within those boundries. That's the fastest method I could figure out to render an arbitrary heightfield.
As for the structures that rest on top of the terrain, I came up with a sort of two part VSD method. It involves breaking them up into smaller "chunks", each being of relatively small size and constant texture and then computing the bounding spheres/boxes for these chunks and testing them against the viewing frustum. As these primitives are easier to clip and this could quickly eliminate the portions of the structure that are outside of the viewable area. Then I could use front-side (done before transformation and lighting) backface removal on the remaining polygons to come up with a smaller visible set. The problem with this method is that it only culls out the polygons that either are outside the viewable area, or not facing the user. It does nothing for polygons that are occluded by other polygons. Here is where I was really wondering if anybody had any better ideas or even possible improvements on my idea.
Zbuffer and only frustum really isn't enough to keep large outdoor environments fast.
I've created antiportal support which act as occluders, you can place them inside buildings for example. everything in the volume behind the antiportal won't be processed by my engine. Also it is important to create some sort of hierarchies in your world. Like octrees. Split up your landscape into sectors, and split these large sectors up into smaller ones etc etc.
Then check the boundingboxes of the large sectors against the frustum and occluders, if they are not visible then you can skip all elements inside the sector. If it however is visible you check the smaller sectors within this sector etc...
It's also cool to automaticaly generate occluders inside high hills and mountains. This really can speed things up. Also level of detail is very important on landscapes. There are many ways to do this.
I hope I helped you a bit in the good direction with this message.
- John vd Burg
Programmer of Oxygen3D http://www.mysticgd.com/oxygen3d.htm