Tuesday, 30 August 2016

Basic "Rules" of voxel world, like AIWorld

In this tutorial I will cover the basic rules of voxel world generation. If you need info about initialization of those rules, you can check out my previous tutorial.

 World Creation and Modification

Everything starts with a basic face of a cube.
A face (a polygon) consists of 4 points (2), 2 triangles (1) and 4 points, used for texturing. 6 faces combined create a cube (3).
Each face may have it's own texture.
Sometimes we don't need to show all faces of blocks, only a few of them. Above you can see all possible combinations of visible faces. Red means that you can't see one or more faces.
If we count a cube with some faces shown as a block, here you can see a 16x4x16 set of blocks. The top layer is dirt with grass on top and the bottom layer is stone.
In game development, blocks usually have something like IDs or types, which store additional information about them, for example, rotation. Furthermore, a (usually) 16x16x16 set of blocks is called a chunk.
As the player travels, different chunks appear and disappear, so all the chunks around the player are loaded, but there are no loaded chunks, that are too far (because of computer limitations).
Warning: bad drawing ahead.
Player before deleting a block.
If a player wants to place or delete a block, the game sends a ray from his head position to the point, that the player is looking at. When the ray hits the targeted block, the block gets deleted or a new block is placed.
That is it for the voxel world generation, maybe later I'll cover lighting the world in a face-based way or something.

Texture Creation

Here's a little add-on that I promised before: a guide to create simple textures. Today I'll create a very simple texture that should resemble a stone texture.
Here are the steps:

Create new image


Apply a colour (here: grey)

Add some drawings in similar colour.

Apply Blur.

Apply Noise.

Check if the texture looks good duplicated.






Here are the pictures in the original size.

No comments:

Post a Comment