| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
Rendering
the Great Outdoors: Detecting Occlusion To detect if an object is occluded, we will utilize the object’s bounding volume. To find out if the object is inside of the occlusion frustum, we’ll make a simple test to check if its bounding sphere is inside of the frustum. Figure 8 shows possi-ble situations that may arise. Here we see that only sphere C passed the test and is fully occluded. Listing 3 shows the func-tion that may be used for such a computation. This process detects whether a bounding sphere is occluded. It’s fast, but not as accurate as detection using bounding boxes. With this technique, some objects may be detected as visible after the bounding sphere test succeeds, but their bounding box is still fully occluded, so we would end up rendering them even though they’re fully occluded. Figure 9 illustrates this possibility.
Detecting if the bounding box is inside the occlusion frus-tum is another very simple task: detect if all eight corner points of the bounding box are inside of the frustum (Listing 2). Note that we use oriented bounding boxes in world coor-dinates, so we must transform local AABBs to world OBBs (as explained previously). If any vertex is outside of the volume, the box is not occluded. This test can take eight times more dot products than the sphere test, so it is less efficient. Ideally you would use it only when you detect that the center of the bounding sphere is inside the occlusion frustum but the sphere is still not occluded. This minimizes the chances of wasting time checking box-versus-frustum collision, at the same time getting more accurate occlusion tests, resulting in fewer objects being rendered.
Editing Support Computing the occlusion volume and detecting whether an object is occluded is half of the work that needs to be done. Another task is finding a way to edit occluders comfort-ably in an evolving 3D scene during development. It may be done in several ways; I’ll discuss some of them here. Editing
occlusion volumes in a modeling package.This is a con-venient way of starting
with occluders quickly and testing func-tionality. You may use 3DS Max,
Maya, or whatever modeling program you prefer, to build an occluder skeleton
from vertices and faces and import that into your engine. Integrating
an occluder editor into your game editor.This is a harder way to do it,
but it’s preferable over editing in a model-ing package. The geometry
inside occluders may change, and occluders must match geometry in order
to be effective, so an “edit and see” approach is the best bet here. Because
an occluder is simply a convex hull, once you’ve implemented and tuned
your convex hull code, you can call it with a set of points and you’ve
got it. Figures 10 shows occlusion techniques in a real game project, including numbers about rendered triangles. Note that the terrain is specially modeled so that occlusion is efficient; it con-tains high hills that are suitable for occluding objects behind them. But the areas of possibility for occluder utilization are much wider: cities with plenty of buildings, fences (solid, not transparent), and so on.
Finally, fine-tune editing support by visually displaying occluders in edit mode while designing your missions or modi-fying the occluder’s shape in the editor. Take It Outside This article
provides some insight into rendering possibilities for outdoor scenes,
and shows some new directions for optimizations. The model described here
has worked — and continues to work — for games I have been working on
(used with other HSR techniques, such as sectors and portals) and has
undergone many changes to get to this point. As we contin-ue to improve
our methods for rendering all kinds of environ-ments in games, soon there
will be no boundaries as to what kinds of worlds we can provide players.
|
|||||||||||||||||||||||||||||||||||
|
|