3dRender.com Fixing Lighting Irregulaties in Self-Tiling Maps
Tutorial by Jeremy Birn
Back to Main Index.

Adapted & Shortened from
Digital Lighting & Rendering
Digital Lighting & Rendering

By Jeremy Birn

Most 3D artists know how to process a photograph into a self-tiling map in Photoshop, using Filter > Other > Offset (set to "wrap around") to bring the seams to the center, so you can clone over them. But, in problem situations such as the photograph below, the Offset filter reveals that there are color and lighting shifts running across the original picture. This tutorial shows how to get rid of overall color and brightness shifts before making a tiling map.

The Original Picture of a wooden post was shot with a Nikon Coolpix 950 digital camera. Click here if you want to download the 1600x1200 image and follow-along with the same map. The file is 415 K.

The initial result of Filter > Other > Offset shows lighting irregularities. Undo this! You're not ready to start cloning. Even if you made the edges of your map seamless, these shifts could become a visible artifact in your map if the map is repeated several times.

Here's a quick and efficient way to nuetralize overall color and brightness shifts in a picture, before you do the Offset:

1.  In the Layers window, drag the Background layer down
    onto the Create New Layer icon. (A new layer named
    Background Copy is created.)

2.  With the new layer active, press Ctrl-i
    (or choose Image > Adjust > Invert from the menu.)
    Your picture will look like a color negative.

3.  Choose Filter > Blur > Guassian Blur from the menu.
    Enter enough blur to hide all of the significant detail from your picture.
    Often a number between 20 and 40 works well, although very high-resolution
    originals may require more blurring to hide the details of the shot. Be
    careful to use enough blur that all the detail is hidden - otherwise this
    technique might cancel-out local detail that you want to preserve!

4.  In the Layers window, slide the Opacity down to 50%.

If you were only trying to correct luminance shifts, then you could also change the Blending Mode for this layer to Luminance - but in this case, we need to fix both the color and the brightness, so it stays at Normal.

5. In Layers, choose Flatten Image.

The result will be flat and uniform, but will lack contrast. (NOTE: Experienced Photoshop users may observe that what you've done could alternately be achieved with the High Pass filter set to the same radius - but building your corrections in layers is more versatile, and allows for alternatives such as setting the top layer to a Soft Light blending mode.)

6. Choose Image > Adjust > Levels, do one channel at a time with ctrl 1, ctrl 2, ctrl 3 and pin the levels to the existing dark and light points of each channel, before you ctrl ~ switch back to all at once. Doing this right will rebuild the color balance as well as the contrast.

Note: We've only got 8 bits a channel here - for this to appear lossless and not cause banding in the histogram of the final map, you need to work with an image that is higher resolution than your final map, such as starting with a 1600x1200 image that will be scaled before use into 512x512 or 1024x1024 final.

7. Now, finally, you can do the Filter > Other > Offset again, and this time it will work well:

In this case, the horizontal seam is almost invisible, and the vertical seam only needs a little cloning.  (Compare this with the second image in this tutorial, and see how much better it is!)

8. Clone over the seams to hide them, using the Rubber Stamp (cloning) tool. (Before Offsetting, you might also want to copy an area a few hundred pixels wide from the right side of the image, shift-ctrl-i, and crop the remaining area. After offsetting horizontally, you can paste the right edge next to the seam, and offset both layers vertically. This way you can selectively erase parts of the overlap area to start blending the seam before you begin to clone.)

This version of the map now seamlessly tiles in horizontal and vertical directions, with no luminance shifts!

Click here to see the completed map tiling.

One more thing to try: Press Ctrl-Alt-Z a few times to move back in history to step 4. This time, leave the opacity of the top layer at 100%, but change it's blending mode from Normal over to Soft Light.  Soft Light will not be as complete and uniform an equalization, but it will help your image's consistency without lowering the contrast. Make another copy of your Soft Light layer if that result isn't strong enough at 100%.

source: The book Digital Lighting & Rendering explains this and many other texture mapping techniques in more detail.

All contents of this page Copyright © 2000-2006 by Jeremy Birn. Please do not copy without prior written permission.