GENERATING TERRAIN AND HI DETAILS USING TEXTURE MAPS

Z. Sabati, A. Bernik

1. Abstract

Texturing is one of the fundamental elements of 3D computer graphics. Application, which is analyzed in this paper is related to two components. First is the relationship of textures and 3D models, and the second refers to the texture generating relief. Showing the basic principles and rules for the inevitable result of good quality. It explains the idea of the textures multiplied the number of two Advantages and disadvantages of various other ways of generating terrain, such as polygonal geometry and dots (a voxel). The analysis includes two platforms PC and iOS. Practical work results in a table format that shows the comparative component compatibility of 2D graphic elements. Mentioned are three basic types of texture maps: Mip, Detailed and Normal maps. The principle of Normal maps and the algorithm of creations are listed in the paper. For what use, what are the advantages and what are the ways that this technique supports the process of creating 3D terrain.

2. Basic techniques used for terrain creation

2.1 Heightmaps

With a heightmap, you store only the height component for each vertex (usually as 2D texture) and provide position and resolution only once for the whole quad. The landscape geometry is generated each frame using the geometry shader or hardware tessellation. Heightmaps are the fastest way to store landscape data for collision detection. You only need to store one value per vertex and no indices. It's possible to improve this further by using detail maps or a noise filter to increase perceived detail.[3]
The geometry shader for heightmaps is small and runs fast. It's not as fast as geometry terrain though.
On systems without triangle based 3D acceleration, ray marching heightmaps is the fastest way to render terrain. This was referred to as voxel graphics in older games. It's possible to change the resolution of the generated mesh based on distance from the camera. This will cause the shifting geometry if the resolution drops too far, but can be used for interesting effects. Heightmaps can easily be created by blending noise functions like fractal Perlin Noise and heightmap editors are fast and easy to use. Both approaches can be combined. They are also easy to work with in an editor. A horizontal position maps directly to (usually) one to four positions in memory, so geometry lookups for physics are very fast.[3]
There usually can't be holes in the ground or overhanging cliffs. You can only control the precise height of each point if the grid size matches the texture coordinates. If the four vertices that define a sub-quad aren't on the same plane, the split between the two vertices will become visible. This usually happens on steep cliffs with edges that don't follow a cardinal direction. Heightmaps are the most efficient way of rendering terrain by far and are used in many newer games that don't rely on advanced terrain features and have large outdoor areas.[3]

2.2 Voxels

Voxel terrain stores terrain data for each point in a 3D grid. This method always uses the most storage per meaningful surface detail, even if you use compression methods like sparse octrees. The term "voxel engine" was often used to describe a method of ray marching terrain heightmaps common in older 3D games. This section applies only to terrain stored as voxel data.[6]
Voxels are pretty much the only efficient way to store continuous data about hidden terrain features like ore veins. Uncompressed voxel data can be changed easily. It's possible to create overhangs.
Tunnels are seamless. Game Minecraft does this by overlaying noise functions and gradients with predefined terrain features (trees, dungeons). To render voxel data, you either have to use a ray tracer or compute a mesh, for example with marching cubes. Neighboring voxel aren't independent for mesh generation and the shaders are more complicated and usually produce more complex geometry. Rendering voxel data with high LOD can be very slow. Storing voxel data uses lots of memory. It's often not practicable to load the voxel data into VRAM for this reason, as you'd have to use smaller textures to compensate for it, even on modern hardware.[6]
It's not practical to use voxels for games that don't rely on voxel features like deformable terrain, but it can allow interesting game mechanics in some cases. Voxel engines are more common in older games, but there are also newer examples: Atomontage engine: Voxel rendering, Worms 4, Minecraft, Terraria, Voxels combined with physics used for destruction showcases.

2.3 Meshes

Polygon meshes are the most flexible and precise way of storing and rendering terrain. They are often used in games where precise control or advanced terrain features are needed. You only have to do the usual projection calculation in the vertex shader. A geometry shader isn't needed. All coordinates are store individually for each vertex, so it's possible to move them horizontally and increase mesh density in places with finer details. This also means the mesh will usually need less memory than a heighmap, because vertices can be more sparse in areas with less small features. The mesh is rendered as-is, so there won't be any glitches or strange-looking borders. It's possible to leave holes and create overhangs. Tunnels are seamless. Only possible with precomputed meshes. This will cause "jumps" when switching without additional data to map old to new vertices. Finding vertices that correspond to an area that should be modified is slow. Unlike in heightmaps and voxel data, the memory address for a certain location usually can't be calculated directly.[8]
This means physics and game logic that depend on the exact surface geometry will most likely run slower than with the other storage formats.Polygon terrain is often uses in games that don't have large open areas or can't use heightmap terrain because of its lack of precision and overhangs.

Table 1. Techniques for terrain generation

a 

Heightmaps are the best solution if you don't need overhangs or holes in the terrain surface and use physics or dynamic terrain. They are scalable and work well for most games.
Voxels are good for describing very dynamic terrain with many complex features. Avoid rendering them directly as they need large amounts of memory and processing.
Meshes have the highest precision and can describe overhangs, holes and tunnels. Use them if you have complex terrain that doesn't change often.

3. Limitations for the texture in terms of engine

There are a few fundamental 'rules' applicable to making content for any sort of interactive media that need particular attention paid to them. The following section will discuss one of the core ''rules'', that of texture size, their dimensions and how that relates to a form of texture optimization, something commonly called the ‘’Power of two’’ rule. The main question was: Is our project affected by this rule and what types of media projects use this rule? [2]
Answer is: ‘’All of them!'' because it's an underlying technology requirement so it's applicable from First Person Shooter (FPS) games as much as it is to Massive Multi-player Online (MMO), Role Playing Game (RPG), to the virtual worlds or 3D chat services. The technology behind every type of media or game is built on the same fundamental power of two rule. Is it necessary for developer to format textures in this type of form?[2]
No, it’s not necessary, but media most certainly needs that kind of a formatting and that’s regardless as to what developer wanted to do with it. The rule is a fundamental necessity due to the way game engines work, there's actually a long history associated with game and content development that has to do with the way computers manage and process data in 'chunks' for purposes of efficiency.
For game content creation, textures in particular, it's these chunks that are important with regards to the power of two rule as it sets hard coded, physical restrictions on media in such a way that it must conform to it directly.And here-in lies the problem where textures are concerned, if they don't conform to the expected parameters, game are forced to physically alter assets and in so doing, waste resources both in terms of time and processing power, fixing the problem. In effect the essence of the power of two rule is 'optimization', being as efficient and 'lite' as possible whilst providing the user an appropriate visual experience. Here is an example of how the texture is previewed in developer’s scene before it is built for engine.[2]

 a

Figure 1. Preview of god and bad texture mapping [2]

A visual representation, in Blender, of what a game would do to a texture when applied to something if it didn't resize and fix badly proportioned images. A) would happen if texture were loaded in 'as is' when incorrectly sized - red areas indicate areas of the model that wouldn't have anything applied. B) is what happens when a game resizes a bad texture, note the areas of mismatch between faces, something commonly the result. And C) a properly and correctly sized and proportioned texture applied to an object without any of the aforementioned problems.
This is not a singular problem because every time the game pulls in a texture to render to screen, it's having to waste resources resizing to fit, each and every time.

3.1 The power of two rule

It's a simple set of criteria applicable to all game related images that makes sure they conform to a series of regular dimensions. Typically this means doubling up or dividing down by two. So texture sizes that have or are limited to "8", "16", "32", "64", "128", "256", "512", "1024", "2048" (or higher for more modern games) in one or more width/height direction are regarded as being valid and properly optimized for quick loading into a game and processing into memory.
Shown below are some typical examples of valid and invalid textures. The first set on the left use the correct (or 'valid') power of two dimensions. The second don't, as is highlighted by the visible extra area representing the amount of space the textures should be occupying; the amount of extra visible directly correlates to the amount of forced resizing an engine is required to do to fix the problem of incorrect proportions so the textures can be used properly. [2]

a

 

 

 

 

 

 

Figure 2. Unwrapped texture maps: Power of two and random texture pixel size [2]

Ignoring the power of two rule has a number of knock-on effects for texture making, one of which relates directly to image quality. Because a game engine has to physically adjust the size and dimensions of incorrectly proportioned image it degrades the fidelity of the image itself, so fine details - the freckles on a character models skin, or the pattern of fabric on a piece of furniture - become blurred, pixilated or have some other visual artifacts appear due to the resize process having to extrapolating the necessary data from what's available.
The fix isn't to change to a format that has 'better' compression, i.e. a format using 'loss-less' compression like PNG, TGA et-al, and usually at the expense of increasing file size a few kilobytes or megabytes. The solution is to pay greater attention to the size of the original image, making sure they're properly proportioned so they're loaded into, and displayed by, an engine correctly.It is possible to use other (non power of two) texture sizes with Unity. Non power of two texture sizes work best when used on GUI Textures. However if used on anything else they will be converted to an uncompressed RGBA 32 bit format. That means they will take up more video memory (compared to PVRT(iOS)/DXT(Desktop) compressed textures), will be slower to load and slower to render (if you are on iOS mode). In general you'll use non power of two sizes only for GUI purposes. [2]

4. Texture types and support

Every texture image when imported into the engine is converted into basic format which is supported by certain graphic cards. Types of formats for PC and iOS platform are shown in next table.
Some Engines can read the following file formats: PSD, TIFF, JPG, TGA, PNG, GIF, BMP, IFF, PICT. It should be noted that more advanced Engines can import multi-layer PSD & TIFF files just fine. They are flattened automatically on import but the layers are maintained in the assets themselves, so developer doesn’t lose any of his work when using these file types natively. This is important as it allows them to have just one copy of textures that they can use from Photoshop.[7]

Mip Maps

Mip Maps are a list of progressively smaller versions of an image, used to optimize performance on real-time 3D engines. Objects that are far away from the camera use the smaller texture versions. Using mip maps uses 33% more memory, but not using them can be a huge performance loss. You should always use mipmaps for in-game textures; the only exceptions are textures that will never be minified (e.g. GUI textures).[7]

Detail Maps

If developer wants to make a terrain, he normally use his main texture to show where there are areas of grass, rocks sand, etc... If terrain has a decent size, it will end up very blurry. Detail textures hide this fact by fading in small details as your main texture gets up close. A Detail texture is a small, fine pattern which is faded in as you approach a surface, for example wood grain, imperfections in stone, or earthly details on a terrain. Detail textures must tile in all directions. Color values from 0-127 makes the object it's applied to darker, 128 doesn't change anything, and lighter colors make the object lighter. It's very important that the image is centered around 128 - otherwise the object it's applied to will get lighter or darker as you approach. They are explicitly used with the Diffuse Detail shader.
Diffuse Detail Shader is a version of the regular Diffuse shader with additional data. It allows you to define a second "Detail" texture that will gradually appear as the camera gets closer to it. It can be used on terrain, for example. You can use a base low-resolution texture and stretch it over the entire terrain.[7] When the camera gets close the low-resolution texture will get blurry, and you don't want that.
To avoid this effect, create a generic detail texture that will be tiled over the terrain. This way, when the camera gets close, the additional details appear and the blurry effect is avoided. The Detail texture is put "on top" of the base texture. Darker colors in the detail texture will darken the main texture and lighter colors will brighten it.[7]

Table 2. Formats and compatible platforms

a 

Normal Maps

Normal maps are used by normal map shaders to make low-polygon models look as if they contain more detail. Some game Engines uses normal maps encoded as RGB images. Developer also has the option to generate a normal map from a grayscale height map image.

4. Normal mapping

Normal-Mapping is a technique used to light a 3D model with a low polygon count as if it were a more detailed model. It does not actually add any detail to the geometry, so the edges of the model will still look the same, however the interior will look a lot like the high-res model used to generate the normal map. The RGB values of each texel in the the normal map represent the x,y,z components of the normalized mesh normal at that texel. Instead of using interpolated vertex normals to compute the lighting, the normals from the normal map texture are used.[4]
Since the high-res model is used only to generate a texture, the number of polygons in the high res model is virtually unlimited. However the amount of detail from the high-res model that will be captured by the normal map is limited by the texture's resolution.

aa 

Figure 4. Low – Hi poly and usage of Normal maps

The most basic information you need for shading a surface is the surface normal. This is the vector that points straight away from the surface at a particular point. For flat surfaces, the normal is the same everywhere. For curved surfaces, the normal varies continuously across the surface. Typical materials reflect the most light when the surface normal points straight at the light source. By comparing the surface normal with the direction of incoming light, you can get a good measure of how bright the surface should be under illumination:


aa

Figure 5. Lighting a surface using its own and Hi resolution normals [5]

To use normals for lighting, You have two options. The first is to do this on a geometry basis, assigning a normal to every triangle in the planet mesh. This is straightforward, but ties the quality of the shading to the level of detail in the geometry. A second, better way is to use a normal map. You stretch an image over the surface, as you would for applying textures, but instead of color, each pixel in the image represents a normal vector in 3D. Each pixel's channels (red, green, blue) are used to describe the vector's X, Y and Z values.
When lighting the surface, the normal for a particular point is found by looking it up in the normal map. The benefit of this approach is that you can stretch a high resolution normal map over low resolution geometry, often with almost no visual difference.

4.1 Object and Tangent Space normal maps

Whether using object space or tangent space, normal-mapping with skeletal animation is much the same. The main idea behind using tangent space is going through extra steps to allow the reuse of a normal map texture across multiple parts of the model. Storing normals / tangents / binormals at the vertices, and computing the normals of the normal map relative to them, then converting back when rendering. Also, you could use tangent-space to skin a flat bump texture around a model.[5]

a

Figure 7. Low and Hi res Raptor [9]

A limitation of Object Space normal mapping, as opposed to using Tangent Space, is that every point on the skin must have its own distinct UV coordinates. You can't reuse parts of the texture for multiple parts of the model. This is a pretty common practice: perhaps both sides of the Raptor's face will have the exact same UV coordinates, effectively reusing one part of the texture for both sides of the face. With the straightforware implementation of an object space normal map though, the normals on opposite sides of the Raptor's face will obviously have to point in different directions, so they each need to be defined by separate areas of the texture. There is a way around this for parts of a model that are completely symetric along an axis. Only generate the normal map for one side, and then render each side separately.[9]

5. Algorithm for calculating the normals of a heightmap

First, you're going to derive normals for a regular flat terrain heightmap. To start, you need to define the terrain surface, a 2D heightmap, i.e. a function f(u,v) of two coordinates that returns a height value, so you can create a 3 dimensional surface g:

a

Figure 8. Creating three dimensional UV field [5]

We can use this formal description to find tangent and normal vectors. A vector is tangent when its direction matches the slope of the surface in a particular direction. Differential math tells us that slope is found by taking the derivative. For functions of multiple variables, that means we can find tangent vectors along curves of constant v or constant u. These curves are the thin grid lines in the diagram. To do this, we take partial derivatives with respect to u (with v constant) and with respect to v (with u constant). The set of all partial derivatives is called the Jacobian matrix J, whose rows form the tangent vectors tu and tv, indicated in red and purple:
a

Figure 9. Creating the surface normals [5]

The cross product of those tu and tv gives you n, the surface normal.

a 

Figure 10. Creation of the spherical mapping [5]

The principle behind the spherical mapping is this: first we take the vector (s, t, 1), which lies in the base plane of the flat terrain. We normalize this vector by dividing it by its length w, which has the effect of projecting it onto the sphere: (s/w, t/w, 1/w) will be at unit distance from (0, 00). Then we multiply the resulting vector by the terrain height h to create the terrain on the sphere's surface, relative to its center: (h·s/w, h·t/w, h/w) [5]

Just like with the function g(u,v) and J(u,v), we can find the Jacobian matrix J(s,t,h) of k(s,t,h). Because there are 3 input values for the function k, there are 3 tangents, along curves of varying s (with constant t and h), varying t (constant s and h) and varying h (constant s and t). The three tangents are named ts, tt, th. [5]

a

Figure 11. Creation of the spherical mapping [5]

The three vectors describe a local frame of reference at each point in space. Near the edges of the grid, they get more skewed and angular. We use these vectors to transform the flat frame of reference into the right shape, so we can construct a new 90 degree angle here. That is, to find the partial derivatives (i.e. tangent vectors) of the final spherical terrain with respect to the original terrain coordinates u and v, we can take the flat terrain's tangents tu and tv and multiply them by J(s,t,h). Once we have the two post-warp tangents, we take their cross product, and find the normal of the spherical terrain.

It's important to note that this is not the same as simply multiplying the flat terrain normal with J(s,t,h). J(s,t,h)'s rows do not form a set of perpendicular vectors, which means it does not preserve angles between vectors when you multiply by it. In other words, J(s,t,h) * n, with n the flat terrain normal, would not be perpendicular to the spherical terrain.[5]

6. Conclusion

Texturing is one of the basis elements in 3D visualization. Its use in terms of generating 3D terrain is very important because of couple of reasons.
First is based on colour map which gives terrain its form and atmospheric look. It is used for granting extra details and by that 3D modelling artist doesn’t need to model every rock or hole. Texture does that for you, and by that the performance of visualization are better. Textures can also be used for generating relief and walls also known as collisions. The texture map that does this is called Hightmap and it is used widely. Besides of Hightmaps, there are different types and methods for generating terrain and its functionality. Commonly used are Meshes but they are also expensive in terms of processor usage. Every texture has its own two dimensional space. It is wise to pick standard forms of texture maps. Be aware of Power of two rules. If the texture size is multiple of number 2, only then will texture be shown correctly.
There are various types and formats of textures for the engine use. Keep in mind the table shown in this paper. Important functional means of texture maps are also shown here. This is especially related to Normal mapping and the use of Normal maps. There are free programs that can generate quality Normal maps, they aren’t listed here, but authors are well familiar with them. The meaning of Normal mapping is related to simplification of the 3D model and renders it in Hi quality details preview. This is done by translating Hi detailed texture map to the surface of Low poly model.
The program or engine for visualization is getting the base model from Low poly mesh, and all details from 2D texture map. Results are stunning and this is considered to be the standard in computer graphic technology.

7. References

  • 3dkingdoms, available at: http://www.3dkingdoms.com/tutorial.htm, seen on 16.08.2012.
  • Acko.net, available at: http://acko.net/blog/making-worlds-3-thats-no-moon/, seen on 14.08.2012.
  • Gamedevelopment, available at:  http://gamedev.stackexchange.com/questions/15573/heightmap-voxel-polygon-geometry-terrains, seen on 14.08.2012.
  • Illustrations: Steven Wittens, steven@acko.net, seen on 15.08.2012.
  • Illustrations: 3D models by Josh Hess, seen on 15.08.2012.
  • KatsBits, available www.katsbits.com/tutorials/textures/make-better-textures-correct-size-and-power-of-two.php, seen on 13.08.2012.
  • Normal Maps available at: wiki.polycount.com/ NormalMap, seen on 16.08.2012.
  • Unity 3D, http://docs.unity3d.com/Documentation/Components/class-Texture2D.html, seen on 13.08.2012.
Patrik Ervells latest collection is ironically titled “Software”ADIDAS ORIGINALS TUBULAR SHADOW. In the notes from the presentation, Ervell says he was interested in developing tension between nostalgia and sci-fi,NIKE ZOOM WINFLO 3 and even included 90s cyberpunk amongst his influences. Ervell developed this point of view by creating an imaginary software company called Idegen software systems. He then re-appropriated the company’AIR JORDAN XXXI MENs logo in several of the collection’s garments. Elsewhere,MBT TARIKI MEN mohair coats with oversized lapels made an appearance alongside mock neck tees,NIKE AIR JORDAN RETRO 5 police-inspired ribbed sweaters,MBT FORA GTX WOMEN flight bombers, and polyurethane leather coats. The setting was also suitably dystopian, and the resulting ambiance was something akin to if the creators of Deutschland 83 and Hackers met up and decided to create a collection… We mean that as a compliment.Yesterday afternoon,JORDAN CP3 IX MEN artist JR spent the day working on his latest collaborative piece with Daniel Arsham in Greenpoint,NIKE AIR MAX 90 Brooklyn,MBT KIMONDO GTX MEN NYC. Connecting the lines between art, architecture, dance and theater, Daniel Arsham has been known to subvert existing architectural structures in unconventional,NIKE CLASSIC CORTEZ NYLON playful ways; confusing and confounding the expectations of space and form. Source: Street Art News .