Dan Silverman continues his texture tutorials - this is the second part.

Creating Seamless Textures

Seamless textures are a necessity for real time 3D environments. Without them, your levels would simply look unnatural. In this article we will look at my preferred method for creating seamless textures. There are many other ways of creating textures that tile seamlessly, but my method should be a good starting point for you. Because I use Photoshop to create my textures, a lot of the "tool" names will be those used by Photoshop. Even so, you should be able to find similar tools in other image manipulation programs such as Paint Shop Pro or even GIMP.

First we need an interesting image to use as a texture. Below is an image of a rusted piece of metal with a square bolt in it:

While this image is interesting, there are several problems with it. The first problem is that it is not the proper size to be used in 3D Game Studio. Most real time 3D engines need textures to a power of two in size. This means a texture must be one of the following sizes either horizontally or vertically: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc. Vertical and horizontal edges of textures do not have to be the same size, so you can "mix-n-match" the sizes: 16x32, 512x128, 256x256, etc. In order to use our rust texture in 3D Game Studio, we must get it to conform to power of two. In Photoshop I simply adjusted the size to the nearest power of two. In this case, the size ended up being 256x128. (Please note that 3DGS does not necessarily need a power of 2 texture size, but these sizes look better and use less memory so they should be used
whenever possible - George's note).

Even though the texture is the proper size to use in 3D Game Studio, it may not necessarily tile properly. To check this we need to use a very important tool in Photoshop called the OFFSET tool. This tool can be found under FILTER>OTHER>OFFSET. Once you have selected the Offset tool you will have to set the amount of offset in the vertical and horizontal directions. I normally set a number that is half the size of the image.

As you can see, this image does not tile properly. The next most important tool in my Photoshop arsenal is the CLONE STAMP tool. This tool looks like an office stamp in the Photoshop tool bar. The Clone Stamp tool will allow you to place a "marker" on your image and clone that area on another part of your image. As you move your pointer about, the marker moves and that area is cloned to where you are pointing your mouse on your image. Once you have selected the Clone Stamp tool, press the ALT key on your keyboard and then click in the area you want to clone. Release the ALT key and begin to paint on your image. You will see that you are now cloning part of your image over the area you painting. You can use this tool to hide the seams that appear when you used the OFFSET tool.

Even though you have removed the seams using the CLONE STAMP tool in your offset image, this does not mean you did not end up creating some new ones! To check this, use OFFSET again. In the image below you can see that I ended up creating a few seams.
 

To correct this I simply go back to my CLONE STAMP tool and try to cover them up.

Sometimes you will find that you have to go back and forth with OFFSET and the CLONE STAMP tool to get rid of any seams. After some practice you will learn what to avoid so that you will not have to do this so much.

Now we have a seamless texture:

And here is what it looks like applied to a few walls in 3D Game Studio:

Well, I hope this lesson helps you along your way to creating great seamless textures! Next time we will explore the importance of ornamental textures.