6
Practical Algorithm for Unlimited Scale Terrain Rendering JAN VANEK, BRUNO JEZEK Faculty of Military Health Sciences University of Defence Trebesska 1575, 50001 Hradec Kralove CZECH REPUBLIC [email protected] http://www.vojenskaskola.cz/school/ud/fmhs/Pages/default.aspx Abstract: - The paper presents an algorithm for rendering digital terrain models of unlimited scale and detail. The algorithm is straightforward and simple to implement. It integrates easily with rendering of other geographical data. It has minimal CPU requirements as it harnesses the power of modern graphics processing units. It has implicit triangle budget and provides stable frame rates. Key-Words: Terrain Rendering, GPU, Triangulated Network, MIP-mapping, Level of Detail 1 Introduction Terrain visualization is a task taking place in all geographic information systems. Very large datasets are often processed and visualized in real-time. Although the performance of hardware continually increases, it is necessary to optimize the form and the amount of terrain information in order to obtain sufficient frame rates during visualization. New developments in graphical hardware and its versatility and programmability bring new opportunities and needs to redesign rendering algorithms. This paper proposes an algorithm designed to take advantage of programmable graphics hardware, to be simple and easy to implement, and to handle unlimited terrain detail and scale. 2 Existing methods The first terrain rendering algorithms, such as [1], [2] or [3], were specifically optimized for particular hardware and were not based on polygonal models. Non-polygonal approaches were used by [4], [5] or [6] even rather recently, though with a limited success. The 1990s marked a significant spread of triangle and z-buffer based rendering pipeline in practical virtual reality applications. At the same time, hardware acceleration of the pipeline by GPUs (graphics processing units) became commercially successful. Because of the limited memory resources of the GPUs and relatively low difference in performance between CPUs and GPUs very sophisticated algorithms and data structures were designed to optimize the rendered triangulated network. In the recent years, however, the GPUs have reached computational performance several orders of magnitude greater than that of CPUs, so the algorithms must mainly feed the GPU with data and use the CPU as little as possible. The triangulated network does not have to be optimal as long as it is sufficiently dense [7]. Some authors (e.g. [8]) also stress the importance of keeping rendering time budget, in which respect complex algorithms are contra productive. In general, all algorithms attempt to solve the problem of triangle count reduction by rendering a triangulated network with continuously changing level of detail so that all triangles have a similar size in perspective projection. The most efficient triangulated network is generated by algorithms such as [9], [10], [11] or [12], which are based on triangulated irregular networks. However, these algorithms are also the most demanding in terms of data structure and manipulation complexity, which does not correspond well with the hardware accelerated rendering paradigm. Some improvement is introduced by algorithms proposed in [13], [14], [15] or [16]. These use triangulated regular networks and simpler data arrangements, but they still work on a per-triangle basis, which is CPU demanding and requires frequent GPU memory updates. The methods described in [7], [17], [18], [19], [20] and [21] provide further improvement by splitting terrain in form of a triangulated regular elevation grid into tiles, thus handling batches of compact data and even allowing for out-of-core rendering. Recent Researches in Circuits, Systems, Communications and Computers ISBN: 978-1-61804-056-5 247

Practical Algorithm for Unlimited Scale Terrain Rendering

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Practical Algorithm for Unlimited Scale Terrain Rendering

Practical Algorithm for Unlimited Scale Terrain Rendering

JAN VANEK, BRUNO JEZEK Faculty of Military Health Sciences

University of Defence Trebesska 1575, 50001 Hradec Kralove

CZECH REPUBLIC [email protected] http://www.vojenskaskola.cz/school/ud/fmhs/Pages/default.aspx

Abstract: - The paper presents an algorithm for rendering digital terrain models of unlimited scale and detail. The algorithm is straightforward and simple to implement. It integrates easily with rendering of other geographical data. It has minimal CPU requirements as it harnesses the power of modern graphics processing units. It has implicit triangle budget and provides stable frame rates. Key-Words: Terrain Rendering, GPU, Triangulated Network, MIP-mapping, Level of Detail 1 Introduction Terrain visualization is a task taking place in all geographic information systems. Very large datasets are often processed and visualized in real-time. Although the performance of hardware continually increases, it is necessary to optimize the form and the amount of terrain information in order to obtain sufficient frame rates during visualization. New developments in graphical hardware and its versatility and programmability bring new opportunities and needs to redesign rendering algorithms. This paper proposes an algorithm designed to take advantage of programmable graphics hardware, to be simple and easy to implement, and to handle unlimited terrain detail and scale. 2 Existing methods The first terrain rendering algorithms, such as [1], [2] or [3], were specifically optimized for particular hardware and were not based on polygonal models. Non-polygonal approaches were used by [4], [5] or [6] even rather recently, though with a limited success. The 1990s marked a significant spread of triangle and z-buffer based rendering pipeline in practical virtual reality applications. At the same time, hardware acceleration of the pipeline by GPUs (graphics processing units) became commercially successful. Because of the limited memory resources of the GPUs and relatively low difference in performance between CPUs and GPUs very sophisticated algorithms and data structures were designed to optimize the rendered triangulated network. In the recent years, however, the GPUs

have reached computational performance several orders of magnitude greater than that of CPUs, so the algorithms must mainly feed the GPU with data and use the CPU as little as possible. The triangulated network does not have to be optimal as long as it is sufficiently dense [7]. Some authors (e.g. [8]) also stress the importance of keeping rendering time budget, in which respect complex algorithms are contra productive.

In general, all algorithms attempt to solve the problem of triangle count reduction by rendering a triangulated network with continuously changing level of detail so that all triangles have a similar size in perspective projection.

The most efficient triangulated network is generated by algorithms such as [9], [10], [11] or [12], which are based on triangulated irregular networks. However, these algorithms are also the most demanding in terms of data structure and manipulation complexity, which does not correspond well with the hardware accelerated rendering paradigm.

Some improvement is introduced by algorithms proposed in [13], [14], [15] or [16]. These use triangulated regular networks and simpler data arrangements, but they still work on a per-triangle basis, which is CPU demanding and requires frequent GPU memory updates.

The methods described in [7], [17], [18], [19], [20] and [21] provide further improvement by splitting terrain in form of a triangulated regular elevation grid into tiles, thus handling batches of compact data and even allowing for out-of-core rendering.

Recent Researches in Circuits, Systems, Communications and Computers

ISBN: 978-1-61804-056-5 247

Page 2: Practical Algorithm for Unlimited Scale Terrain Rendering

Some authors tackle the problem using quite different approaches. [5] and [22] combine classic techniques with image based rendering. [23] renders the terrain by projecting a single triangulated grid onto it from the viewpoint.

With few exceptions, such as [8] or [24], authors do not take rendering of other geographical data into account, although they are with terrain data closely linked. Complicated methods and especially complex data structures make an integration of an algorithm to a larger system of geographical data visualization difficult, impractical and costly. Simple algorithms not only tie in better, they can actually also perform better, especially on the current generation of hardware that allows for decoupling of triangulation and terrain data. 3 Proposed Method Most of the currently used and hardware acceleration-friendly algorithms, such as [20] or [21], display digital terrain models in form of regular elevation grid triangulation split into tiles, which change their level of detail in correspondence with the viewpoint movement.

As the viewpoint moves, the level of detail of the tiles increases in the movement direction and decreases in the other. For example, as the camera moves from the tile 13 in Fig.1 to the tile 8, the level of detail increases in tiles 3, 7 and 9 and decreases in tiles 12, 14 and 18. If the terrain data is sampled from a texture based on planar vertex coordinates, the very same effect can be achieved by translating all the vertices of all tiles by the tile height. So the terrain can be rendered using a fixed triangulated network with the following properties: • It moves with the viewpoint • Its connectivity is fixed, its detail decreases

with increasing distance from the viewpoint • The elevation of its vertices is modified by

sampling from a texture This premise is the starting point of the proposed

method. The level of detail of a grid split into tiles does

not decrease gradually and areas of the same distance from the viewpoint but different levels of detail exist in the final triangulation. In an ideal case all visible triangles should have the same screen-space size. Algorithms that optimize the level of detail based on screen-space metrics must modify vertex connectivity when the view changes, which is unsuitable for hardware accelerated rendering and

creates a high latency when a user looks around. The proposed algorithm generates a triangulated network that, to a degree, maintains similar screen-space size of triangles, but it does not use screen-space metrics. The network is absolutely fixed in terms of GPU input data and thus guarantees stable frame rate even during viewpoint change. It is continuous without any cracks or T-vertices.

Fig.1: Level of detail dependence on viewpoint

During rendering, the triangulated network processed by a GPU is transformed from the input data into triangles rasterized on screen. The proposed algorithm consists of two parts. The first generates the input data and is executed on CPU once before rendering loop begins. The second transforms the input data into terrain coordinates and is executed as a vertex shader on GPU for every rendered frame.

Vertices of the proposed triangulated network are positioned above concentric circles with the center in the orthogonal projection of viewpoint into the ↔ plane of the terrain coordinate system and their coordinates on the -axis are sampled from an elevation grid based on the [ , ] coordinates. See Fig.2.

Fig.2: Proposed triangulated network

A triangulated network is passed to a GPU as a vertex and index array. The vertex data serve as the

Recent Researches in Circuits, Systems, Communications and Computers

ISBN: 978-1-61804-056-5 248

Page 3: Practical Algorithm for Unlimited Scale Terrain Rendering

input to the transformation into terrain coordinates and in the proposed triangulated network vertices consist of polar coordinates: normalized radius of the circle the vertex lies on and angle between the ray from the center to the vertex and the positive -axis. Fig.3 on the left shows the network with five circles in the terrain coordinates, on the right there is the same network plotted in the polar coordinates of the input data.

With the increasing radius the number of vertices on a circle grows by 6 starting at the hexagon of the circle 0, so the number of vertices at the circle is 6 , = 1, … , , where is the number of all circles of the network and specifies its overall detail. Then the total number of vertices is obviously 1 + ∑ 6 = 1 + 3 ( + 1).

ϕ

ϕ

1

Fig.3: Input vertex coordinates

The following pseudo code creates the vertex array for the given number of circles .

procedure Create vertices ( ) add vertex [0; 0] for i from 1 to for from 0 to 6 − 1 = =

add vertex [ ; ] end for end for i end procedure

The connectivity of the network is described by an index array, the most efficient interpretation of which is a triangle strip. The proposed triangulated network can be expressed as a single triangle strip, though at the cost of adding triangles degenerated to a line. The annulus between the circles and + 1 is covered by six triangle strips, apiece connecting + 1 vertices of the circle with + 2 vertices of

the circle + 1. Each of the first five strips is appended a degenerated triangle connecting it to the next. The last strip is linked to the first strip of the next annulus by three degenerated triangles.

The following pseudo code generates an index array this way for the given number of circles . The variable , respectively , denotes the first index of the currently processed annulus at the circle , respectively circle + 1. The variable , respectively , denotes the first index of the currently processed strip of the current annulus at the circle , respectively circle + 1. See Fig.4, where an example of a current annulus is in full line and of a current strip is dashed.

procedure Create indices ( ) for i from 1 to 6 add index add index 0 end for i add index 1 add index 1 = 1 = 7 for i from 2 to − 1 = = add index for from 0 to 5 for from 0 to − 1 add index + add index + + 1 end for = + − 1 = + end for remove the last 2 indices add index add index add index end for remove the last index end procedure

The number of indices in an index array created this way is 13 + ∑ (12i + 2) = 6n − 4n− 3 , and the number of triangles defined by it is two less, as is always the case with a triangle strip.

Recent Researches in Circuits, Systems, Communications and Computers

ISBN: 978-1-61804-056-5 249

Page 4: Practical Algorithm for Unlimited Scale Terrain Rendering

Fig.4: First indices of an annulus and a strip

Vertex coordinates in the terrain coordinate system are derived from the [ ; ] input data in a vertex shader. The and coordinates calculated from a parametric equation of a circle, the coordinate is sampled from an elevation grid stored in a texture using the calculated and coordinates. The circle radii are normalized in the input data to values equidistantly ranging from 0 for the central vertex to 1 for outer-most circle. In the vertex shader they are transformed to the interval ⟨0; ⟩, where is the parameter that defines visibility range. If the radii were equidistant in the interval too, the level of detail would be the same throughout the triangulated network. The proposed algorithm redistributes the radii so that the circles are equidistant when projected on a spherical cap corresponding to the viewpoint and visibility range. Half of the central angle of the cone above the spherical cap is = arctan , where P is the viewpoint and P is its coordinate in the terrain coordinate system. The radius of the circle , above which is the currently shaded vertex, is then given as = P tan( ), see Fig.5. Finally, the and coordinates of the vertex in the terrain coordinate system are = P + cos and = P + sin .

Fig.5: Radius computation in vertex shader

Fig.6 shows the circle distribution for two viewpoints with P = 10 and P = 100. It can be

seen that for low viewpoints (upper image) individual vertices of the circles in distant parts of the terrain represent large sections of the terrain in the direction from viewpoint. As a result, continual viewpoint translation causes an undesirable undulation of the displayed terrain.

Fig.6: Circle distribution for different viewpoints

Fig.7 shows three consecutive frames of the triangulated network translation and the resulting apparent rise and depression of a terrain protuberance. The elevation grid is indicated by full lines, half of the network in dashed. The arrows represent the viewpoint and the direction of its motion. The intensity of the undulation depends on the relative amplitude of the terrain features and the ratio of their wavelength to the spacing of the circles that cover them.

Fig.7: Terrain undulation with viewpoint change

The proposed algorithm mitigates the problem to an acceptable level by additional sampling of the elevation texture per vertex and by the use of MIP-mapping.

For the vertex at the circle of radius the elevation is sampled between the radii and . The number of samples is calculated so that it represents how many times the sampled range is larger than the radius of the first circle. Therefore = . The number of samples is

+ 1

1 1

P

P

Recent Researches in Circuits, Systems, Communications and Computers

ISBN: 978-1-61804-056-5 250

Page 5: Practical Algorithm for Unlimited Scale Terrain Rendering

further capped by a predefined limit so that the computational load on the GPU remains under control. The final vertex coordinate is an average of the samples.

MIP-mapping is a texturing technique used in hardware accelerated rendering for anti-aliasing and computational optimizations. A texture is extended with a pyramid of textures, each of which is averaged from the previous at half its size. During sampling the pyramid level can be specified by a coefficient from 0 for the base texture in full resolution to for the smallest one; = log , where is the texture resolution, i.e. the maximum of width and height. If is not an integer the GPU calculates a weighted average of the two closest levels. The algorithm determines the coefficient so that the number of texture samples per the interval between the circle radii and is the same as per the radius of the first circle, that is = log .

Because of the additional sampling and MIP-mapping, the level of detail decreases rapidly with the increasing distance from the viewpoint. The algorithm is further modified not to excessively accent the detail close to the viewpoint at the expense of the distant one by using f(P ) instead of P in the calculations. By the choice of the function f it is possible to reach an adequate compromise between the level of detail in the proximity of the viewpoint and the rate of its decline, as can be seen in Fig.8, where the upper image shows a terrain with f(P ) = P and the lower one with f(P ) = max{5P , 50}.

Fig.8: Level of detail decrease rate

4 Conclusion The proposed algorithm has been implemented and tested both on artificial terrain models and on real datasets. The artificial terrains were rendered with detail and scale limited only by the floating point precision of viewpoint coordinates and z-buffer. Scale-to-detail ratios of six orders of magnitude were achieved easily. The algorithm was also applied to spherical terrain models with only a single additional transformation in vertex shader. The simplicity of the algorithm allowed for its effortless integration with different texturing techniques to render real terrains of hundreds of thousands square kilometers in scale and square meters in detail. The biggest drawback of the algorithm is the terrain undulation with viewpoint motion, which can, however, be managed. References: [1] G. S. P. Miller, “The definition and rendering

of terrain maps,” in Proceedings of the 13th annual conference on Computer graphics and interactive techniques, New York, NY, USA, 1986, pp. 39-48.

[2] J. Kaba, J. Matey, G. Stoll, H. Taylor, and P. Hanrahan, “Interactive terrain rendering and volume visualization on the Princeton Engine,” in Proceedings of the 3rd conference on Visualization ’92, Boston, Massachusetts, 1992, pp. 349-355.

[3] J. Kaba and J. Peters, “A pyramid-based approach to interactive terrain visualization,” in Proceedings of the 1993 symposium on Parallel rendering, San Jose, California, United States, 1993, pp. 67-70.

[4] B. Lloyd and P. Egbert, “Horizon occlusion culling for real-time rendering of hierarchical terrains,” in Proceedings of the conference on Visualization ’02, Washington, DC, USA, 2002, pp. 403-409.

[5] H. Qu, M. Wan, J. Qin, and A. Kaufman, “Image based rendering with stable frame rates,” in Proceedings of the conference on Visualization ’00, Los Alamitos, CA, USA, 2000, pp. 251-258.

[6] M. Wan, H. Qu, and A. Kaufman, “Virtual flythrough over a voxel-based terrain,” in Proceedings of the IEEE Virtual Reality, Washington, DC, USA, 1999, pp. 53-60.

[7] F. Losasso and H. Hoppe, “Geometry clipmaps: terrain rendering using nested regular grids,” ACM Trans. Graph., vol. 23, no. 3, pp. 769-776, 2004.

[8] C. Zach, S. Mantler, and K. Karner, “Time-

Recent Researches in Circuits, Systems, Communications and Computers

ISBN: 978-1-61804-056-5 251

Page 6: Practical Algorithm for Unlimited Scale Terrain Rendering

critical rendering of discrete and continuous levels of detail,” in Proceedings of the ACM symposium on Virtual reality software and technology, New York, NY, USA, 2002, pp. 1-8.

[9] K. Baumann, J. Döllner, and K. Hinrichs, “Integrated multiresolution geometry and texture models for terrain visualization,” in Proceedings of Joint Eurographics - IEEE TVCG Symposium on Visualization, 2000, pp. 157–166.

[10] P. Cignoni, F. Ganovelli, E. Gobbetti, F. Marton, F. Ponchio, and R. Scopigno, “BDAM — Batched Dynamic Adaptive Meshes for High Performance Terrain Visualization,” Computer Graphics Forum, vol. 22, no. 3, pp. 505-514, 2003.

[11] D. Cohen-Or and Y. Levanoni, “Temporal continuity of levels of detail in Delaunay triangulated terrain,” in Proceedings of the 7th conference on Visualization ’96, Los Alamitos, CA, USA, 1996, pp. 37-42.

[12] H. Hoppe, “Smooth view-dependent level-of-detail control and its application to terrain rendering,” in Proceedings of Visualization ’98, Los Alamitos, CA, USA, 1998, pp. 35-42.

[13] M. Duchaineau, M. Wolinsky, D. E. Sigeti, M. C. Miller, C. Aldrich, and M. B. Mineev-Weinstein, “ROAMing terrain: real-time optimally adapting meshes,” in Proceedings of the 8th conference on Visualization ’97, Los Alamitos, CA, USA, 1997, pp. 81-88.

[14] P. Lindstrom, D. Koller, W. Ribarsky, L. F. Hodges, N. Faust, and G. A. Turner, “Real-time, continuous level of detail rendering of height fields,” in Proceedings of the 23rd annual conference on Computer graphics and interactive techniques, New York, NY, USA, 1996, pp. 109-118.

[15] P. Lindstrom and V. Pascucci, “Visualization of large terrains made easy,” in Proceedings of the conference on Visualization ’01, Washington, DC, USA, 2001, pp. 363-371.

[16] P. Lindstrom and V. Pascucci, “Terrain Simplification Simplified: A General Framework for View-Dependent Out-of-Core

Visualization,” IEEE Transactions on Visualization and Computer Graphics, vol. 8, no. 3, pp. 239-254, Jul. 2002.

[17] J. S. Falby, M. J. Zyda, D. R. Pratt, and R. L. Mackey, “NPSNET: hierarchical data structures for real-time three-dimensional visual simulation,” Computers & graphics, vol. 17, no. 1, pp. 65-69, 1993.

[18] E. Gobbetti, F. Marton, P. Cignoni, M. Di Benedetto, and F. Ganovelli, “C-BDAM-Compressed Batched Dynamic Adaptive Meshes for Terrain Rendering,” Computer Graphics Forum, vol. 25, no. 3, pp. 333-342, 2006.

[19] D. Koller, P. Lindstrom, W. Ribarsky, L. F. Hodges, N. Faust, and G. Turner, “Virtual GIS: A Real-Time 3D Geographic Information System,” in Proceedings of the 6th conference on Visualization ’95, Washington, DC, USA, 1995, pp. 94-100.

[20] B. D. Larsen and N. J. Christensen, “Real-time Terrain Rendering using Smooth Hardware Optimized Level of Detail,” in Journal of WSCG, Vol.11, No.1, Plzen, Czech Republic., 2003, vol. 11.

[21] J. Schneider and R. Westermann, “GPU-Friendly High-Quality Terrain Rendering,” in Journal of WSCG, Vol.14, Plzen, Czech Republic., 2006.

[22] B. Chen, I. I. J. Edward Swan, E. Kuo, and A. Kaufman, “LOD-sprite technique for accelerated terrain rendering,” in Proceedings of the conference on Visualization ’99: celebrating ten years, Los Alamitos, CA, USA, 1999, pp. 291-298.

[23] C. Dachsbacher and M. Stamminger, “Rendering Procedural Terrain by Geometry Image Warping,” in Proceedings of Eurographics Symposium on Rendering 2004, 2004.

[24] J. Andersson, “Terrain rendering in frostbite using procedural shader splatting,” in ACM SIGGRAPH 2007 courses, Course 28: Advanced real-time rendering in 3D graphics and games, New York, NY, USA, 2007, pp. 38-58.

Recent Researches in Circuits, Systems, Communications and Computers

ISBN: 978-1-61804-056-5 252