With a heightmap, you store only the height component for each vertex (usually as 2D texture) andprovide position and resolution only once for the whole quad. The landscape geometry is generatedeach frame using the geometry shader or hardware tessellation. Heightmaps are the fastest way tostore landscape data for collision detection. You only need to store one value per vertex and noindices. It's possible to improve this further by using detail maps or a noise filter to increase perceiveddetail.[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 torender terrain. This was referred to as voxel graphics in older games. It's possible to change theresolution of

the generated mesh based on distance from the camera. This will cause the shiftinggeometry if the resolution drops too far, but can be used for interesting effects. Heightmaps can easilybe created by blending noise functions like fractal Perlin Noise and heightmap editors are fast andeasy to use. Both approaches can be combined. They are also easy to work with in an editor. Ahorizontal position maps directly to (usually) one to four positions in memory, so geometry lookupsfor physics are very fast.[3]

2

There usually can't be holes in the ground or overhanging cliffs. You can only control the preciseheight of each point if the grid size matches the texture coordinates. If the four vertices that define asub-quad aren't on the same plane, the split between the two vertices will become visible. This usuallyhappens on steep cliffs with edges that don't follow a cardinal direction. Heightmaps are the mostefficient 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 storageper 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 inolder 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 featureslike 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 withpredefined terrain features (trees,

dungeons). To render voxel data, you either have to use a ray traceror compute a mesh, for example with marching cubes. Neighboring voxel aren't independent for meshgeneration 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 useslots of memory. It'soften not practicable to load the voxel data into VRAM for this reason, as you'd have to use smallertextures 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 itcan 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 oftenused in games where precise control or advanced terrain features are needed. You only have to do theusual projection calculation in the vertex shader. A geometry shader isn't needed. All coordinates arestore individually for each vertex, so it's possible to move them horizontally and increase mesh densityin 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, sothere won't be any glitches or strange-looking borders. It's possible to leave holes and createoverhangs. 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 toan area that should be modified is slow. Unlike in heightmaps and voxel data, the memory address fora 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 runslower than with the other storage formats.Polygon terrain is often uses in games that don't have largeopen areas or can't use heightmap terrain because of its lack of precision and overhangs.

3

Table 1. Techniques for terrain generation

Heightmaps

are the best solution if you don't need overhangs or holes in the terrain surface and usephysics 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 renderingthem 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 youhave 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 thatneed particular attention paid to them. The following section will discuss one of the core ''rules'', thatoftexture size, their dimensions

and how that relates to a form oftexture optimization, somethingcommonly called the ‘’Power of two’’rule. The main question was: Is our project affected by thisrule and what types of media projects use this rule?[2]

services. The technology behind every type ofmedia or game is built on the same fundamentalpower of two rule. Is it necessary for developer toformat 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 asto what developer wanted

to do with it.The rule is a

fundamental necessity

due to the way gameengines work, there's actually a long history associated with game and content development that has todo 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 tothepower of two rule

as it sets hard coded, physical restrictions on media in such a way that itmust

conform to it directly.

And here-in lies the problem where textures are concerned, if they don'tconform to the expected parameters, game are forced to physically alter assets and in so doing,wasteresources

both in terms of time and processing power, fixing the problem. In effect the essence of thepower of two rule

is 'optimization', being as efficient and 'lite' as possible whilst providing the user anappropriate visual experience. Here is an example of how the texture is previewed in developer’sscene

before it is built for engine.[2]

4

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 somethingif 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 textureapplied 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'shaving 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 aseries of regular dimensions.Typically this meansdoubling up

ordividing down

by two. So texturesizes that have or are limited to "8", "16", "32", "64", "128", "256", "512", "1024", "2048" (or higherfor more modern games) in one or more width/height direction are regarded as beingvalid

andproperlyoptimized

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 thecorrect (or 'valid') power of two dimensions. The second don't, as is highlighted by the visible extraarea

representing the amount of space the texturesshould

be occupying; the amount of extra visibledirectly correlates to the amount of forced resizing an engine is required to do to fix the problem ofincorrect proportions so the textures can be used properly.[2]

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

[2]

5

Ignoring the power of two rule has a number of knock-on effects for texture making, one of whichrelates directly to image quality. Because a game engine has to physically adjust the size anddimensions 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-

becomeblurred, pixilated or have some other visual artifacts appear due to the resize process having toextrapolating 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 ormegabytes. The solution is to pay greater attention to the size of the original image, making surethey're properly proportioned so they're loaded into, and displayedby, an engine correctly.It ispossible to use other (non power of two) texture sizes with Unity. Non power of two texture sizeswork best when used on GUI Textures. However if used on anything else they will be converted to anuncompressed RGBA 32 bit format. That means they will take up more video memory (compared toPVRT(iOS)/DXT(Desktop) compressed textures), will be slower to load and slower to render (if youare 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 supportedby 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 justfine. 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 itallows 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 onreal-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. Youshould always use mipmaps for in-game textures; the only exceptions are textures that will never beminified (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 areasof grass, rocks sand, etc... If terrain has a decent size, it will end up very blurry. Detail textures hidethis fact by fading in small details as your main texture gets up close.ADetail texture

is a small, finepattern 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-127makes the object it's applied to darker, 128 doesn't change anything, and lighter colors make the objectlighter. It's very important that the image is centered around 128-

otherwise the object it's applied towill 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 todefine a second "Detail" texture that will gradually appear as the camera gets closer to it. It can beused on terrain, for example. You can use a base low-resolution texture and stretch itover the entireterrain.[7]

When the camera gets close the low-resolution texture will get blurry, and you don't wantthat.

To avoid this effect, create a generic detail texture that will be tiled over the terrain. This way, whenthe camera gets close, the additional details appear and the blurry effect is avoided. The Detail textureis put "on top" of the base texture. Darker colors in the detail texture will darken the main texture andlighter colors will brighten it.[7]

6

Table 2. Formats and compatible platforms

Normal Maps

Normal maps are used by normal map shaders to make low-polygon models look as if they containmore detail. Some game Engines uses normal maps encoded as RGB images. Developer also has theoption 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 amore detailed model. It does not actually add any detail to the geometry, so the edges of the modelwill still look the same, however the interior

will look a lot like the high-res model used to generatethe normal map. The RGB values of each texel in the the normal map represent the x,y,z componentsof 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 resmodel is virtually unlimited. However the amount of detail from the high-res model thatwill becaptured by the normal map is limited by the texture's resolution.

Figure 4. Low–

Hi poly and usage of Normal maps

7

The most basic information you need for shading a surface is the surface normal. This is the vectorthat points straight away

from the surface at a particular point. For flat surfaces, the normal is the sameeverywhere. For curved surfaces, the normal varies continuously across the surface. Typical materialsreflect the most light when the surface normal points straight at the light source. By comparing thesurface normal with the direction of incoming light, you can get a good measure of how bright thesurface should be under

illumination:

Figure 5. Lighting a surface using its

own and Hi resolutionnormals

[5]

To use normalsfor 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 ofthe shading to the level of detail in the geometry. A second, betterway is to use a normal map. Youstretch an image over the surface, as you would for applying textures, but instead of color, each pixelin the image represents a normal vector in

3D. Each pixel's channels (red, green, blue) are used todescribe 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 thenormal

map. The benefit of this approach is that you can stretch a high resolution normal map overlow 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 thesame. The main idea behind using tangent space is going through extra steps to allow the reuse of anormal map texture across multiple parts of the model. Storing normals / tangents / binormals at thevertices, and computing the normals of the normal map relative to them, then converting back whenrendering. Also, you could use tangent-space to skin a flat bump texture around a model.[5]

Figure 7. Low and Hi res Raptor

[9]

8

A limitation of Object Space normal mapping, as opposed to using Tangent Space, is that every pointon the skin must have its own distinct UV coordinates. You can't reuse parts of the texture for multipleparts of the model. This is a pretty common practice: perhaps both sides of the Raptor's face will havethe 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 onopposite sides of the Raptor's face will obviously have to point in different directions, so they eachneed to be defined by separate areas of the texture. There is a way around this for parts of a model thatare completely symetric along an axis. Only generate the normal map for one side, and then rendereach 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 definethe terrain surface, a

2D

heightmap, i.e. a

functionf(u,v)

of two coordinates that returns a height value,so you can create a

3

dimensional

surfaceg:

Figure 8. Creating three dimensionalUV field[5]

We can use this formal description to find tangent and normal vectors. A vector is tangent when itsdirection matches the slope of the surface in a particular direction. Differential math tells us that slopeis found by taking the derivative.

For functions of multiple variables, that means we can find tangentvectors along curves of constantv

or

constantu. These curves are the thin grid lines in the diagram. Todo this, we take partial derivatives with respect

tou

(withv

constant) and with

respect

tov

(withu

constant). The set of all partial derivatives is called the Jacobian matrix J, whose rows form thetangent

vectorstu

andtv, indicated in red and

purple:

Figure 9. Creating the surface normals

[5]

The cross product of thosetu

andtv

gives

youn, the surface

normal.

9

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 thebase plane of the flat terrain. We normalize this

vector by dividing it by its

lengthw, which has theeffect of projecting it onto the

sphere:(s/w, t/w,

1/w)

will be at unit distance

from(0,

0,

0). Then wemultiply the resulting vector by the terrain

heighth

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 functiong(u,v)

andJ(u,v), we can find the Jacobian

matrixJ(s,t,h)

ofk(s,t,h).Because there are

3

input values for the

functionk, there are

3

tangents, along curves of

varyings

(with

constantt and

h),

varyingt

(constants and

h) and

varyingh

(constants and

t). The threetangents are

namedts,tt,th.[5]

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 intothe 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 coordinatesu

andv, we can take the flat terrain's

tangentstu

andtv

and multiply them

byJ(s,t,h). Once we have the twopost-warp tangents, we take their cross product, and

find the normal of the spherical

terrain.

10

It's important to note that this is not the same as simply multiplying the flat terrain normal

withJ(s,t,h).J(s,t,h)'s rows do not form a set of perpendicular vectors, which means it does not preserveangles between vectors when you multiply by it. In other

words,J(s,t,h) *

n, with n the flat terrainnormal, 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 isvery important because of couple of reasons.

First is based on colour map which gives terrain its form and atmospheric look. It is used for grantingextra details and by that 3D modelling artist doesn’t need to model every rock or hole. Texture doesthat for you, and by that the performance of visualization are better. Textures can also be used forgenerating relief and walls also known as collisions. The texture map that does this is called Hightmapand it is used widely. Besides of Hightmaps, there are different types and methods for generatingterrain and its functionality. Commonly used are Meshes but they are also expensive in terms ofprocessor usage. Every texture has its own two dimensional space. It is wise to pick standard forms oftexture maps. Be aware of Power of two rules. If the texture size ismultiple of

number2, only thenwill texture be shown correctly.

There are various types and formats of textures for the engine use. Keep in mind the table shown inthis paper. Important functional means of texture maps are also shown here. This is especially relatedto Normal mapping and the use of Normal maps. There are free programs that can generate qualityNormal maps, they aren’t listed here, but authors are well familiar with

them. The meaning of Normalmapping is related to simplification of the 3D model and renders it in Hi quality details preview. Thisis 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 detailsfrom 2D texture map. Results are stunning and this is considered to be the standard in computergraphic 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.