Development Blog #2

Dear Mechanics!

Welcome to our second Development Blog post. We will present here more detailed informations regarding development of Tank Mechanic Simulator. This day our Programmer Przemek will present here details about generator tool  for SystemDG maps.

Cartographic Map Generation System

In real life almost everyday we are going to the various places. Naturally, we make it intuitive, because we reconstruct information about local environment from our memory. Now  let’s imagine, we have to drive somewhere far away, first time. So, before start, we usually gather data to quick reach the target without problems. Similarly, in virtual worlds, players often needs tools for comfortable levels exploration. And like in true world, map can be our the best guide.

Minimap is a part of Graphical User Interface (GUI), which is characteristic especially for sandbox games with huge levels.  It is primarily designed to display distance and direction to the current mission objective. In addition, it helps the player to identify his position in the game world. Minimap often is situated at the corner of screen during gameplay and usually developers allow us  to enable or disable it from options.  Reason is simple – sometimes players want to investigate surrounded area without tips, for better challenge.

More complex set of knowledge about game world is included in full map, accessed from virtual PDA or toggled from special key (for example M). It can be designed as a model of traditional cartographic map (topography or hypsometric) or as a stylized map. For example, hypsometric map (sometimes called relief map), has got  contour lines (isolines) through points of equal elevation and  basically shows the configuration and height of the land surface by color palette . Such maps are useful for quick identification of  terrain layers (lowlands, highlands).

Example maps in games: Tom Clancy’s Ghost Recon Wildlands (top left),  ArmA III (top right), Firewatch (down left), Betrayer (down right).

Now we want to include map functionality in our game. In the first step, we have to choose style. Then, we should realize our task in practice. In Unity Engine you can use classic mesh for a simulation of ground. An alternative method is to use the built-in Terrain Component. Unity also has tools for shaping the sculpture of terrain and surface painting with set of textures (called splat maps).  From technical side, geometrical data is internally stored in grayscale heightmap and it’s resolution has influence on terrain details. Through C# scripts, we can easily read certain fragments of elevation data (function TerrainData.GetHeight). After extraction of two-dimensional heightmap, we use post-processing.  Degenerals team  designed special pixel shader, where custom color ramp is assigned and algorithm replaces grayscale values from input texture. Isocontours are computed from gradients. An additional feature of the shader is the procedural grid with the changeable parameters of resolution, color, line orientation and thickness. In shader code, grid lines are created through getting of fractional parts of two up-scaled custom UV coordinates systems. Then we set lines parameters and falloff.  It uses built-in shader function called „smoothstep”, which could be mathematically described as result of x*x*(3-2*x), where x is clamped value to 0..1 range.

Generated three-dimensional terrain (top left) and its two-dimensional representations based on cartographic shader variant with different settings.

Player can dynamically move map as well as zoom-in and zoom-out .  The last step would be inserting symbols of objects (roads, building etc.)  into existing map. However, let’s think whether we can show map content in even more clearly way.  Slighty modification – desaturation made by multiplication RGB values and three components vector float3(0.2126, 0.7152, 0.0722) – and colors look like more toned down. Finally, we can highlight additional data in the foreground and elevation structure in background with eye pleasant style. We prepared solution for fast foliage detecting and mapping to our image.  Thanks to built-in treeInstances struct we can specify position of every tree. For visualization purposes, these points define centers of procedural circles with small radius. Next, in a loop, every circle is written to custom render texture.

Terrain with autumn-style trees (top left), desaturated relief map (top right), desaturated relief map with forest layer (down left), inverted isolines only with forest layer (down right)

We are thinking about further improvements.  Fetching terrain shadows from  second camera with ortographic projection and blending to existing map model would be cool. Of course, we will add label with world coordinates and other standard features. As described in article, maps  were generated on-the-fly.  Create terrain, paint it, configure shader settings, click button and that’s all. We love making flexible systems, which give us combination of speed and quality.

What’s your idea about map appearance in Tank Mechanic Simulator ? Feel free, comments are welcome!

If You have any suggestions, ideas or questions, write to us at contact@degenerals.com or visit our Discord server – https://discord.gg/HPbJj9y

DeGenerals

Leave a Reply

Your email address will not be published. Required fields are marked *