In this
article, I'll examine some of the issues you may want to consider when
starting to create a terrain tile set for a game. When done well, the
terrain becomes a believable world in which your characters come to life.
The user will simply accept your work as part of the natural backdrop.
Often, the best compliment for a good environment is that it doesn't call
attention to itself.
As the terrain
artist, you may not have a ton of texture memory space to deal with, so
it's always a good idea to figure out how to stretch your budget as far
as possible. Obviously, the larger the number of base texture tiles, the
more random (and hence natural) the terrain will look. When only a few
terrain tiles are available, a repetitive pattern becomes very obvious.
The trick is maximizing the usage of each texture while minimizing the
disjoint that occurs when you see the same pattern over and over.
The Basics
Before you
begin, you will need to evaluate the needs of your particular project.
Let's assume that you are trying to make one large plain of cooled lava
stone. In theory, you can accomplish this with just one texture map tile
and one large polygon. You can tile the texture map multiple times on
the single polygon, which gives the appearance of a higher resolution
on the terrain. While this method works conceptually, it can quickly lead
to some technical problems, such as the inability to add additional texture
variety into the field, and shading issues over a large polygon.
Another
method is establishing a grid of polygons similar to a chessboard mesh.
You can map each square with a different texture map, and there is a lot
more flexibility with what you can do on an individual square basis. This
method addresses some of the variety and shading issues as well as making
the process of editing and tweaking much easier.
Now, suppose you want to add a lake of molten magma to the middle of the
landscape. With the single large polygon method, you'll quickly face some
problems. Since you can't interrupt the tiled terrain and insert a different
texture map in the middle of the sequence, you have to figure out an alternative
method. One such alternative is to include the lake in one large texture
map. While this would allow you to create a completely custom terrain,
you will quickly encounter texture memory usage and texture resolution
challenges.
The other alternative is to make a custom polygon for the magma only,
and then perform a Boolean operation on that polygon, combining it with
the other terrain polygon. This too presents some particular problems
if you are using vertex shading to light your terrain. In addition, making
the seam between the two texture types invisible will prove to be difficult,
if not impossible.
For this
tutorial, I'll focus on a more forgiving method of maximizing the effect
of your tiled terrain by using a standard grid and texture-mapping each
polygon quad or set of quads as a unique element. This method will allow
you to control the layout of the textures much more accurately, and it
also provides vertex-shading advantages. In addition, when you start to
add vertical information to your mesh, you will find that the additional
vertices give you more control of the 3D aspects.
Creating the Basic
Flood Fills
When making
a texture tile set, you'll need to create a minimum set of tiles. The
complexity of the planned environment will determine the number of tiles,
how well the tiles appear visually without showing repetitive patterns,
and how many different types of random tiles will be required. The amount
of available memory for the terrain will impact all these factors. As
a good starting point, create the minimum base set, then add to it only
when necessary. Reuse is king, so try to stretch your texture budget as
far as possible.
The number
of different terrain types you will have in your environment will be another
big impact on your tile set. This impact can be compounded by which terrain
types can touch or transition with one another. Take, for example, a terrain
that consists of water, sand, and grass. If water can only touch sand
and sand can only touch grass, then you only have two transition sets
to make. However, if water touches grass as well, then an additional transition
set is required. As you can tell, planning out the environmental requirements
ahead of time makes a lot of sense. You may find areas where you need
to limit the number of transitions in order to keep the texture budget
in check.
For the
sake of argument and to keep the number of variations low, I'll assume
that the new terrain will consist of two basic ground types: stone (cooled
lava) and molten lava. This will require you to make only one transition
set. For now, don't concern yourself with the 3D aspects, and assume that
the terrain is a flat plain.
First, create
the flood-filled texture for each basic ground type. This is the basic
tile that is used as the default flood fill of an area. If possible, since
it stretches your texture budget, it's a good idea to make the texture
able to tile in any direction, even if it's rotated 90 or 180 degrees.
This will give you more visual mileage out of a single texture by breaking
up the repetitive pattern of the texture when you lay it down next to
itself.
In Figure
1, you can see the stone texture in its original orientation. It's easy
enough to use the Offset filter and Rubber Stamp tool in Photoshop to
make a texture seamless, but you're limited to only one orientation. If
you rotate it and try to place it in a grid, the seam will be plainly
visible. In order to make a tile seamless when it rotates, the texture
needs to have identical edge pixels on each of the four sides. This requires
a bit more work than just using the Offset filter, but it also extends
the usability of the texture. With a bit of Photoshop magic, you can create
the seamless effect pretty easily.