Praca Dyplomowa - Magisterska
Total Page:16
File Type:pdf, Size:1020Kb
Wydział Informatyki i Zarządzania kierunek studiów: Informatyka specjalność: Systemy informacyjne Praca dyplomowa - magisterska Procedural heightmap generation for level of detail purposes Odyseusz Spiridis słowa kluczowe: procedural heightmap generation Krótkie streszczenie: W poniższej pracy zostaną ocenione, pod względem szybkości generowania, dwa rodzaje shaderów. opiekun .................................................. ....................... ....................... pracy Tytuł/stopień naukowy/imię i nazwisko ocena podpis dyplomowej Ostateczna ocena za pracę dyplomową Przewodniczący .................................................. ....................... ....................... Komisji egzaminu ocena podpis dyplomowego Tytuł/stopień naukowy/imię i nazwisko Do celów archiwalnych pracę dyplomową zakwalifikowano do:* a) kategorii A (akta wieczyste) b) kategorii BE 50 (po 50 latach podlegające ekspertyzie) * niepotrzebne skreślić pieczątka wydziałowa Wrocław 2017 Streszczenie: Praca traktuje o proceduralnym generowaniu zawartości gry z naciskiem na generowane map wysokości w celu stworzenia proceduralnego planetarnego terenu. Aby móc użyć mapę wysokości w algorytmie optymalizującym konkretny typ szumu musi być użyty w celu uniknięcia nieciągłości. Po objaśnieniu szumów, algorytmu optymalizującego oraz dlaczego to GPU zostało wybrane do tego zadania kilka testów wydajności zostanie przeprowadzonych aby sprawdzić który rodzaj shadera daje najlepsze wyniki pod względem szybkości generowania map wysokości mierzonej w, dobrze znanej w branży gier, jednostce klatek na sekundę. Abstract: This master thesis is about procedural content generation with emphasis to heightmap generation in order to create procedural planetary terrain. To use heightmaps in level of detail algorithm certain type of noise have to be used to avoid discontinuities. After explanation of noises, level of detail and why GPU is used in this task several benchmarks will be run to test what type of shader gives the best results in term of heightmap generation speed measured in, well known in graphic industry, frame per second unit. 2 1. Objectives ............................................................................................................................... 4 2. Approach to terrain in games. ................................................................................................. 4 2.1. Terrain in classic games ................................................................................................... 5 2.2. Procedural terrains elements in mainstream games ......................................................... 6 2.3. New approaches to terrain ................................................................................................ 7 3. Procedural generation ........................................................................................................... 12 4. Level of detail ....................................................................................................................... 13 5. Smooth noise ......................................................................................................................... 15 6. GPU and CPU architecture comparison ............................................................................... 19 7. Shaders .................................................................................................................................. 21 8. Test subjects .......................................................................................................................... 23 8.1. Vertex shader.................................................................................................................. 23 8.2. Compute shader .............................................................................................................. 26 9. Benchmark motivation and development ............................................................................. 27 9.1. Motivation ...................................................................................................................... 27 9.2. Development .................................................................................................................. 28 10. Benchmarks........................................................................................................................ 32 10.1. Heightmap generation benchmark .............................................................................. 33 10.1.1. Introduction ......................................................................................................... 33 10.1.2. Results ................................................................................................................. 34 10.2. Real-time heightmap generation benchmark .............................................................. 37 10.2.1. Introduction ......................................................................................................... 37 10.2.2. Results ................................................................................................................. 37 10.3. GPU – driven gravity simulation ................................................................................ 41 11. Tests summary ................................................................................................................... 42 12. Bilbiography ...................................................................................................................... 44 3 1. Objectives First objective of this thesis is to introduce reader to procedural content generation and its potential uses. Main discussion will be about terrain generation with emphasis to procedural planetary terrain however will be shown that procedural generation is suitable not only for terrain generation. In order to fully understand procedural planetary generation classic techniques of terrain creation will be discussed. Also techniques that speed up real time rendering and reduce resources usage will be covered followed by discussion about noises and how to distinguish its properties with examples on real time rendering application . After introduction to artistic side of procedural generation more technical aspects will be expounded. In these paragraphs architecture of modern graphic card and how to use them will be reviewed and explained why, for procedural terrain generation, it’s the best choice. Because graphic card are also programmable but in different way, programs which run on them will be compared and its differences will be explained. At the end tests will be run, in application exclusively written for this thesis, to find what is the fastest way to generate procedural heightmaps which are main building blocks for procedural planetary terrain. Three benchmarks will be run on three different manufacturers of graphic card drivers. These benchmark will give answer what kind of shader to use for particular purpose and how much performance gain will be there on a specific platform. 2. Approach to terrain in games. Games are interactive computer software in which some action takes place. There are many genres of games like racing, strategy or role playing game, but all of them have to be placed in some environment. One of the most important part of any environment is a terrain which can have direct impact on gameplay like in strategy game or purely aesthetical, for example distant mountains as background in racing game. Realistically created terrain is one of main requirement to consider game immersive and realistic if realism is what game is aiming for. Even for arcade games with toonish styling diversified terrain (levels) is advantage since player is not bored with repetitive surroundings. Games focused strictly on some mechanism like soft body physics, which start on flat plane, also benefits from interesting terrain because it easier to interest players who are not up to date with newest technology. See Figure 1 example. Figure 1 BeamNG terrain in early and recent stage of development. Source: bsimracing.com 4 Creation of terrain starts as any other game object with geometry. Classically level artist make terrain or level of game. Flat plane or other generic shape is taken and in prepared editor with pre- defined tools shape of object is changed. Other quite new approach is to generate terrain with some kind of noise with pre-defined properties (eg. amplitude, frequency) without human intervention. There is also something in-between where tiles are pre-made by artist but whole terrain or level is assembled into one piece procedurally. In this master thesis mostly second option, fully procedural terrain is taken into consideration. 2.1. Terrain in classic games As mentioned earlier, in mainstream games the creation of terrain depends mainly on the artist. This process requires making game engine (or using existing one) and editor with friendly graphics user interface, some assets to populate game (like trees, buildings etc.) and of course concept. Example of early stage of terrain development in Unity Engine is shown on Figure 2. As it can be seen artist can use various shaped brushes to add or substract height in certain point. When the geometry is done textures, collision mesh are added, some assets are placed and terrain is ready to host game action. See in Figure 3 example of excellent terrain in one of the most successful role playing game ever made: The Witcher 3 Figure 2 Early stage of terrain development. Source: youtube.com