Faculty of Computer Science and Management Field of study: COMPUTER SCIENCE Specialty: COMPUTER ENGEENERING

Master Thesis

METHODS FOR IMPLEMENTING GAMES BASE ON REAL MAP DATA

Sarper TEMEL

keywords: Unity 3D Real-Location Based Games Real World Environment short summary: Implementing the real map data into the Unity with possible methods and testing with Windows Graphics which are supported by Unity.

Supervisor Dr.inż.Marek.Kopel...... ……………………. Title/ degree/ name and surname grade signature

The final evaluation of the thesis Przewodniczący Komisji ...... ……………………. egzaminu Title/ degree/ name and surname grade signature dyplomowego

For the purposes of archival thesis qualified to: * a) Category A (perpetual files) b) Category BE 50 (subject to expertise after 50 years) * Delete as appropriate

stamp of the faculty

Wrocław 2019

1

ABSTRACT Game technology is a big part of our lives. Nowadays, the new tradition is the transfer of the real-world environment to the game engine and making games in this way. It's not just about games. The user can use this technology for their own benefit. For example, users can discover new places they can't go or experience the real world on other major technology AR and VR, every day the emergence of new methods that will lead to the concentration of game programmers in this area. The aim of this master thesis is to transfer methods to the game engine in 3D using real map data and to work on four different Windows graphics APIs to test and compare CPU, GPU and FPS performance. This will allow the user to observe which API is more successful. These APIs are: DirectX 11, DirectX12, Vulkan and OpenGL 4.5. The Unity will be the engine used. Test results will be collected using the official Unity Engine tools.

STRESZCZENIE Technologia gier stanowi dużą część naszego życia. Obecnie nową tradycją stało się przeniesienie środowiska świata rzeczywistego do silnika gry i tworzenie gier w ten sposób. Nie chodzi tylko o gry. Użytkownik może korzystać z tej technologii dla własnej korzyści. Użytkownicy mogą na przykład odkrywać nowe miejsca, których w przeicwnym razie nie mogli by odwiedzić, za pomocą technologii AR i VR, każdego dnia pojawienie się nowych metod doprowadzi do koncentracji programistów gier w tej dziedzinie. Celem tej pracy magisterskiej jest przeniesienie metod do silnika gry w 3D, używając danych o istniejących lokalizacjach oraz praca na czterech różnych grafikach API w systemie operacyjnym Windows, a także przeprowadzenie testu oraz porównanie CPU, GPU i FPS. Pozwoli to użytkownikowi obserwować, które API jest bardziej skuteczne. Te API to: DirectX 11, DirectX12, Vulcan i OpenGL 4.5. Zasosowany silnik to Unity. Wyniki testów będą zbierane przy użyciu oficjalnych narzędzi Unity Engine.

2

CONTENTS ABSTRACT ...... 2 1. INTRODUCTION ...... 5 1.1. Location-based Games ...... 5 2. RESEARCH BACKGROUND ...... 6 2.1. Unity Game Engine ...... 6 2.1.1. Introduction of Unity...... 6 2.1.2. Frame Debugger ...... 7 2.1.3. Profiler Tool ...... 8 2.2. CPU and GPU Optimization in 3D Gaming Platform ...... 8 2.2.1. CPU Optimization in 3D Gaming Platform ...... 9 2.2.2. GPU Optimization in 3D Gaming Platform ...... 9 2.3. Frame Per Second (FPS) ...... 9 2.4. Graphics APIs for Windows ...... 10 2.5. Lighting Performance ...... 10 2.5.1. Realtime Lighting...... 10 2.5.2. Precomputed Realtime GI Lighting ...... 11 2.5.3. Type of Lights ...... 12 2.6. Shadows in Unity ...... 13 2.7. OpenStreetMap ...... 15 3. METHODS ...... 17 3.1. ActionStreetMap ...... 17 3.2. Map-Ity ...... 17 3.3. GO Map 3D Map ...... 19 3.4. Real World Terrain ...... 21 3.5. Mantle Environment System ...... 22 3.6. Platform Unity SDK ...... 23 3.7. Wrld3d Map ...... 25 3.8. SDK ...... 30 4. TEST ENVIRONMENT AND CONFIGURATIONS ...... 35 4.1. Test Environment ...... 35 4.2. Quality Settings Details ...... 35 5. TEST RESULTS ...... 37 5.1. Frame Per Second (FPS) Benchmark ...... 37

3

5.2. CPU Benchmark ...... 39 5.3. GPU Benchmark ...... 42 6. DISCUSSION ...... 47 7. CONCLUSION ...... 49 7.1. Future Work ...... 49 8. BIBLIOGRAPHY ...... 50 8.1. Figure References ...... 52

4

1. INTRODUCTION The rapid increase of data sources nowadays produces a massive map data that needs to be managed. A few decades before, companies start to implement real world environment into the different platforms. Many foundations take a part of the implementing real map data. Such as Google, Tomtom, Micello, Zenrin, DataCom. Unity is so much more than just a game engine. From the user-friendly editor, to the flexibility of C# scripting, powerful and useful applications can be created within a fraction of the time. Unity has now incorporated many methods and tools into engine by collaborating with many companies. However, some of these tools and methods were developed by Unity and some of them by other companies. The game industry is increasing day by day and users would like to gain more experience about real world environment in the games. Based on this idea, companies started spend more time about developing games considering with this idea. Especially, location-based games are becoming more popular and many methods come to exist. Moreover, real time location-based games with AR and VR can be considered. Google has been published new product which is call “Google Glass”. Also, published “Oculus VR”. The purpose of the research is to transfer the real world to the game environment through different implementation methods. The real location based themed games can be run on different platforms. Therefore, each method was tested on four different APIs. The purpose of testing on different APIs is that each API has a different of processor consumption and FPS performance. The graphics details of the game content and fluency of the scenes in the game are the most important criteria. Obviously, real-world themed games cause more CPU consumption. Therefore, at the end of the research, the reader will learn which method performs better on which API and how to make the scene content more efficient and richer.

1.1. Location-based Games Nowadays, computers and have become more popular and wants to experience real world in the games. Location-based game is a type of game which uses the player’s location. Recently, location-based games are played publicly and have become a common type of game for people. GPS technology is used for tracking the player’s current location. For instance, the game Pokémon GO and this type of games have popularisation is unavoidable fact because of the experiencing the real life. [1] Another aspect is the use of location-based games to make life easier. For example, it would be a great advantage for the user to provide a game to be developed for public transport and a tracking system in 3D based on real time location. With the increasing technology and richness of map data, real data-based games, which started to be developed for the first time in the early 2000s, have increased their popularity to the present day and are currently being programmed on many game engines with different methods.

5

2. RESEARCH BACKGROUND In this chapter, general information about Unity Game Engine, elements affecting scene performance and APIs supported by the game engine are mentioned. The implementation methods in the following chapter, also covered by thesis colleague Mr. Ihsan Sabri Senturk for the Unreal Engine 4.

2.1. Unity Game Engine This section gives detailed information about the Unity Game Engine and its tools.

2.1.1. Introduction of Unity “Unity is a cross-platform game engine developed by Unity Technologies, first announced and released in June 2005 at Apple Inc.'s Worldwide Developers Conference as an OS X-exclusive game engine [2].” Nowadays, the game engine is supported on 27 different platforms. With Unity Engine, users can create 2D and 3D games, and engine supports primary scripting in C#, both form of plugin and the game themselves. About 3D games, Unity provides mipmaps, texture compressions for all platforms that the engine supports. Therefore, Engine allows to make pre-processing and create static & dynamic shadows. Another benefits about Unity is official and custom methods are supported by Unity. Regarding the thesis topic, different approaches to the methods will be tested. Advantages of Unity includes; [25] - Biggest benefit is more productive than other engines because in most case Unity uses less memory. - Unity’s best asset is that it does a good job at helping develop 3D game by using custom and official tools and methods. - The engine is supported by 27 platforms. - Applications can be easily developed and shared with people by Unity. - The high-quality visual effects are supported by the engine that eases the game development. The visuals are adaptable on every screen and device without any distortion or compromise with the image quality. The debugging and tweaking are easier with Unity game development because all the game variables are displayed during gameplay, which in turn allow the developers to debug the process at runtime. Disadvantages of Unity includes; [34] - Most commonly known disadvantage is, user can’t access to code directly. - Lighting settings are not as good as other game engines. (e.g. Unreal Engine) - Another weak side of the Unity is, designing the open world games. Editing terrain and object placements are not strong as other engines.

6

- Users can use the engine for free but for better quality settings, must be paid for license.

2.1.2. Frame Debugger The Frame Debugger allows to playback for a running game and check the individual “draw calls” [3] that are used to render that frame. Therefore, the debugger also lets to step through them one-by-one so details about the scene can be checked.

Figure 2.1: View of the Frame Debugger in Unity Engine Render Target option (Figure 2.1) is the toolbar which isolates the red, green, blue and alpha channels for the current state of the Game view. ‘Levels’ The level setting is used to make changes to the brightness of the screen. Red, green, and blue channels are the basic colours that make up the RGB image. “RGB channels roughly follow the colour receptors in the human eye, and are used in computer displays and image scanners [4]”. “If the RGB image is 24-bit (the industry standard as of 2005), each channel has 8 bits, for red, green, and blue—in other words, the image is composed of three images (one for each channel), where each image can store discrete pixels with conventional brightness intensities between 0 and 255. If the RGB image is 48-bit (very high colour-depth), each channel is made of 16-bit images.” [4]. The Figure 2.2 shows that only the red channel is activated.

7

Figure 2.2: ‘Show red channel only’ section is activated

2.1.3. Profiler Tool Unity Engine does not require additional tools for profiling the current status of the scene. Profiler helps to optimize the game and give reports how much time and frame spent in the game. Specifically, CPU, GPU and rendering time performances can be analysed. Making improvement in game performances are the most important thing. By using the profiler, results can be compared and use for the game. [35]

Figure 2.3: Unity Profiler Tool view Average usage of CPU and GPU can be checked bottom part of the tool (Figure 2.3). Additional features allow to obtain more detailed results for each case. For instance, Vertical Synchronization details can be seen on the profiler scene when it is checked. Most efficient way to use profiler tool is, giving the specific running time space and analysing the results.

2.2. CPU and GPU Optimization in 3D Gaming Platform CPU and GPU are the two biggest factors that directly affect the performance of 3D games. The capacity of these two units allows players to have a smoother and better-quality gaming experience. Performance losses in games are prevented by optimization adjustments depending on the capacity of these two units.

8

2.2.1. CPU Optimization in 3D Gaming Platform The CPU (central processing unit) is a brain of the computer. Therefore, CPU directly affects rendering time of the game. Faster CPU helps engine to render the scene smoother and faster. To render objects on the screen, CPU has a lot of processing work to do. For instance, which lights affect object, sending the drawing commands to graphic driver then after graphic card prepares the scene and shows.[28] Each object on the scene can affect the rendering time. If scene has many different visible objects, then rendering time will be much longer. For example, if a scene has a thousand pieces of the same object (a building) and all objects are in a single cage instead of objects that look different, the CPU's performance would be much better. On the other hand, this scenario would be the same in the GPU, but the work done by the CPU to create the thousand objects is significantly higher than GPU. To reduce the CPU’s work; - Combining close objects together. For instance, designing forest, use same type of object. - Every detail on the object could affect CPU usage. Using low quality tiles and textures would affect CPU usage positively. - Disabling some of the features which is provided by engine. (such as shadows, lights) - Optimum post-processing configuration for hardware.

2.2.2. GPU Optimization in 3D Gaming Platform The GPU (Graphics Processing Unit) specialized for display functions. The GPU renders images, videos, scenes. GPU is used for 2D and 3D data but mostly used for rendering 3D and videos. [36] The GPU has too many things to process. The number of edges that is acceptable to ensure good performance depends on the GPU and complexity of the object shaders in the scene. To reduce GPU’s work in the game; - Turning off the Vertical Synchronization directly affects the GPU usage positively. (if the scene runs over 60FPS) - Good configuration of post-processing. - Low quality texturing.

2.3. Frame Per Second (FPS) FPS shows how many images GPU is able to render for each second and the monitor displays it for each second. Basically, frame per second is basic measurement of performance. The facts that directly affects FPS performance; [20] - Antialiasing: In , it is a technology used to improve non- overlapping edge textures. It expresses as 2x AA, 4x AA, 8x AA

9

- Field of View: It is a display angle on the scene. Higher number of fields of view means lower fps. - Lighting/Shadows: High quality shadows negatively affects FPS. - Resolution: The higher resolution provides better quality scene but details of the objects will be higher and it will decrease FPS result. - Texture: Details in objects may adversely affect FPS.

2.4. Graphics APIs for Windows On the Windows operating system, there are 4 different APIs supported by Unity. These APIs are; - Vulkan: It aims to implement high-performance video games in 3D graphics in various platforms. Vulkan, announced in 2015, stands out with its balanced CPU and GPU usage. One of the main reasons for this is that the work that the processor has to do is evenly distributed to the cores. [30] - OpenGL 4.5: It defines an API for creating two-dimensional and three- dimensional graphics. Generally, OpenGL runs through the GPU to access the hardware-accelerated image. Unity uses version 4.5 as the latest release. [31] - DirectX: DirectX is specifically designed to run game programming and video-related applications on Microsoft platforms. Supports 2D and 3D graphics. Unity supports DirectX 11 and the latest version, DirectX 12. [32]

2.5. Lighting Performance Unity game engine presents different methods depending on the state of the scene to be designed. Choosing the best lighting method influences the smoothness, appearance and the more stable operation of a scene during execution. Lighting in Unity can be considered as real-time or precomputed lightings. Both ways can be used for create efficient light scene [5].

2.5.1. Realtime Lighting This technique, Game Objects are moved with the scene and lighting will be updated immediately. This can be visible both the scene and game view. [5].

Figure 2.4: Example of Realtime Lighting Technique (unity3d.com)

10

Realtime lighting technique is the most common lighting method for objects within the scene and is useful for movable geometry. Figure 2.4 represents the illustration of Realtime Lighting Technique. It consumes less CPU and GPU. Unfortunately, for more realistic scenes Realtime Lighting technique is not the first option.

2.5.2. Precomputed Realtime GI Lighting Static lights are unable to update to changes in the scene dynamically but precomputed Realtime GI offers update complex scene lightings immediately.[5] “In order to deliver these effects at playable framerates, it is necessary to shift some of the lengthy number-crunching from being a Realtime process, to one which is precomputed” [33]. During the game, if the problems with the lighting on the stage are not critical, this error can be fixed later with the 'precomputed' technique. This is called offline operation. [5]

Figure 2.5: Example of Precomputed Realtime GI Lighting (unity3d.com) For more high-quality scenes, precomputed Realtime GI is the best option for users. Figure 2.5 shows the effect of Precomputed Realtime GI Lighting on the scene. In static lights, object changes can’t affect lights and shadows but with precomputed Realtime GI, object changes affect lighting and shadows. It provides more quality in the game scene. Precomputed Realtime GI consumes more CPU and GPU.

Figure 2.6: City of Manhattan with OpenStreetMap data

11

The Figure 2.6 represents example scene by using Mapbox SDK. Realtime Mode used for lighting tests.

2.5.3. Type of Lights Different approaches of the lights on the scenes is very important. It may be desirable to illuminate a particular point or region in a dark scene. This is very useful for situations. Moreover, different type of light affects different type of shadows. For a more effective appearance and smoothness of the scene, the lighting technique must be used very well. Lighting types are as follows; [6] - Directional Lights: Directional lights are very common for creating affects such as sunlight in the scene. On the other hand, directional lights can be used for long distance light sources which exist far away. Directional lights emit parallel rays in a single direction. At the end, shadows look the same in any case of the related objects position. Biggest advantage of the directional light is shadows are remaining consistent. This is useful for to lighting outdoor scenes. Directional lights don’t have any specific source position. They can be moved and placed anywhere. Moreover, rotating the light can be caused the visualisation. Directional lights do not subside over the distance. Obviously, using the directional light costs the performance. This is connected to the number of the pixels.

Figure 2.7: Directional Light Technique Terrain with Elevation The Figure 2.7 represents the directional light technique in the scene. The X, Y, Z coordinates can be change and rotatable. - Point Lights (Figure 2.8): A point lights are the most common type of lights in 3D scenes. It can be considered as a point in 3D Scene and emitting the light all directions. These are useful for creating like light bulbs. Specific point and the source will make closer objects brighter and objects which are further away will be darker. That means, 'range’ takes huge part in this way of the light. Enabling shadows for Point Lights can be required more processor work and so must be used sparingly. Point lights require that shadows have to render for 6 directions and rendering process must be done 6 times. Because of that, it requires more processor work and this could be a problem for some computers which have low hardware system.

12

Figure 2.8: Point Light Technique Terrain with Elevation - Spot Lights (Figure 2.9): Spot Light provides a direct source of light. It is emitting the light in cone shape and the width of the cone is defined as ‘Spot Angle’ parameter. It can be controlled how wide the cone angle will be. In this way, it can be decided how much of the area is actually illuminated. Spot Lights are useful and great affects for such as street lights or effects as flash lights. When using Precomputed Realtime GI, Spot Lights don’t support indirect shadowing just like Point Lights.

Figure 2.9: Spot Light Technique Terrain with Elevation

2.6. Shadows in Unity Shadows are one of the most important factors affecting the quality of the scene. The lighting techniques in the Unity and the position of the source of the light have an important influence on the shadows. The shadow has a significant impact on the usage of the both GPU and CPU. Depending on the type of shadow can give different results. Unity Engine provides 2 different shadow types. These types are ‘Soft Shadow’ and ‘Hard Shadow’. Hard shadows enclose less processing and reduces GPU and CPU usage and it is not realistic as Soft Shadows. On the other hand, soft shadows look smoother but requires more

13 processor work. Additionally, Unity provides specific resolution setting for shadows. [37] For instance, even if the scene configured for soft shadows but it still has sharp edges, then shadow resolution can be changed and more realistic scene will be presented. Shadows from the objects can be less visible if the source of the light is far away from the object. Unity provides ‘Shadow Distance’ option for customizing the distance of shadows. This could be the advantage but on the other hand high number of shadow distance reduces the rendering performance.

Figure 2.10: Shadows without any cascade (unity3d.com) The Figure 2.10 shows shadows appearance in two different points A and B. The shadow which is point A looks more accurate than point B. The edges can be seen on the point B. Unity solves this problem with defining the shadow cascades. It can be selected with two options. Two cascades or four cascades (Figure 2.11). More cascade means shadows will be affected less from camera perspective and edges will not be sharp but on the other hand it causes more rendering time and processor usage. [37]

Figure 2.11: Result after using four cascade option (unity3d.com)

14

2.7. OpenStreetMap “OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world. Rather than the map itself, the data generated by the project is considered its primary output.” [7] OpenStreetMap is an online service that can be zoomed and segmented in detail. It represents rendering of the map which is call “fast design map”. On the website (.org), fast design map is nothing then static images rendered from OpenStreetMap database. What makes OpenStreetMap stronger is not for being static map, the idea is actually access to data behind this map. Everyone can access to the dataset freely and this is the reason why OpenStreetMap is different than other maps such as Google Maps, Bing Maps and Yahoo! Maps. This is the biggest difference of OSM from other maps. Idea behind of the OpenStreetMap is database which includes every street, city, road, building so on. There are few ways to export the specific locations which user decided to export. In most cases, website provides XML files for purpose. Other way is exporting the latitude and longitude and using it in tools and engines. Map transfer can be done in two different ways in game engines. This depends on which method the game engine supports. The first method is available as scripted in the SDK and can be set in the inspector. All the user needs to do is enter the latitude and longitude information. In the Mapbox SDK, the search button is added without the need for this in the Inspector.[24] Another method is to cut a specific area from the OpenStreetMap official website. The Mapbox SDK also allows to import the ID of the domain that the website provides for a particular area. OpenStreetMap data is officially supported by Unity. In addition, many methods that can be added to Unity, which can transfer the actual map data to the game engine, work with OpenStreetMap data. Some of these methods include: Mantle, map-ity, Mapbox, UtyMap. [23] Advantages of OpenStreetMap; [22] - It’s free to access dataset and downloadable whole world of data approximately 800GB. - It can be export and customize and this is the biggest differences than other maps (Google, Bing, Yahoo! Maps). - Dataset is richer than other free map sources. Moreover, includes more details about streets, roads so on. - Customization is possible. Because OSM is a service, it can be used by third- party applications. - Day by day more frequently used. This is because the map service, which is most common today, is getting faster results than Google. There are points where it performs better as the speed of map loading.

15

Disadvantages of OpenStreetMap; [22] - Data quality is unsteady. The reason is OpenStreetMap depends on volunteers. For instance, big cities might have more details than small cities. - Database does not get updated often. That means, the network couldn’t be accurate or complete. - Documentation is incomplete and weak. Also, it is not updated very often.

16

3. METHODS In this section, different methods using real map data supported by Unity Game Engine are mentioned.

3.1. ActionStreetMap ActionStreetMap is a framework that helps to build a dynamic environment and city based on real location. As a data source, ASM uses OpenStreetMap. The main goal is to simulate a real city, create dynamically buildings, roads, parks, etc. using OSM information for given location. Moreover, ActionStreetMap allows to modify all objects (meshes) in scene, e.g. buildings, barriers and add new objects into the scene either. Additionally, ActionStreetMap saves new objects in OSM compatible format and use online/offline map data. [8] ASM is useful for customizing the scene with different type of objects and make rich the scene. SDK allows user to use online and offline map data. This could be useful for especially public transport schedule and users can see the visualization in 3D by using the application which made from ActionStreetMap.

Figure 3.1.a: Alexandreplatz, Berlin (52.51955, 13.40728) [1] Figure 3.1.b: Red Square, Moscow (55.75282, 37.62259) [2] Figure 3.1.a and Figure 3.1.b represent simulation of real environment by using OSM data. Environment doesn’t look good this could be negative point but for person who doesn’t have good enough hardware system for render high resolution scenes this SDK could be useful for them and framework is still under development process. ActionStreetMap published only 2 demo scenes (Berlin, Moscow) and it is runnable. Moreover, user who wants to access to source code, this is possible as well. The negative point of the SDK is that doesn't have a high-quality texture. This may be suitable for low quality games, but it will not be a very convenient method for realistic city simulation. [8]

3.2. Map-Ity Map-Ity is a SDK which provides by Rewind Game Studios. Package includes OpenStreetMap data and lets to create and customize real world environment. Based on location data provided, Map-Ity queries OpenStreetMap (OSM) data servers and downloads all the data for that location. It then parses that data and gives access to it

17 via API. Inside of the package, all classes already created. All user need to do is, import the package in the new project and use the objects in the prefabs. Roads, waterways, buildings and relations such as bus routes are the objects that SDK includes. Biggest disadvantage is Map-Ity cannot draw map tiles.[9]

Figure 3.2.a: The game scene before importing buildings Figure 3.2.b: The game scene after importing buildings The Figure 3.2.a and Figure 3.2.b represent the scene before and after using the Map-Ity SDK. It doesn’t include car object and after using the package, buildings are used in the prefabs folder and imported the scene.

Figure 3.3: Final version of the scene with Map-Ity SDK [3] The Figure 3.3 shows to final view of the scene. As an object, buildings and roads imported in the scene and results are very clear. As mentioned, classes with this SDK are pre-prepared and made available to the user. These classes are usually designed to be associated with the map. The classes in the SDK are as follows; [9] - Highway: Designing of highway base. - MapBounds: Used to determine the boundaries and edges of the map. - MapBuilding: The paths and the relations of the buildings on the map. - MapNode: This is the most important and main class of the SDK. Latitude and longitude are defined in this class. - MapWay: Areas such as roads, rivers and so on are designed in this class. It can also represent a specific area. - MapRelation: The relationship between objects is indicated in this class. For example, multiple path nodes must be combined for a given route, and its definition is made in this class.

18

Map-Ity SDK, released November 22, 2016 and current version is 2.1.3. Supported Unity Engine versions are 5.0.0 or higher. SDK is accessible in Unity Asset Store.

3.3. GO Map 3D Map GO Map is a SDK for making location based games with Unity 3D by using dynamic map. Graphic quality and control are customisable from the inspector and doesn’t need any code lines. The package includes, many demo scenes and all scenes are customisable as well. GO Map uses different types of styles such as; satellite, terrains, real buildings, classic flat maps. The GO Map collaborates with OpenStreetMap data. Uses “Vector Map” as data. The user does not have to use any image to create the scene, because the tiles contain all the information to create the map. What makes the SDK efficient is that it uses vector tiles. Faster processing time results in fewer project sizes, as it does not require any additional images and better resolution capabilities. GO Map v2.3 or higher supports “protobuffer” map files and are faster than JSON format. The reason is the protobuffer binary format. The GO Map features 4 different key grip. These concepts; Tile Buffer, Coordinates/units Ratio, Zoom Level and Origin of the World. The concepts in the SDK are as follows; [10] Tile Buffer (Figure 3.4): Basically, tile buffer means number of tiles in the map, that built demands of user’s location. When the tile buffer increases, it shows wider map but it causes more request to do.

Figure 3.4: Tile buffer increment according the map size. [7] Coordinates/Units Ratio: For rendering of the map, SDK uses a fixed scale. Measurement of the distance between coordinates in meters and a distance between Vector3 the value would be the same. Advantage of this concept is understanding the game mechanism and using a more comfortable scale in the project. Zoom Level: User able to configure zoom level in inspector by using the “Location Manager” which comes with package. In classic map, zoom level is proof of the map size. On the other hand, when the zoom level increases, tiles increase as well. That means, higher zoom level causes bigger tiles. World’s origin: This concept explains how user’s default location (Vector3 (X, Y, Z)) and world’s origin (latitude, longitude) match. In the dynamic map, every time when the default scene changes, real location will be updated and user does not have to care about the location.

19

Figure 3.5: Inspector view of Location Manager Script [10] The Figure 3.5 represents a “Location Manager” script which is given from Go- Map SDK. This script provides a fix location by using location services. “Demo Location” is a list of locations presets to use when playing inside editor or without locationServices. If it is changed to “custom” then latitude and longitude have to be configured. Another good point about this script is “Events”. A series of events are available with LocationManager and user can import it into the additional script. Parameters are used in the script; [10] - useLocationServices (bool): transition between GPS and fixed location. It always returns zero when playing inside the editor. - demoLocation (enum): a list of presets which come with package and editable inside the editor without using LocationServices. - updateDistance (float): making updates considering the location changes by using meters. - simulateMotion (enum): the speed of the simulation inside the editor.

Figure 3.6.a: Satellite images with GO Map [4] Figure 3.6.b: Search Location Asset with GO Map [5] The GO Map script includes map settings and editing; it is responsible for the detailed adjustments in the map, the regulations and the destruction of the objects

20 depending on the desired scene. This script is definitely most important script of entire package. The 'Location Manager' script should also be defined in the GO Map script. The biggest advantage of this SDK is that it works as a partner with Mapbox SDK and uses OpenStreetMap as map data. This is a great advantage for creating high-quality and more effective scenes. Moreover, it allows the user to create a real- or a three-dimensional virtual world depending on the request. Figure 3.6.a represents, high quality satellite images. On the other hand, Figure 3.6.b shows the example of Search Location Asset with GO Map SDK and it can be used for developing Augmented Reality games. Accessing for this tool, should pay 64.31 Euro and accessible in Unity Asset Store [10].

3.4. Real World Terrain Real World Terrain is a SDK that designed for generating real map data into the game environment by using several objects such as roads, rivers, roads, buildings, trees, grass so on. Data is taking from OpenStreetMap and SDK helps to combine them together. Moreover, with Real World Terrain there is a utility for selecting specific part on Google Maps and there are set of tools for post-processing, texture and placing objects on the scene. For elevation map, Real World Terrain uses; - “SRTM (The Shuttle Radar Topography Mission) v4.1 elevation map, accuracy of 3 arcseconds (90 Meters). The relative error in height for the data of less than 6 meters. - “SRTM 30. Accuracy of 1 arcseconds (30 meters). - “Bing Maps Elevation API. Accuracy: 10m – USA, 90m - 56° S - 60° N, 900m – other. - “Mapbox accuracy is unknown. [11]”

Data source is OpenStreetMap data and to create textures “ArcGIS, DigitalGlobe, Map Quest, Mapbox, Mapy.CZ, Maps (HERE.com), Virtual Earth (Bing Maps), Open Street Map [11].” Real World Terrain SDK, does not have any restriction about data usage. It depends on the users demand but for big Terrains, memory could be issue. For recommendation for users who would like to create a project with Real World Terrain SDK, it is better to follow required resolution.[11]

21

Figure 3.7: Demo scene of the Grand Canyon with Real World Terrain (36.12915, -113.892) [6] Figure 3.7 shows the Grand Canyon designed using real map data. The most common problems are; [11] - Downloading textures. Tool, forces to use another texture provider for solutions. - Visible gap between terrains. - Rendering problems with some areas. This issue is directly connecting with the OpenStreetMap data. - Memory problem becomes exist when the project size is very big. Current version of the SDK is v4.0.4 and supports Unity 5.6.0 or higher. Package is accessible in Unity Asset Store and licence price is 80€.

3.5. Mantle Environment System Mantle is a project that helps user to create a 3D real world environment. It provides a simple interface that allows to design and create a high quality and efficient scenes. Mantle mostly focuses on the create an interactive entertainment. Another aim of the Mantle is, focusing on the urban planning and traffic simulations. It makes people life easier by following this purpose. “Map source integration is provided by Mapzen, an open, sustainable, and accessible mapping platform that provides the core vector tiles that power Mantle generation [12].” Also, Mantle supports OpenStreetMap data as well. Mantle includes different type of meshes. These meshes are; [13] - Terrain Meshes: This type of meshes are created from land and sea map data’s in 3D form. It combines, complex and interesting landscapes. - Building Meshes (Figure 3.8.a): Buildings are crucial point for implementing real world environment into the scene. Mantle’s structures defined by map data and SDK automatically creates 3D buildings. All the textures are customisable and can be decorated. Specific buildings such as hospitals, restaurants can be independently targeted for styling. Moreover, building highness can be customize in the inspector.

22

- Transport Network Meshes: Mantle supports to develop roads, railways and paths. It is useful for urban planning and for this purpose, it uses Transport Network Meshes for designing. The most useful part of the Mantle is procedural decoration (Figure 3.8.b) capability. All the objects are customisable. For instance, parks could be filled with trees and it could be decorated with different tiles and makes it more efficient.

Figure 3.8.a: Example of Building Meshes [8] Figure 3.8.b: Example of Procedural Decoration [8] Mantle for Unity includes following features; [13] • Environment & Game Prototyping • 3D Environment Production: Early Stage • 3D Mapping • Augmented & Virtual Reality Environments (AR/VR) • Area Context • Data Visualisation • 3D Environment Production

Mantle’s current version is v1.3.2 and it supports Unity v5.6.3 or higher. It is accessible in Unity Asset Store and licence price is 550$.

3.6. Google Maps Platform Unity SDK Google Maps SDK for Unity helps user to develop real world environment into the game scene and includes set of development tools, services and pre-prepared assets. The SDK uses Google Maps database as a source. Within the SDK, there are more than 100 million 3D structures, roads and various structures. More than 200 countries are in the database to be transferred to the game engine. Using all these features, an effective and engaging game design can be done. [27]

“All geographic feature GameObjects have the following components: Transform, Mesh Renderer, and Mesh Filter [14].” The fact that these components come with the game object is a great factor to regulate the geographic features with styling and effects components like Rigidbody, Collider, and Materials.

23

- Mesh Renderer: Responsible for making lighting settings. - Mesh Filter: When Mesh Renderer is added, it is created automatically by Unity. - Rigidbody and Collider: They are a component of the Unity Engine and physically give dynamics to objects. For instance, gravity or falling ball hit the object.

The most important component is the MapService script which provides to access map data and customize it. User needs to attached the MapService script to the game object which should be created. Figure 3.9 below shows the Map Base game object in inspector window and ‘Basic Example’ script comes with SDK as well. ‘Basic Example’ script allows user to define latitude and longitude.

Figure 3.9: Inspector View of Map Base

The user needs ‘Api Key’ to use all the features in the SDK. However, without the key, user have access to some features and these features come as a demo. The demo package includes some examples of scene and it can be customized. It is not possible to access all dataset with demo package, it only includes ‘Manhattan’ as the demo scene.

24

Figure 3.10: City of Manhattan in the daylight

Figure 3.11: City of Manhattan in the night

The Figure 3.10 and Figure 3.11 represent illustration of the City of Manhattan from two different perspectives and times. It is possible to create a day-night cycle using Unity’s skybox system and directional lighting techniques. It makes the scene more effective and realistic. User needs to have Unity version 2017.3 or later for using the Google Unity SDK.

3.7. Wrld3d Map Wrld3D' is a SDK developed to transfer a real world to the game environment. With this SDK, three-dimensional visualized and dynamic location-based experiences and games can be developed. With this SDK, developers can quickly create a dynamic scene, transfer real-world data to the gaming environment

25

The main idea behind of the Wrld3 is, rendering the GIS and other location data into the game engines and creating high-quality environment. “At present, mapping platform has full coverage for such countries as the , Canada, , Ireland, Scandinavia, the Arabian Peninsula, Italy and more [15].” Wrld3d has over 300 Million kilometres mapped in their platform. The crucial point of, Wrld3 works with multiple GIS data partners depending on their regional mapping data coverage. Figure 3.12 illustrates the Wrld3d SDK map coverage across the world.

Figure 3.12: Wrld3d map coverage all around the world (wrld3d.com) The Wrld3d map is rich about optimizing different types of data; [15]

- Detailed water polygons. - River polylines where water polygons are unavailable. - 10m to 30m resolution Digital Terrain Model. - Road, river and railway polylines, ideally including height information. Structure of the Wrld3d SDK includes; [21] - Demo: Includes demo scenes and scripts that ready for import and customize. - API: Contains base script WrldMap which includes plugins. - Plugins: Includes all plugins for different platforms. - Textures: A set of textures ready to use. - Scripts: Unity MonoBehaviour scripts that help running the app. - Scene: Includes example of scenes and includes start-up scenes which have separate behaviour. - Resources: Includes set of materials.

26

Figure 3.13: Inspector view of Wrld Map script Implementation progress starts with importing the SDK package into the project. There are two different ways to add a 3D map to a Scene. First one is, using the pre- prepared assets. In the Project panel, it located under the Assets folder and the name of the scene is UnityWorldSpace. This scene allows to access game object which already created itself WrldMap. The main script Wrld Map (Figure 3.13) attached to this game object. User should have import API key for activating the script. The main script allows to change latitude and longitude. Script contains three different collisions. These collisions are Terrain, Road and Building. Figure 3.14 represents an example of the UnityWorldSpace scene that is available and editable in the package by the SDK.

27

Figure 3.14: Example of the UnityWorldSpace Scene The second way of the implementation is creating a new scene and game object. The component Wrld Map should be added to game object. User needs to tick the ‘Build-in Camera Controls’ to enable control mouse and keyboards for the camera. As mentioned, the base script contains three different collision settings and this can be used with map geometry. Enabling collision consumes more memory and add some latency to the rendering of the scene and this can be negative situation but on the other hand, enabling collider for dynamic scenes make the games more realistic. Another way to enable collision is writing the code line (Figure 3.15) into the script which created by user.

Figure 3.15: Collision script code line The Wrld3d SDK has two different options for coordinate system which solves the large distance map issue. These options are: Unity World Space (Figure 3.16) and ECEF Space (Figure 3.17). Unity World Space is default coordinates system. Latitude and longitude positioned. This option allows to use lighting techniques, math, cameras without any complexity.

28

Figure 3.16: Example of Unity World Space The ECEF (Earth-Centered Earth-Fixed) coordinate system is geographically accurate and it represents curve of the earth. It has more complicated steps about lighting techniques, math, cameras than Unity World Space but it has more accurate render times than it. Vector calculations are more complex for Earth’s surface.[16]

Figure 3.17: Example of ECEF Space It is possible to use custom textures in the project. Wrld3D SDK contains 5 different textures. These textures are; [17] - Building Textures: These textures are responsible for texturing the all buildings in the map. Wrld3d SDK is rich about building textures because it has specific textures for different situations such as day, night and snowy. - Transport Textures: Currently, two types of transport textures are exist. These textures are road and rail and rail textures include tramlines as well. - Terrain Textures: This type of textures using for specified lands. For instance: urban park, beach, forest etc

29

- Water Textures: It contains 3 different type of water textures. Depends on the water depth, one of these textures can be selected. - Tree Textures: Includes simple tree themes. Advantages of Wrld3d SDK for Unity; - Wrld3d SDK has 6 different partners for map data and it makes it rich about data source. - Allows to create and customize indoor & outdoor maps. - The SDK has 2 different coordinate system and it makes it more special. Disadvantages; - Current version of SDK does not allow to use Scene window before the run project. This makes harder to make customization. - Camera movements are restricted in the game scene. Additional camera script must be added for more efficiency. - The SDK has free access for developer but for unlimited editions, must be paid (for developers $16 per month) Current version of the Wrld3D SDK is v.0.7.1019 and supports Unity v2018.1.0f2.

3.8. Mapbox SDK Mapbox is a SDK which is supported by Unity and used to transfer the real world to the game environment. It allows to create and edit the map that included with many tools. Mapbox web services APIs include: The Maps, Geocoding and Directions APIs and OpenStreetMap is the data source. [19] Mapbox SDK contains many example scenes (Figure 3.18) and all the scenes have different features and possibilities of the SDK. Example scenes are located under the Mapbox Setup on the toolbar.

Figure 3.18: Example Scenes of Mapbox SDK The Mapbox SDK, provides The Map Editor (Figure 3.19) for developers to understand the map visualizations clearer. It has tree shape hierarchy and helps to create custom map. It is located under the Mapbox option on the toolbar.

30

Figure 3.19: The Map Editor view in Mapbox SDK Each node from the tree is scriptable object. Separated layers make hierarchy view cleaner and developers can see every change from inspector in this view. Moreover, layers can be toggled on or off with checkboxes. Implementation process starts with importing the SDK into the project. The empty scene must be created and ‘Map’ prefab should be attached into the hierarchy. This prefab provides the map visualization. Customization of the map should be done in the inspector. The script ‘Abstract Map’ should be attached to the Map game object. Abstract map is the script that which has the control of the map. Under the ‘General’ section, latitude and longitude can be changed. In the ‘Image’ section source of tile set for imagery can be selected. ‘Terrain’ section allows to select source of tile set for terrain. It includes ‘Mapbox Terrain’ and ‘Custom’ options. Custom option can be enabled only with ‘Map ID’ corresponds to the tile set. Elevation options for the terrains modify in here.

31

Figure 3.20: Inspector view of the Map game object Map Prefab (Figure 3.20) includes specific map features. Map feature is visualization for vector features (Figure 3.21) contained in a layer. It is possible to add new features on the map such as buildings, roads or some custom features.

Figure 3.21: Example of the map features in the Inspector Modelling section in the Inspector allows to make changes about meshes; [29] - Primitive Type: It defines type of vector feature. There are 4 different options for it; Point, Line, Polygon and Custom. - Extrusion Type: Defines type of geometry extrusion. - Geometry Type: Both roof and side wall geometry of the vector feature. Settings for it: roof, sidewall or both. - Property Name: Type of the property will be selected for extrusion and information about property can be checked in description line below. - Scale Factor: Scale factor to multiply the extrusion value of the feature. - Collider Type: This option is used for selection of type of the colliders.

32

Material options for building is configured under the Texturing section: - Custom: This setting for using custom materials and texturing type. - Simple (Figure 3.22): It combines vector designs with palettes which can be scripted to provide colourful style. - Light (3.23.a): It uses specific materials for creating bright map. - Dark (3.23.b): It uses specific materials for creating dark map. - Realistic (3.24.a): This is the default option texturing for buildings. It helps to create realistic city view. - Fantasy (3.24.b): This option renders the buildings in old medieval shape. - Colour: Depends on the user’s demand, colour of the buildings before render can be customized in here.

Figure 3.22: Simple type of style for building

Figure 3.23.a: Light type of style for buildings Figure 3.23.b: Dark type of style for buildings

Figure 3.24.a: Realistic type of style for buildings Figure 3.24.b: Fantasy type of style for buildings

33

Advantages of Mapbox Unity SDK; - Easy to build 3D Maps. - SDK loads scene fast. - Map Editor view makes easier to understand labels. - Tiles can be customized and combined in different scenes. - Runnable with 4 different Windows Graphic APIs Current issues about Mapbox Unity SDK; - SDK does have tile problem. Some tiles are missing and this could be visible some part on the objects. - Some parts of the buildings are not associated with correct tiles. - Sometimes tiles do not refresh properly when the scene is running multiple times.

34

4. TEST ENVIRONMENT AND CONFIGURATIONS

4.1. Test Environment Unity Engine supports 4 different APIs. These APIs are: DirectX 11, DirectX12, Vulkan and OpenGL 4.5. According these APIs, 4 different qualities (low, medium, high, ultra) tested with 2 different implementation methods. These methods are Wrld3D SDK and Mapbox SDK. The screen resolution was set to only 1600x900 because, changes in the resolution would directly affect the tiles and textures. Therefore, it would be possible to make inaccuracies in the results. Runtime measurement is 60 seconds and tested in 3 different screens scales: 1x, 5x and 10x. Vertical Synchronization (V-Sync) was another approach of the tests. The reason is V-Sync, matches the frame rate of the scene with the monitor refresh rate. For instance, if user has 60Hz monitor then FPS will be fixed for 60. This directly affects the CPU and GPU usage. The tests were done in two different approach: when V-Sync toggled on and toggled off.

4.2. Quality Settings Details As mentioned, tests were done with four different qualities. For each APIs, quality settings were the same. The quality settings tested on the scene are as shown in the Table 4.2.1, Table 4.2.2, Table 4.2.3, Table 4.2.4 below. Table 4.2.1: Low Quality Settings Texture Quality Full Resolution Anti-Aliasing Disabled Soft Particles Disabled Realtime Reflection Disabled Shadowmask Mode Shadowmask Shadows Disabled Shadows Resolution Low Resolution Shadow Distance 20 Shadow Cascades No Cascades

Table 4.2.2: Medium Quality Settings Texture Quality Full Resolution Anti-Aliasing 2x Multi Sampling Soft Particles Disabled Realtime Reflection Disabled Shadowmask Mode Shadowmask Shadows Hard Shadows Only Shadows Resolution Low Resolution Shadow Distance 20 Shadow Cascades No Cascades

35

Table 4.2.3: High Quality Settings Texture Quality Full Resolution Anti-Aliasing 4x Multi Sampling Soft Particles Disabled Realtime Reflection Enabled Shadowmask Mode Distance Shadowmask Shadows Hard and Soft Shadows Shadows Resolution High Resolution Shadow Distance 40 Shadow Cascades Two Cascades

Table 4.2.4: Ultra Quality Settings Texture Quality Full Resolution Anti-Aliasing 8x Multi Sampling Soft Particles Enabled Realtime Reflection Enabled Shadowmask Mode Distance Shadowmask Shadows Hard and Soft Shadows Shadows Resolution Very High Resolution Shadow Distance 150 Shadow Cascades Four Cascades

Shadowmask Mode: This is the shading effect of the lights reflected by the static objects on the scene. - Shadow Mask: It uses mixed lighting mode. It is used to shade objects that are not used dynamically by the character on the scene. It only provides low quality shading. - Distance Shadowmask: It uses real-time shadows up to shadow distance. Uses real-time shadows up to shade distance. This feature is used for more realistic shadows in the scene. Soft Particles: When soft particles are active, the objects have a more realistic and soft texture, but can cause poor performance. The hardware features of the computer used for the testing of scenes: - GPU: GeForce GTX 1050 with 4GB GDDR5 - CPU: Intel Core i5-8300H 2.30GHz - RAM: 8GB - Operating System: Windows OS - Monitor Refresh Rate: 60Hz.

36

5. TEST RESULTS

5.1. Frame Per Second (FPS) Benchmark

Low Quality FPS Benchmark V-Sync Off

OpenGL 4.5

DirectX 12

Vulkan

DirectX 11

0,00 100,00 200,00 300,00 400,00 500,00 600,00 700,00 FPS

Mapbox wrld3d

Figure 5.1.1: Low Quality FPS Benchmark

Medium Quality FPS Benchmark V-Sync Off

OpenGL 4.5

DirectX 12

Vulkan

DirectX 11

0,00 100,00 200,00 300,00 400,00 500,00 600,00 700,00 FPS

Mapbox wrld3d

Figure 5.1.2: Medium Quality FPS Benchmark

37

High Quality FPS Benchmark V-Sync Off

OpenGL 4.5

DirectX 12

Vulkan

DirectX 11

0,00 100,00 200,00 300,00 400,00 500,00 600,00 FPS

Mapbox wrld3d

Figure 5.1.3: High Quality FPS Benchmark

Ultra Quality FPS Benchmark V-Sync Off

OpenGL 4.5

DirectX 12

Vulkan

DirectX 11

0,00 100,00 200,00 300,00 400,00 500,00 600,00 FPS

Mapbox wrld3d

Figure 5.1.4: Ultra Quality FPS Benchmark Figure 5.1.1, Figure 5.1.2, Figure 5.1.3 and Figure 5.1.4 show FPS results for each of four different display settings. Low, medium and high-quality Vulkan has the best FPS performance. 663 FPS in low quality, 347 FPS in medium quality and 313 FPS in high quality. The lowest performance for these three display settings is shown by OpenGL. It has 72,20 FPS in low setting, 69,80 FPS in medium setting and 70,20 FPS in high setting. In the Ultra setting, DirectX 11 showed the best performance with 509.40 FPS. The lowest performance is shown by OpenGL with 64,40 FPS.

38

5.2. CPU Benchmark In this test, the test results are calculated in the same approach as the FPS criterion. All APIs were tested in 2 different ways and compared when V-Sync was turned on and off The CPU measurement unit is taken in milliseconds.

Low Quality CPU Usage V-Sync Off

18,00 16,79 16,43 16,00 14,00 12,00 10,00 8,71 7,43 8,00 6,74 6,40 5,30 CPU (ms) 6,00 4,59 4,00 2,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.1: Low Quality CPU Usage, V-Sync Off

Low Quality CPU Usage V-Sync On 35,00 29,61 30,00 25,00 20,00 17,34 17,53 16,26 16,10 14,6115,66 16,08 15,00 CPU (ms) 10,00 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.2: Low Quality CPU Usage, V-Sync On Figure 5.2.1 and Figure 5.2.2 show the CPU utilization comparison in low-quality scenes based on APIs. CPU usage is severely high when V-Sync is turned on. Each SDK required more processor operation. Each method has its own tiles and textures, and therefore the CPU usage results are quite different. In both cases, OpenGL with wrl3d has the highest result with 16,79ms and 29,61ms.

39

Medium Quality CPU Usage V-Sync Off 30,00 24,12 25,00

20,00 16,93 15,00 9,67 CPU (ms) 10,00 7,52 7,84 7,74 5,84 6,42 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.3: Medium Quality CPU Usage, V-Sync Off

Medium Quality CPU Usage V-Sync On

35,00 31,30 30,00 25,00 17,79 17,58 17,32 20,00 16,48 15,7516,52 16,16 15,00 CPU (ms) 10,00 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.4: Medium Quality CPU Usage, V-Sync On

Figure 5.2.3 and Figure 5.2.4 show the CPU Usages of Medium Quality. The results for each method were increased compared to the low quality. Shadows are of medium quality and the type of shadow is Hard Shadow, making a difference between these results and requiring more CPU work. Furthermore, Anti-Aliasing is enabled and set to 2x Multiple Sampling and directly affects CPU usage.

As with the low-quality test, OpenGL has the highest values with 24,12ms and 31,30ms. When vertical synchronization is off, DirectX 11 has the lowest CPU utilization with 5,84ms. When vertical synchronization is on, Vulkan has the lowest processor utilization with 15,75ms.

40

High Quality CPU Usage V-Sync Off 30,00 28,10 25,00 20,00 17,25 15,00 9,91

CPU (ms) 8,01 8,11 10,00 6,92 6,53 7,78 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.5: High Quality CPU Usage, V-Sync Off

High Quality CPU Usage V-Sync ON 40,00 34,57 35,00 30,00 25,00 20,00 17,0318,15 16,75 16,78 17,22 17,33 17,61

CPU (ms) 15,00 10,00 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.6: High Quality CPU Usage, V-Sync On

According to Figure 5.2.5 and Figure 5.2.6, the CPU utilization is significantly higher than the medium quality in both cases as V-Sync On and V-Sync Off. Anti- aliasing is set to 4x Multi Sampling. When remote shadow mask mode is enabled, processor usage has been higher. Exceptionally, the Medium Quality DirectX12 had more usage than High Quality when the V-Sync was opened with the Mapbox. As mentioned, Shadow Cascade has big impact on the render time and it changed through the 2 Cascades. Shadow Distance has increased to 40 and both facts affected the CPU usage significantly.

41

Ultra Quality CPU Usage V-Sync Off 35,00 29,32 30,00 25,00 20,00 18,78 15,00

CPU (ms) 10,90 10,23 8,45 10,00 7,05 8,14 8,09 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.7: Ultra Quality CPU Usage, V-Sync Off

Ultra Quality CPU Usage V-Sync On 35,00 33,21 30,00 25,00 19,04 17,35 17,37 17,36 18,21 18,25 20,00 17,49 15,00 CPU (ms) 10,00 5,00 0,00 DirectX 11 Vulkan DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.2.8: Ultra Quality CPU Usage, V-Sync On

Every detail in the scene directly affects the creation time and CPU usage. When the graphic settings are set to Ultra, soft particles are activated and the shadow stage is configured as 4 layers. According to Figure 5.2.7 and Figure 5.2.8, very high- resolution shadows were activated and the results were changed as in the table. In both methods, the values are almost the same, but OpenGL, which is always required high usage, is considerably higher than other API results as before.

5.3. GPU Benchmark The GPU test is included only 3 APIs: DirectX11, DirectX12, and OpenGL 4.5. The Unity Engine profiling tool failed to show the GPU usage results of the Vulkan

42

API. According to these 3 APIs, the graphics settings used for both the Wrld3D and the Mapbox SDK are the same as in the CPU test. The GPU measurement unit is taken in milliseconds.

Low Quality GPU Usage V-Sync Off 18,00 16,47 15,32 16,00 14,00 12,00 10,00 8,00 5,50 5,72 GPU(ms) 6,00 3,73 4,00 2,00 1,10 0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.1: Low Quality GPU Usage, V-Sync Off

Low Quality GPU Usage V-Sync On 25,00 22,81

20,00 15,16 15,00

10,00

GPU(ms) 6,44 4,25 4,88 5,00 3,85

0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.2: Low Quality GPU Usage, V-Sync On Changes in the graphic quality directly affects the rendering time and GPU usage. Low quality setting did not include any shadow effects or high detailed graphic options. According these facts, Figure 5.3.1 and Figure 5.3.2 show the GPU usage for each API and method.

43

Medium Quality GPU Usage V-Sync Off

18,00 16,51 16,12 16,00 14,00 12,00 10,00 8,00 6,93 5,59 GPU(ms) 6,00 3,80 4,00 2,76 2,00 0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.3: Medium Quality GPU Usage, V-Sync Off

Medium Quality GPU Usage V-Sync On 30,00 24,12 25,00 20,00 14,12 15,00 9,04 GPU(ms) 10,00 4,54 4,60 4,98 5,00 0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.4: Medium Quality GPU Usage, V-Sync On Changes in the graphic, directly affected the rendering time and GPU usage. The difference between Low and Medium quality is between Anti-Aliasing and shadows. Both affect the use of the GPU, and each SDK has its own texture materials and tiles. Also, V-Sync is another reason for higher GPU usage. According to these facts, Figure 5.3.3 and Figure 5.3.4 show the use of GPUs in low quality settings. OpenGL has the highest GPU usage with 16,51ms and 24,12ms where vertical synchronization is turned on and off. Another important result is that when vertical synchronization is turned off, the results of Mapbox and wrld3d in OpenGL are very close to each other.

44

High Quality GPU Usage V-Sync Off 20,00 17,50 18,00 16,74 16,00 14,00 12,00 10,00 7,50 8,00

GPU(ms) 5,82 6,00 4,30 4,00 3,21 2,00 0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.5: High Quality GPU Usage, V-Sync Off

High Quality GPU Usage V-Sync On 35,00 29,26 30,00 25,00 20,00 14,22

15,00 12,75 GPU(ms) 10,00 6,18 4,70 5,19 5,00 0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.6: High Quality GPU Usage, V-Sync On According to 3 different APIs, in most cases the Mapbox required more GPU usage, but in rare cases this was not accurate. Figure 5.3.5 and Figure 5.3.6 show how shadow attributes and graphic details affect GPU usage results.

45

Ultra Quality GPU Usage V-Sync Off 20,00 18,10 14,15 15,00

10,00 8,75 5,40 6,36

GPU(ms) 4,17 5,00

0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.7: Ultra Quality GPU Usage, V-Sync Off

Ultra Quality GPU Usage V-Sync On 30,00 27,16 25,00 20,00 13,67 14,30 15,00

GPU(ms) 10,00 7,16 5,45 6,25 5,00 0,00 DirectX 11 DirectX 12 OpenGL 4.5

wrld3d Mapbox

Figure 5.3.8: Ultra Quality GPU Usage, V-Sync On

Figure 5.3.7 and Figure 5.3.8 show the case where the graphic settings are ultra. The highest result is OpenGL with 18,10ms and 27,16ms. In both cases. The lowest CPU usage is Mapbox DirectX 11 with 4,17ms.

46

6. DISCUSSION The research objective was finding the methods for implementing the real map data into the game environment. The most important thing for developers, find the best configuration settings. This is very important approach for having smooth game experience. Games can be run with different Windows Graphics APIs. Therefore, tests were performed on four different APIs. Three key elements that are important for games: CPU, GPU usage and FPS performance. Computers might have different hardware systems and have different performance results. Therefore, each element tested with 2 different methods with different configuration settings and APIs. The purpose of the tests was to compare the results by running the selected method, Wrld3d and Mapbox, on these different APIs. Obviously, the recommended hardware features to use a game engine are higher. In order to carry out the tests, certain criteria were determined. First, screen scaling is set to 1x, 5x and 10x. The main purpose of this scale is to change the number of objects on the screen and directly affect the results. Another factor is the shadows and lighting, which have a direct impact on performance. One of the most important points of a game is to give the user a smooth playing experience. For this purpose, FPS comparisons were made. Since the execution time of the scene was exhausting the processor directly, a 60-second execution time was determined for the test. This was a measure taken to obtain FPS results more accurately. Considerable problems encountered in the Mapbox method is that the requested map is sometimes not loaded correctly and that the scene has to be executed again. This caused excessive CPU heating, so correct results could not be obtained. Significant differences were found between Mapbox and Wrld3d FPS results. Only OpenGL 4.5 FPS results are very close to each other (Figure 5.1.1, Figure 5.1.2, Figure 5.1.3, Figure 5.1.4). Mostly, wrld3d SKD is found to have higher FPS performance. Vulkan, one of the newest graphics APIs, performed well through low, medium and high-quality testing (Figure 5.1.1, Figure 5.1.2, Figure 5.1.3). Although, DirectX 11 is an older version than DirectX 12, it has higher FPS results in ultra-quality (Figure 5.1.4). An important criterion for CPU and GPU testing is that vertical synchronization is on and off. This factor, which directly affects the performance of these two units, has also created great differences in the results. In both cases where vertical synchronization is on and off, the highest results are in OpenGL. Figure 5.2.7, Figure 5.2.8, Figure 5.3.7 and Figure 5.3.8 are examples of these results. Therefore, CPU and GPU over-heating problems have been detected. Vulkan API is not included in GPU tests. This is because the profiler tool does not display the Vulkan API GPU results. This is the missing point of GPU tests. The tests were performed via 3 other APIs. As with the CPU tests, OpenGL has the highest GPU usage in the tests. This caused an increase in the load of the processor and a lower level

47 of the flow of the scene. As can be seen in the results (Figure 5.1.1, Figure 5.1.2, Figure 5.1.3, Figure 5.1.4). FPS results were the lowest in OpenGL. Generally, the results between the two methods are balanced, but significant differences are observed between FPS performances. The Wrld3D SDK is highly successful in terms of FPS performance. This is one of the most important criteria for the player and the game developer.

48

7. CONCLUSION The two methods planned to test, Mapbox SDK and Wrld3d SDK were successfully transferred to Unity Engine and then tested on 4 different APIs. The main purpose of the tests is to determine which API is suitable for the user by performing performance evaluations. The hardware system of the computer directly affect performance. Scale of the scene and quality of the textures used in the scene is another factor affecting performances. Although, these factors affect FPS results, the Wrld3D SDK generally has better FPS performance results than the Mapbox SDK. For both methods, the highest values for CPU and GPU usage are in the OpenGL API results. Although, changes were made in the objects depending on the details on the scene, both the computer and the processor were heated. Therefore, FPS performance was decreased. Moreover, the Mapbox SDK has a rich map data, but despite the rich content which big cities has (New York, , etc.), small cities (Salzburg, Wrocław, etc.) does not have this privilege and it can be seen flat on the scene.

7.1. Future Work This study can be extended with the next generation of real-world map data transfer methods and compared with the Mapbox SDK and Wrld3D which is used in this research. Depending on the number of objects on a larger map and in different locations, the user can make customization on the maps and test them in the Mapbox SDK and Wrld3D SDK with Unity Game Engine. This gives users an idea of what methods and APIs they should focus on.

49

8. BIBLIOGRAPHY 1. Dale Lorke, Location-Based Gaming, Play in the Public Space, https://www.palgrave.com/gp/book/9789811306822, 2019 2. Wikipedia contributors, Unity (Game Engine), In Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Unity_(game_engine)&oldid=900 243160, 06.04.2019 3. Unity Technologies, Frame Debugger, https://docs.unity3d.com/Manual/FrameDebugger.html, 15.04.2019 4. Wikipedia contributors, Channel (digital image), In Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Channel_(digital_image)&oldid=8 96770649, 12.05.2019 5. Unity Technologies, Introduction to Lighting and Rendering, https://learn.unity.com/tutorial/introduction-to-lighting-and-rendering#, 15.04.2019 6. Unity Technologies, Types of Lights, https://docs.unity3d.com/Manual/Lighting.html, 15.04.2019 7. OpenStreetMap Wiki contributors, OpenStreetMap, https://en.wikipedia.org/w/index.php?title=OpenStreetMap&oldid=90022689 1, 04.06.2019 8. ActionStreetMap, https://actionstreetmap.github.io/demo/index.html, 26.07.2016 9. Rewind Game Studio, Map-Ity Documentation, http://www.rewindgamestudio.com/documentation/current/index.html, 08.03.2016 10. Alan Grant, 3D Map for AR Gaming, http://gomap-asset.com/docs/go-map- documentation, 22.11.2017 11. Infinity-Code, Real World Terrain Documentation, http://infinity- code.com/en/docs/real-world-terrain 12. Mantle Technologies, Mantle and how it works, https://www.mantle.tech/how-it-works 13. Mantle Technologies, Mantle Features, https://www.mantle.tech/features 14. Google Maps Platform Gaming Solution, Maps Unity SDK, https://developers.google.com/maps/documentation/gaming/overview_musk, 24.04.2019 15. Wrl3d, Wrld3d Mapping Data, https://www.wrld3d.com/3d-maps/mapping- data 16. Wrld3d, Wrld3d Documentation Coordinate Systems, https://www.wrld3d.com/unity/latest/docs/examples/coordinate-systems, 2018 17. Wrld3d, Wrld3d Documentation Custom Textures, https://www.wrld3d.com/unity/latest/docs/examples/custom-textures, 2018

50

18. Wrld3, Wrld3d Documentation SDK Package Structure, https://www.wrld3d.com/unity/latest/docs/examples/sdk-package-structure, 2018 19. Mapbox Docs, Maps SDK for Unity, https://docs.mapbox.com/unity/maps 20. Michael Klappenbach, Understanding and Optimizing Frame Rates, https://www.lifewire.com/optimizing-video-game-frame-rates-811784, November 02, 2018 21. Ross Avner, Build location-based games or apps with the newly launched WRLD SDK for Unity, https://blogs.unity3d.com/2017/07/05/build-location- based-games-or-apps-with-the-newly-launched-wrld-unity-sdk, July 5, 2017 22. Darwin Garcia, OpenStreetMap; an alternative to Google Maps, https://www.webilop.com/openstreetmap-an-alternative-to-google-maps, 23.06.2013 23. OpenStreetMap Wiki contributors, Unity, https://wiki.openstreetmap.org/w/index.php?title=Unity&oldid=1490139, 11.07.2017 24. Derick Rethans, What is OpenStreetMap, https://derickrethans.nl/what-is- openstreetmap.html, 12.05.2011 25. Andrew Kertesz, What are the benefits of Unity, https://www.quora.com/What-are-the-advantages-of-Unity, 26.12.017 26. Unity Technologies, Lighting Overview, https://docs.unity3d.com/Manual/LightingInUnity.html, 15.04.2019 27. Clementine Jacoby, The real world as your playground: Build real-world games with Google Maps APIs, https://cloud.google.com/blog/products/maps-platform/the-real-world-as- your-playground-build, 14.03.2018 28. Wikipedia contributors, Central processing unit, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Central_processing_unit&oldid=8 99567996, 30.05.2019 29. Unity Technologies, Map Features, https://docs.mapbox.com/unity/maps/overview/map-features 30. Wikipedia contributors, Vulkan (API), The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Vulkan_(API)&oldid=899650581, 31.05.2019 31. Wikipedia contributors, OpenGL, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=OpenGL&oldid=899284603, 29.05.2019 32. Wikipedia contributors, DirectX, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=DirectX&oldid=899953624, 2.06.2019 33. Unity Technologies, Choosing a Lighting Technique, https://unity3d.com/cn/learn/tutorials/topics/graphics/choosing-lighting- technique

51

34. Potenza Global Solutions, 5 Rarely Known Advantages and Disadvantages of Unity Game Development, http://www.potenzaglobalsolutions.com/blogs/5- rarely-known-advantages-and-disadvantages-of-unity-game-development 35. Unity Technologies, Profiler Overview, https://docs.unity3d.com/Manual/Profiler.html, 15.04.2019 36. Wikipedia contributors, Graphics processing unit, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Graphics_processing_unit&oldid= 901125633, 9.06.2019 37. Unity Technologies, Shadows, https://docs.unity3d.com/Manual/ShadowOverview.html, 15.04.2019

8.1. Figure References 1. ActionStreetMap Demo Scene, Alexandreplatz, Berlin, https://actionstreetmap.github.io/demo/demo_list.html 2. ActionStreetMap Demo Scene, Red Square, Moscow, https://actionstreetmap.github.io/demo/demo_list.html 3. Map-ity Racing Game Example, Rewind Game Studio, https://www.youtube.com/watch?v=FJ1U_y7PTq4&t=2s, 28.03.2014 4. Alan Grant, Satellite Images, https://gomap-asset.com/docs/go-map- documentation/demo-scenes/satellite, 23.01.2018 5. Alan Grant, Search Location Asset, https://gomap-asset.com/docs/go-map- documentation/demo-scenes/search-location, 23.01.2018 6. Real World Terrain - Grand Canyon, Infinity-code, http://infinity- code.com/en/demos/real-world-terrain/real-world-terrain-grand-canyon 7. Alan Grant, Key Concepts of GO Map, https://gomap-asset.com/docs/go- map-documentation/getting-started/key-concepts, 22.11.2017 8. Mantle Technologies, Mantle Features, https://www.mantle.tech/features

52

List of Figures

Figure 2.1: View of the Frame Debugger in Unity Engine Figure 2.2: ‘Show red channel only’ section is activated Figure 2.3: Unity Profiler Tool view Figure 2.4: Example of Realtime Lighting Technique (unity3d.com) Figure 2.5: Example of Precomputed Realtime GI Lighting (unity3d.com) Figure 2.6: City of Manhattan with OpenStreetMap data Figure 2.7: Directional Light Technique Terrain with Elevation Figure 2.8: Point Light Technique Terrain with Elevation Figure 2.9: Spot Light Technique Terrain with Elevation Figure 2.10: Shadows without any cascade (unity3d.com) Figure 2.11: Result after using four cascade option (unity3d.com) Figure 3.1.a: Alexandreplatz, Berlin (52.51955, 13.40728) [1] Figure 3.1.b: Red Square, Moscow (55.75282, 37.62259) [2] Figure 3.2.a: The game scene before importing buildings Figure 3.2.b: The game scene after importing buildings Figure 3.3: Final version of the scene with Map-Ity SDK [3] Figure 3.4: Tile buffer increment according the map size. [7] Figure 3.5: Inspector view of Location Manager Script [10] Figure 3.6.a: Satellite images with GO Map [4] Figure 3.6.b: Search Location Asset with GO Map [5] Figure 3.7: Demo scene of the Grand Canyon with Real World Terrain (36.12915, -113.892) [6] Figure 3.8.a: Example of Building Meshes [8] Figure 3.8.b: Example of Procedural Decoration [8] Figure 3.9: Inspector View of Map Base Figure 3.10: City of Manhattan in the daylight Figure 3.11: City of Manhattan in the night Figure 3.12: Wrld3d map coverage all around the world (wrld3d.com) Figure 3.13: Inspector view of Wrld Map script Figure 3.14: Example of the UnityWorldSpace Scene Figure 3.15: Collision script code line Figure 3.16: Example of Unity World Space Figure 3.17: Example of ECEF Space Figure 3.18: Example Scenes of Mapbox SDK Figure 3.19: The Map Editor view in Mapbox SDK Figure 3.20: Inspector view of the Map game object Figure 3.21: Example of the map features in the Inspector Figure 3.22: Simple type of style for building Figure 3.23.a: Light type of style for buildings Figure 3.23.b: Dark type of style for buildings Figure 3.24.a: Realistic type of style for buildings Figure 3.24.b: Fantasy type of style for buildings Figure 5.1.1: Low Quality FPS Benchmark

53

Figure 5.1.2: Medium Quality FPS Benchmark Figure 5.1.3: High Quality FPS Benchmark Figure 5.1.4: Ultra Quality FPS Benchmark Figure 5.2.1: Low Quality CPU Usage, V-Sync Off Figure 5.2.2: Low Quality CPU Usage, V-Sync On Figure 5.2.3: Medium Quality CPU Usage, V-Sync Off Figure 5.2.4: Medium Quality CPU Usage, V-Sync On Figure 5.2.5: High Quality CPU Usage, V-Sync Off Figure 5.2.6: High Quality CPU Usage, V-Sync On Figure 5.2.7: Ultra Quality CPU Usage, V-Sync Off Figure 5.2.8: Ultra Quality CPU Usage, V-Sync On Figure 5.3.1: Low Quality GPU Usage, V-Sync Off Figure 5.3.2: Low Quality GPU Usage, V-Sync On Figure 5.3.3: Medium Quality GPU Usage, V-Sync Off Figure 5.3.4: Medium Quality GPU Usage, V-Sync On Figure 5.3.5: High Quality GPU Usage, V-Sync Off Figure 5.3.6: High Quality GPU Usage, V-Sync On Figure 5.3.7: Ultra Quality GPU Usage, V-Sync Off Figure 5.3.8: Ultra Quality GPU Usage, V-Sync On

54