Game Development Reference
In-Depth Information
Finally, we compute the corners of the visible extent in WGS84 coordinates.
upper left = D 1 ( c + s ( n
e ))
upper right = D 1 ( c + s ( n + e ))
lower left = D 1 ( c + s (
n
e ))
lower right = D 1 ( c + s (
n + e ))
In the fragment shader, a ray is cast from the eye through each fragment in
the depth plane. If the fragment does not intersect the ellipsoid, the fragment is
discarded as shown in Figure 3.6(b) . The result is the globe's depth is replaced
with the depth plane's depth, which allows objects on the front side of the globe
to pass the depth test and those on the backside to fail without z-fighting or
tessellation differences between image tiles and vector data. This is like backface
culling, except it doesn't require the primitives to be backfacing; for example, a
model of a satellite works with the depth plane but does not work with backface
culling alone.
We originally used a technique based on backface culling. First, we rendered
the tiles without depth. Next, we rendered polygons and polylines on the ellip-
soid's surface without depth, and with backface culling implemented by discarding
in the fragment shader based on the ellipsoid's geodetic surface normal. Finally,
we rendered the tile's depth. Like the depth plane, this did not require writing
gl_FragDepth ; however, it had created a shortcoming in our API. Users needed
to specify if a polygon or polyline was on the surface or in space. The depth
plane works in both cases except for the rare exception of polylines normal to
and intersecting the ellipsoid. The backface-culling technique also relies on two
passes over the tiles, which increases the number of draw calls. This is a major
WebGL bottleneck.
3.6
Conclusion
As long-time C++ and desktop OpenGL developers, we have found JavaScript
and WebGL to be a viable platform for serious graphics development. We hope
this chapter provided both inspiration for what is possible with WebGL, and
concrete techniques for globe rendering that are well-suited to WebGL. To see
these techniques in action, see our live demos at http://cesium.agi.com.
3.7
Acknowledgments
We thank Matt Amato, Norm Badler, Wolfgang Engel, Scott Hunter, and Kevin
Ring for reviewing this chapter. We especially thank Frank Stoner for deriving
the equations for the depth plane.
 
Search Nedrilad ::




Custom Search