Showing posts with label Tilesets. Show all posts
Showing posts with label Tilesets. Show all posts

Wednesday, November 11, 2015

Tilesets: Simulated Elevation

The most popular post on my blog to date has been about isometric tilesets. In a shameless attempt to increase readership, I will give the people more of what they want.

Today, I shall investigate how to add an element of elevation to an isometric tileset. By far my most favourite example of this is the little-known game Snake Rattle 'n' Roll, where the eponymous snakes Rattle and Roll are climbing up a mountain composed of isometric tiles:

However, the technique is as old as video gaming itself, as can be seen in the 1982 class Q-Bert:

In these two examples, the ground is seemingly composed of stacks of cubes. What I am going to show you is a bit more powerful, in that it can bue used to make stacks of half-cubes called 'slabs' that will be immediately familiar to Minecraft players.

I begin by using the ideas in this early blog post to create four tiles, each eight by eight pixels in size, that can be arranged to form an isometric grid, like so:

To create the illusion of depth, we can raise and lower the tiles for individual slabs, like so:

So far, the result looks like an incoherent mess. We must create some new tiles to serve as the 'sides' of the slabs. To do this, I created a sixteen by eight pixel image to represent the side of one slab (that being one by two tiles in size). I then doubled it up to sixteen by sixteen, 'slanted' it, and fit it into the space between two slab tops, as shown below:

This approach creates six tiles. The reason that I chose to double-up a sixteen by eight pixel image instead of creating a sixteen by sixteen image is that my approach will result in the top two and bottom two tiles matching up seamlessly, and result in the middle tiles matching seamlessly with themselves, allowing for height differences in multiples of a slab instead of a cube.

If I slot these new tiles into the earlier image, the result begins to take shape:

I can then do the same procedure again, only this time 'slanting' in the opposite direction:

I can then add these tiles to the earlier image, and complete the look. It now looks like a five-by-five arrangement of slab stacks, at varying heights:

This result is composed of only sixteen tiles:

By applying this technique, and a heaping helping of artistic talent, you can turn out tilesets that let you create amazing environments like those in the Tactics Ogre franchise.

There is one notable restriction on this technique. The tiles that I have created are only able to be used to construct environments where any given slab is no higher than its adjacent northeast and northwest tiles. Stated another way, if you travel northeast or northwest from a given slab, the height must be monotonically increasing. We will relax that restriction a bit in the next post.

Friday, September 19, 2014

Rounding Out Isometric Tilesets

It's been a long digression, but we are finally ready to come back to the original problem stated in this blog all those weeks ago. We have a tileset:

And we can use that tileset to construct an island:

The result is unsatisfactory, however, because it looks too angular and straight. We would like to produce a tileset that lets us create a more natural look. How can we do this?

We saw in earlier posts that it is possible to produce a small set of tiles that can produce an 'edge' between the two regions. This edge can be made slightly rounded. In an isometric tileset, we actually have tiles to define that edge, rather than having be implicit in an orthographic tileset, that lines up with horizontal and vertical lines. This gives us the following edge:

Because of how we produced the edge tiles, there are normally two of them per 'square' of the final map. However, in order to make it easier to produce a natural-looking edge, we will construct three tiles in an L-shape. This ensures that none of the tiles we create need to meet at a corner:

At this point, science takes a back seat to art. Using whatever method you can devise, your goal is to produce three tiles to make the L-shape that look seamless when attached to each other, between the two regions. I personally like to blend the original regions together, and then do a bit of hand touch-up. You should wind up with something that looks a little like this:

We then go through the same process with the edge that is the vertical mirror of our original edge. However, in addition to making the resulting edge tiles connect to each other seamlessly, we also want them to connect seamlessly with the first edge we created. Since a picture is worth a thousand words, check out the following 3K:

So far so good. We will go through the process again with the opposite side:

We then go through the process a fourth time, again making sure it lines up with both itself and its vertical mirror:

So far, we have produced twelve tiles, shown below. If you actually tried to produce a non-trivial image, however, you would find that we have further to go.

The tiles we have so far can be used to construct a gently-flowing stream:

However, we run into a problem if we try to produce a corner of the water areas. The source of the problem is that, because of how we construct our edge, we have two tiles that are competing for position:

The problem is easy enough to solve. Substitute in the edge tiles that don't conflict, and then create two more tiles to complete the corner:

We must also follow the same process for the opposite corner:

The second problem occurs in the opposite configuration, when we want a corner of sand areas. Here, the problem is that the edge gets cut off, so we create two more tiles to extend the corner to a point:

We also create two more tiles for the opposite corner:

The four tiles just created can be used to make tiny islands in the water, as seen below:

It was a long road, but we are finally at the pay-off. We have created 28 tiles, specifically, these:

We can use them to transform our beach into something beautiful:

We can also construct a copy of the road example from earlier posts, in order to highlight the 'diagonal' nature of an isometric tileset versus the 'square' nature of an orthographic one:

This has been my most image-intensive post to date. I'm going to take a break for a bit, and come up with another series that won't require so much work to produce each post. See you soon!

Wednesday, September 3, 2014

Forty-Seven from Twenty-Four

As promised (but delayed), this post will talk about how to produce a small collection of single-width tiles which can be combined in various fashions to form 2x2 supertiles that are of all forty-seven shapes needed to produce any shape desired in a landscape.

To begin, start with any two 2x2 tile supertiles that you wish to blend between. As readers will know, I have a predilection for 8x8 tiles. I am going to make another variation of our earlier ground-and-road display, only this time it will be a badlands-esque ground and highway road. Therefore, I start with the following supertiles, each 16x16 pixels:

Step 1: Arrange eight copies of one of the supertiles in a donut shape, and drop a copy of the other supertile in the middle. You will get a slightly different end effect depending on which supertile you choose for the middle, as I will discuss below.

Step 2: Remove a one-tile-thick rectangle around the inner supertile:

Step 3: Create new tiles to the left and right of the central supertile. These tiles should match seamlessly to the left and right. They will also need to be seamless if you take the middle two rows of tiles and repeat them, as seen on the right side of the next image:

Step 4: Create new tiles above and below the central supertile. These will need to be seamless if you repeat the middle two columns, as shown on the right side of the next image:

Step 5: Create four new tiles in the remaining blank spaces. These new tiles need only connect seamlessly to one configuration, and so if you can create the following shape without any seams, you are on the right track:

Step 6: Arrange a 4x4 copy of the inner supertile. Then, take out a rectangle of tiles from the ouside of it. Then, take out the square of tiles inside of it, leaving a rectangle one tile thick:

Step 7: Put two copies each of the tiles from step 3 along the left and right of the inside of the rectangle. Then, put two copies each of the tiles from step 4 along the top and bottom of the inside of the rectangle (overwriting the corners). Then, delete the corners. Lastly, drop one copy each of the four tiles from step 5 into the middle space.

Step 8: Now that you've gone through the somewhat complex step to produce the four blank spaces, fill them in with four newly-created tiles that are seamless with what is already available:

You are done! You should now have the eight tiles from your original supertiles, plus sixteen new tiles you have created from this procedure:

If you had only taken your original eight tiles and recreated the road example from previous posts, you would have gotten the following result:

However, you now have a brand-new collection of tiles that you can use, in essence, to create an 'edge' between the two original supertiles:

By combining the edge and the base, you are left with a slick result:

A few things to note: the resulting edge from this procedure is designed to replace some of the tiles from one of the two supertiles. The other supertile never has any of its tiles replaced by an edge tile. The center of the donut in step 1 is the supertile that does not get replaced.

If you were to invert your overall image, you would get a subtly different edge:

And a subtly different final result:

If you compare the badlands road example to the red brick road from the previous posts, you will note that the badlands road uses the road supertile as the unreplacable tile, while the red brick road uses the grass as the unreplacable tile. Which of the two tiles you choose to make the unreplacable tile is up to you, but you should consider how the resulting tileset will behave when making the decision.

Friday, August 22, 2014

Fat Roads

A short post today, following up on the last post.

We determined that forty-seven tiles are necessary in order to produce any shape between road and grass. However, how many tiles might we need if we wanted to produce any thick shape? That is, if we wanted to produce roads that were at least two squares thick, but never only a single square thick?

No brain teaser today the answer is sixteen again. These fifteen, plus the 'blank' tile (all green):

In most applications, you would choose to make the tiles for a one-square-thick application (common examples are roads and rivers) or for a two-or-more-square-thick application (common examples are lakes or gardens). The sixteen other tiles, which I call 'connectors', are of limited use. In the days of yore, when memory was expensive, nobody would have produced them without good cause.

Next week, however, we will look at a way to construct a small set of sub-tiles which can be used to produce all forty-seven of our shapes.

Wednesday, August 20, 2014

Forty-Seven For The Win

Last time, I told you that to construct any road shape you wish, you needed forty-seven distinct tiles, and that it was a very unwholesome number. Today, we take a look at how I arrived at that number.

To begin, let us first revisit how the previous method used to enumerate the required tiles, and identify where it is deficient. We constructed the tiles by enumerating the 2^4 different possible configurations of tiles in the four cardinal directions from our tile of interest. This was deficient because what we must actually do for arbitrary shapes is enumerate the possible configurations of all eight cardinal directions: north, northeast, east, southeast, south, southwest, west, and northwest. This gives 2^8=256 options, and is a much larger number than the proposed solution of forty-seven.

We know that the solution for the arbitrary-shape solution is a superset of the solution for the road-shap problem, so sixteen of the forty-seven tiles must be the sixteen from the previous post. We are left with the following information:

The problem, once again, is that the tiles don't link up along the diagonals. As a starting point, let's consider the bottom tile, which connects to all four lateral neighbours. It does not connect to any of its diagonal neighbours. Let's try producing different versions of that tile that do link up diagonally. We find that there are four diagonal neighbours, and so we should get 2^4=16 different forms, and we do:

This is a fairly satisfying result. There is a nice parallel between the sixteen different lateral neighbour options and the sixteen diagonal options. One of the tiles is doing double-duty, so we only have thirty-one, not thirty-two, but we can live with that.

Let's now continue using this approach with the other lateral configurations:

Hmm. That didn't generate as many as we might have hoped. Four of the tiles only have a single 'corner', and so there are only two configurations. Four more have only two 'corners', and they only generate 2^2 = four configurations.

It turns out, however, that we have actually generated all the tiles we require. (If you count them, there are forty-seven, as promised). Some of the tiles can be recycled in multiple configurations, and the rules for when they can be recycled can be summed up with the following lemma:

A given road square is only sensitive to whether its north-eastern neighbour is a road square, if both its north and east neighbours are roads. (Analogous statements can be made for the other three diagonals.)

Consider a road square connecting to the west and south. According to the lemmas, only the southwest diagonal neighbour will impact which tile is used. The other three diagonals do not. Thus, we expect that the tile can be reused in 2^3 = eight different configurations, and that is indeed the case:

It also turns out that forty-seven isn't that unwholesome a number after all, since 47 = 16 * 3 - 1. If you include the not-road tile (all green, in our example), you get forty-eight, which isn't so bad after all.

For concreteness, here are all fourty-eight tiles in our road-and-grass example:

They can be used to produce the thick road we desired from the previous example:

Beauty.