• entries
443
1190
• views
772094

# Wang Tiles

1286 views

Wang Tiles!

Sounds kinda dirty, I know, but according to Wikipedia, Wang tiles are sets of tiles that can be used to seamlessly tile a plane, while reducing the visual artifacts of repetition. By constructing a set of Wang tiles, you can piece together arbitrarily large regions of texture using the pieces from the Wang tile set to fill the region. Some sets of Wang tiles tile the plane aperiodically, meaning no overall repeating pattern is generated.

The way a set of Wang tiles is generally depicted, colors are used to "code" the edges. A green left edge, for instance, will tile with a green right edge. So these color-coded edges represent the patterns of pixels along that edge.

In theory, the idea is pretty neat. You have a bag of tiles you can mix-n-match to fill the plane without too much obvious repetition. In practice, however, I've found them to be a bit of a pain. At least, creating the artwork for the textures can be a pain. Consider a set of 8 Wang tiles. The top/bottom edges can be either "Red" or "Green", the left/right edges can be either "Yellow" or "Blue".

Such a set could be constructed using some creative blending of different texture sources, one source for each of the edges. However, doing so results in the same sort of blending artifacts I discussed 2 journal entries ago in the seamless noise mapping discussion. Values in the middle become murky and muddy.

I'm trying to work out simpler methods of creating Wang tile sets from procedural noise texture functions, but so far all that I've come up with that eliminates the blending artifacts and minimizes distortion is an algorithm using an N-dimensional noise function such that N is equal to 2 times the number of colored edges. Each colored edge has endpoints at 0, and traces a circle on the plane formed by 2 coordinate components, these components being unique to each color code. So a red edge might trace a circle on XY, a green edge might trace a circle on ZW, and so on. Thus the simple 4 color example above would require an 8-dimensional function. Conceptually, it's easy; extending a noise function to N-dimensions isn't that hard once you know how the function works. Programatically, it's a pain, necessitating the use of simplex noise, since the interpolated variants rapidly explode in complexity. 8-dimensional noise would require 257 individual linear interpolations between 256 generated noise values per octave (for fractal noise) per pixel. That's a lot of computations, considering my typical use of 8 to 10 octaves per function, and the fact that any interesting texture is going to be composed of multiple noise functions combined together.

Using N-dimensional noise this way only gets more complicated as you attempt to use larger Wang sets with more colors, or edge patterns. The more tiles you can include in a set, the greater the reduction of visible repetitiveness you achieve, so it is not unlikely that you might use Wang sets with 6 or more color coded edges. That's a lot of dimensions, too many to be practical in my opinion. So I'm still looking for a simpler alternative that meets my criteria of reducing distortion and blending artifacts.

EDIT: Actually, now that I'm thinking about it, even this multi-dimensional approach would still introduce distortion, since there would be a blend across the texture from one dominant plane to another, causing a warping effect. I just might be stuck with explicit blending-based methods for this. Ugh.

## 1 Comment

Quote:
 Original post by JTippetts Wang Tiles! Sounds kinda dirty, I know, but...

What a great way to start a journal entry [grin]. It really did make me laugh out loud...

## Create an account

Register a new account

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!