Posts

Stitching tiles to neighbor tiles at different altitudes.

Image
Suppose you have a 2D tilemap grid of altitudes, and mapped tile types to each coordinate based on the altitude generated. What if you wanted to display this in 3D? With the actual altitude set at each tile with full scale mountains? Recently, I set out to do just that. Initially I just put terrain objects down at the grid coordinates in 3D space, but kept all of the height values the same. This results in an overall flat world. Each individual tile can have a heightmap that adds bumps or hills, but there is no global altitude being applied. So, what if we want to add our global altitude to our tiles? Instead of placing every tile at height 0, lets set it to the altitude generated. As you can imagine, this creates a pretty immediate problem: When a tile is a different altitude than its neighbors, a gap forms between the edges. This is bad for obvious reasons, you don't want players falling off the world in to the abyss of -y coordinates. How do we solve

An algorithm for generating smooth 2D multi-layer tilemaps from only three source textures per layer.

Image
TL;DR - This: Becomes this: A larger map using the same technique: A common practice when creating a game is to create a 2D grid of "locations" or "location types". In a roguelike, it might be the walls, the floor, the doors, etc. Or in an open world game it could be the biomes or different layers of altitude. A common problem faced by developers is creating sprites that transition smoothly between these tiles, given the large amount of permutations possible. Often times, developers will create tile atlases, like this: Each terrain layer (lava, grass, snow, etc) has 13 sprites. And allows you to create a nice looking environment like this: However, a astute observer may notice a problem here. There is a limitation to only having one border type. As a developer on Unity's forums put it: The only problem is that a place that could reasonably have 2 outside corners ends up having one corner or the other. From what I can tell, this is a fail