Reader small image

You're reading from  Grome Terrain Modeling with Ogre3D, UDK, and Unity3D

Product typeBook
Published inFeb 2013
Reading LevelIntermediate
Publisher
ISBN-139781849699396
Edition1st Edition
Languages
Right arrow
Author (1)
Richard A. Hawley
Richard A. Hawley
author image
Richard A. Hawley

Richard Hawley started programming in the early 1980s at the start of the home computer craze with the Sinclair ZX-81. Before leaving high school he had worked on three game projects for Assassin Software and later worked on conversions of classic strategy board games for 8- to 16-bit machines. He went on to develop end-user tools for popular flight simulations including Empire Interactives Enemy Engaged helicopter series and the highly successful Origin Janes Longbow series (MissioneerPlus). Hes the director of Tricubic Studios, a small UK company dedicated to creating simulation and training environments using off-the-shelf 3D engines including Unity and Leadwerks. Together with technical artist David Hopkinson (Total War: English Civil War conversion) and physics guru Fred Naar (creator of Helicopter Total Realism for Microsoft Flight Simulator X) they are collectively known for their work on helicopter simulations.
Read more about Richard A. Hawley

Right arrow

Chapter 4. Textures and Lighting

What's the greatest thing about standards? Well, there are so many to choose from. Game engines such as Unity3D, UDK, Ogre3D, and so on, all load textures for materials. A material is like a cooking recipe, it has a bunch of ingredients (textures) and instructions on how to mix them together. The problem is that there isn't any standard for exchanging materials between these engines or GROME. Some assembly is required.

The GROME exporter will save each of its material layers for every zone. This is potentially quite a large number of files if we get out of control with the number of layers we use. For that reason it's sensible to think about how we can combine layers and how we're going to deal with things like noise textures in the host engine.

Ogre3D is an open source and extensible rendering engine. Of the engines we'll be looking at in this book it's the only one that has a terrain plugin natively using GROME's Graphite engine. Scene composition and rendering...

Performance consideration for mobiles


Unity3D on mobile platforms such as iPhone and Android will likely require shadows and lightmaps baked into the terrain textures. Real-time lighting and shadows on terrain objects is simply too costly in terms of performance. All texture layers should be merged into a single layer for these platforms. This is done using the ColorBake tool which we'll look at in this chapter.

Working with material layers


The workspace panel, once again, has a layer stack for working with textures called Materials. Similar to other modes we need an active layer for our tools to work.

So before we can work with textures we must have at least one material layer armed, and have a zone assigned to that layer. Go ahead and create a couple of material layers; call them Beach, Plains, and Mountains.

Terrain textures are rendered as layers in the order they sit on the stack. The top-most layer being rendered last.

Assigning zones to a layer


As with heightmaps we assign zones to a layer by right-clicking on the layer and selecting the Assign to selection. For material layers a dialog box appears asking for texture information.

There are two types of material layers, how you populate this dialog will determine the layer type. A material can be a simple color layer ( a texture stretched over the terrain surface) or a masked texture.

Color textures


A color texture allows us to add a texture (such as a satellite image) to a zone but more importantly they allow us to paint color directly using the ColorBrush tool. This give the artist full control over feathering and shading effects.

Color textures really come into their own when combined with other layers to create tonal variations across a landscape on a zone-by-zone basis.

In the preceding screenshot, the image on the left-hand side is our example island terrain with multiple texture layers added. The image on the right-hand side has an additional simple color layer assigned. This is a simple texture added for tonal variation. By setting the material blend mode to Color Add (blend modes in GROME are referred to as "Shader configuration") the color from the texture is blended.

Each zone in the layer can have its own texture and blend mode by activating the layer stack Selected button and expanding the tree. Clicking on the texture assigned to each zone allows you to individually...

The texture toolset


The fourth tab on the tools panel brings up the texturing features. The drop-down control allows us to select between the brush, procedural, and decal tools.

ColorGen tool

This tool requires an active color texture and paints areas that match specified terrain parameters (altitude range, slope, orientation) with a color.

It does this using a component you'll see in several of the texture tools, called a Distribution Mask (DM), these are found in the rollup of the ColorGen and MaskGen tools. They tell the editor how we want to apply a color or texture to a terrain based on a set of parameters. The tools can use one or more DMs and process them in a single operation although they can be fiddly to work with and often it's easier to use one at a time on different layers. Let's look at a single Distribution Mask component, refer back to this section if you need a reminder.

Distribution Mask component

The plus and minus icons at the top will add and remove Distribution Masks....

Vertical texture mapping


This is the process by which we combine two texture layers to correctly map a flat texture to vertical surfaces such as mountains and cliff faces. Some 3D engines can have some kind of vertical mapping built into a pixel shader which is very handy when available. However, we can't always rely on this; for our project we can assume the mobile platforms will require baked textures with correctly mapped vertical surfaces. We can create two layers to achieve accurate vertical mapping in the following manner:

  • Create our first material layer for cliffs, we'll name this Mountains 0-90.

  • Assign it a nice Canyon Rock texture (such as the arid2/canyon_rock01.tga texture as provided in the GROME texture library).

  • Create a new mask, default values are fine for this example.

  • In the parameters for the texture set the UV tiling to something that fits the scene (for example 20, 20). Set the HV spin for this layer to 0, 90. This is shown in the following screenshot.

  • Now the tricky part...

Let it snow


For a change of scenery let's add some snow to highland regions. Create a new material layer (we'll call it SnowField). Assign the terrain zones to the layer and we'll pick the texture terrain/cold/snow02.dds, setting the tiling UVs to 100. For the mask we'll create a new one with a size of 1,024.

Go to the MaskGen tool, pick the preset named MountainsSnow. We'll only use one Distribution Mask from this, the one named Snow but we'll edit the Height settings as thus:

 

Height

Slope

Min

1000

0

Max

10000

30

Att

150

5

Assign the Snow Distribution Mask to the Layers in use (the material layer called SnowField should be armed to appear in the list). Click on the Apply button.

The brush tools


The brush tools are near identical to those used for heightmaps and selection masks. The obvious difference is that the ColorBrush tool paints the selected color into the active color layers.

The MaskBrush tool is useful for touching up masked textures. The color value here is a simple intensity slider offering values from 0 to 255. Transparent being 0 and fully opaque being a value of 255.

The package browser


This is a common dialog that typically appears when you select a texture, mask shape, or 3D object. It's simply a tool that presents previews of files contained within installed packages and your own filesystem. It's recommended you make use of the Favorites feature when working collaboratively, adding your own files by clicking in the tree and selecting Add to favorites.

Decals


Apart from painting with textures, GROME can use decals to apply spot graphics such as helipads or scorched earth. Decals are individual objects that project images down onto a surface. While individual game engines might support some kind of decal system, they will not translate. It's not possible to bake decal objects into a texture prior to export but as objects they can be exported. However; the onus is on the end user and the host engine to load and handle them. We'll have a quick look at the Decal tool.

Before creating any decals you must (as with all other tools) create a Decal layer on the layer stack then assign at least one terrain zone to the new layer. When you click on Assign to selection the New Decal Layer dialog appears. This is shown in the following screenshot:

Decals are treated as individual objects you can position with the mouse. They lay flat with the terrain but they are made from triangular meshes that are updated with terrain height information when you edit...

Summary


In this chapter, we looked at the hand brushing, procedural texture tools, how to build a shadow map and bake multiple layers into a single texture. We looked at normal maps, the package browser, and finally the decal tool. In the next chapter, we'll look at vegetation, grass, trees, and detail layers.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Grome Terrain Modeling with Ogre3D, UDK, and Unity3D
Published in: Feb 2013Publisher: ISBN-13: 9781849699396
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Richard A. Hawley

Richard Hawley started programming in the early 1980s at the start of the home computer craze with the Sinclair ZX-81. Before leaving high school he had worked on three game projects for Assassin Software and later worked on conversions of classic strategy board games for 8- to 16-bit machines. He went on to develop end-user tools for popular flight simulations including Empire Interactives Enemy Engaged helicopter series and the highly successful Origin Janes Longbow series (MissioneerPlus). Hes the director of Tricubic Studios, a small UK company dedicated to creating simulation and training environments using off-the-shelf 3D engines including Unity and Leadwerks. Together with technical artist David Hopkinson (Total War: English Civil War conversion) and physics guru Fred Naar (creator of Helicopter Total Realism for Microsoft Flight Simulator X) they are collectively known for their work on helicopter simulations.
Read more about Richard A. Hawley