Skip to main content

Tileset methods.

If you're making a game in 3d there are a number of ways to handle tilesets and tiles.
The easiest but least flexible is to handle each single tile as a tile and just place them with no regard for the adjacent tiles. Walls in this case are made of 1x1 pillars of wall material.

This is great, but it doesn't allow for very varied tile sets. It also leads to very repetitive, bland looking dungeons. You could make things a little more random by using multiple kinds of wall and floor tiles, randomly placed, or use an algorithm when placing them.

Here's a look at Eye of the beholder on the gameboy advance which uses that method, though it's actually 2d isometric, not 3d:

Very blocky tiles.

Another method is to use tiles which are bigger than 1x1. In the case of my first attempts, I used a 10x10 tileset. This allows some very interesting shaped rooms such as circles and some kinds of irregular tiles such as caves. We could call these prefabs or kits.

My first tileset for the game.

This requires a quite complex placement method. You have to check the tile type and then check the tile types of the four tiles to the north, east, south and west.

[[0,1],[1,0],[0,-1],[-1,0]]
You can use a search array like this.

Then you place parts of the tile which will mix or transition with those types. Combinations can be either transition (the two tiles are compatible floor tiles) doorway (maybe not actually a real doorway, but a special bridging transition) or wall (solid rock).


For example if the current tile you are placing is a floor tile, and the northern tile is a wall tile, you have to place the northern part of the tile with the following code:

north-floor-wall

We can name the objects like this:

NFW

This works really well and gives really nice transitions, but the way of splitting the tile, from the four corners in to an "X" shape means we need to have pillars of rock at each corner, unless the floor tiles fill the whole of the 10x10 space (not a good idea). It also makes any kind of naturalistic tile set very ugly. Here's an abandoned "cave" type tile set:



Notice the large open areas are broken up by the repeating "pillars" at the corner of each tile. This is the problem with this technique, it produces nice corridors but horrible open spaces.


Another method, which I'll be using from now on uses single tiles instead of a set of 4 split into north south east and west.

You can see that they look like the corners of the room, just 1/4 of a room like we used above, but actually they are full 4x4 sized rooms, but offset by 50% to the north east (it looks like the corner of a room because I've made the walls cover only 25% of the room instead of 50%). Instead of the 4 NESW tiles above, we need 16 for each type of feature, but we can cut this down a lot by using rules which disallow certain types of tile placement. For example note that doors can only be placed in the NESW part of the tile, not in the corner. It's not actually all that difficult to make all the variations, since most are just modifications of each other, either rotated or mirrored.

How does it work? Well, for each tile we take the current tile, and its neighbors in order:

Self, North, Northeast, East. 
[[0,0],[0,1],[1,1],[1,0]] 

This returns a string such as WWDF (Wall, Wall, Door, Floor). We can use this string to place a named tile.

The important thing though is that now we can have large rooms with no pillars. We can also have better textures, since they don't have to be tiled diagonally and don't have to match up on those unpleasant "X" edges.

We can still have nice transitions, and doors but now we can have large rooms, and more natural looking caves.

The final modeled and textured tileset will look far superior to the current one. I'm also revisiting my dungeon generation script to make it quicker to build compact, well filled maps, and to be more versatile when placing entrances, exits, locked doors, themed monsters, themed tilesets and other stuff. I'll be using BSP trees to delineate some "rooms" like a 12X12 square or a 5X10 rectangle, and then I'll place a pregenerated "room array" in that space.

The pregenerated arrays will be drawn by hand using the helper utility you can see in the last picture above (with the blue wall tiles and yellow floor tiles). Then they will be saved in to a dictionary. The arrays can be flipped or rotated by 90 degree increments. There will be a lot of them so you're unlikely to run in to the same one too many times. They can include groups of rooms, prison cell layouts, underground churches or temples, mazes and labyrinths and all sorts of different kinds of areas. I'll also be able to mark tiles as stairs up/ down, or other features such as dining rooms or libraries. Later I'll add code for placing specific monsters, NPCs, treasure or furniture on different squares. Maybe even cut scene cues, special event triggers or at least message log generators. This will also allow me to make some special areas such as boss fights, treasure rooms, trapped mazes and even puzzles eventually.

This means the end result will be a mix of random, procedurally generated content and designed areas. Some parts will be simple rooms with themed monster or furniture spawns:

You enter a room, there are two doors on the far wall. A line of pillars run down the center of the room. A pit is in the corner. There are several cocoons hanging from the ceiling,  a pile of spider eggs pulsates on top of a large rock. Three giant spiders peer at you from the darkness.

Other areas may be more complex:

There is an altar in the central room. Other rooms split off from this one to the North, South and East. As soon as you enter, the door slams shut behind you. There is an evil priest at the altar and several cultists around him. There are a couple of levers near the altar jutting from the floor. A woman is chained to the altar, she look like the daughter of the innkeeper who you are searching for. A big pentagram is inked on the floor, within the pentagram a dark shape writhes, half summoned.

Anyway, that's all for the future. For now it'll just be plain room arrays that will have "feature" tiles which can spawn mobs of monster or arrays of furniture.

Comments

Popular posts from this blog

Automating Level imports from Blender to Godot

  Recently I've been making some levels in Blender an importing them into Godot. There are only about 7 or 8 shaders for each level, not counting dynamic objects which will be added later. But to improve rendering performance, it can be a good idea to split the meshes up into sections. At that point you might be faced with a list like this: Or it might be even more chaotic, if you didn't use simple names for the objects in your level. So it can take a long time to sort out all the meshes, make them unique and add textures and so on. Blender imports with simple Blender textures, or with placeholder materials. This is sometimes OK, but if your Godot shaders are very different to those used by Blender, it means applying new materials to every mesh object in the level when you import the scene. I found that during the design process, I was importing and readying a level several times before I was happy with the final layout. So at first I was wasting a lot of time. In Blender, I us

Upstairs / Downstairs.

I've decided to make my prefabs multilevel. Later this should allow me to add pit traps and other great stuff. It also makes it easier to line up stairs so that you can exit them on the same co-ordinates where you entered them. The prefab editor is pretty much finished, it just needs some code for loading up prefabs from a saved dictionary, so that they can be checked or edited. The entries will need to be forwards compatible, so I'll be loading each tile and then translating the indexes to a new array, that way if I add extra indexes or extra info (like traps or puzzles) I'll be able to update existing prefabs to work with the new standard. Click for a video.

Make your game models POP with fake rim lighting.

I was watching one of my son's cartoons today and I noticed they models were using serious amounts of simulated rim lighting . Even though it wasn't a dark scene where you'd usually see such an effect, the result was actually quite effective. The white edge highlighting and ambient occluded creases give a kind of high contrast that is similar to, but different from traditional comic book ink work. I'll be honest, I don't know if there's a specific term for this effect in 3d design, since my major at university was in traditional art. I learned it as part of photography. You can find plenty of tutorials on "what is rim lighting" for photography. It basically means putting your main sources of light behind your subject so that they are lit around the edges. It can produce very arresting photographs, either with an obvious effect when used on a dark subject ... ..,or as part of a fully lit scene to add some subtle highlights. See ho