• entries
22
40
• views
21115

# Playing with terrains

870 views

The need

I thought for a bit to a method to render tiled maps (terrains) in a way that seems less... well, less tiled actually.

The brainstorming/idea

First idea was to have smaller tiles and different images for each terrain type: so instead of having one grass image for grass terrain, have a dozen of grass images (with little color differences) and then pick a random one each time.

I liked the idea and second thought was: I will end with a lot of tiles... how to handle them? If before I had 24x24 tiles, now I have 9 8x8 tiles for each original 24x24. There are a lot of tiles to cycle in when rendering. More over, I don't want to manually fill a map with all those things.

Next thought was the need to merge between different terrains. This is something I always struggle with, since I'm not an artist and can't produce decents transition tiles. But if I reduce a tile to a grid of tiles (the 9 8x8 tiles said before) I can look for nearby terrain type and use some piece of other terrains instead of the current one. For example, if I have a grass tile under a water tile I can render one of the first row grass subtiles with a water one.

The only problem remains the prolification of tiles (x9, actually). I experimented that the render loop suffers a lot with something like this:for(int r=0; r<100; ++r){ for(int c=0; c<100; ++c) { RenderTileAt(r, c); }}
and I don't feel to complain the poor cpu for this.

So the only solution seemed to be prerender chunks of map into bigger textures, and the use them in the loop.

The implementation

So I did it.

First I edited a really simple map with tiled (40x40 tiles), that could be a single area for a bigger world map.
I used 3 terrains: swamp, dirt and grass. This is the result as exported image (and this is also like all my precedent project's maps looked like):

A swampy area with a kind of a road and some grass.

Then I coded something that parse the tmx (well, I already had from prev projects), pick every tile and build a texture with the same map using 8x8 tiles instead of 24x24 (using a second atlas with 8 terrains for each terrain).

Result is this:

A little more interesting, but still no transitions. Look at the road, so straight!
Last, I applyed the auto transition method, and the result is this:

I'm pretty happy with it, even if I chose terrible colors

There are no comments to display.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account