Low-resolution Procedural Textures With Minecraft Blocks

The techniques mathematicians and engineers use to approximate or simulate natural processes are fascinating. Fascinating because they increase our understanding of how the world works around us, and because they can often be used to solve seemingly unrelated problems. For example consider particle swarms which can be used to simulate flocks of birds or insects, but also can be used to quickly and iteratively optimize problems. L-systems can be used to simulate the growth of plants, but also can be used to create fractals not found in the botanical world.

Another popular technique we use to simulate nature is adding noise to synthetic textures in video games to increase the realism of objects. For example, the texture below could be a closeup of a grain of wood or marbling from a rock:

75 x 40 Rectangle Texture

75 x 40 block rectangle texture

To generate a texture like this we start with a striped texture like a barber’s pole and than add turbulence, which is just another way of saying “Hey you, add a couple different layers of variously zoomed noise to the color value of each block!” Now when I say noise I am referring to a method of generating random values between 0 and 1 that takes the x and y coordinates of blocks as input. Of course some random values are better than others for generating textures.

Low zoom factor makes for a less smooth texture.

Low zoom factor makes for a less smooth texture.

This is a 50 x 50 block shot of a texture which was generated using a method called Simplex noise. Simplex noise is a special type of noise first developed by Ken Perlin (of Perlin noise fame). We are using Simplex noise here because it is fast, the Bukkit API has already implemented it for us, and because it has the special property of creating visual artifacts of about the same size which lets us control it to for interesting results.

The results captured here are interesting, but since they were created in Minecraft there are some limitations–namely, we have a severely limited palette of colors. I choose to only use wool since the colors are solid and their internal IDs are contiguous; however, you could probably create some neat textures using all available Minecraft block types.

Wool Block IDs

Wool Block IDs

In the pics above I only used 4 colors of wool: white, light gray, gray, and black. If you use all 16 wool colors you get textures like the one below:

Colored marble

Colored marble

Yet another colored marble

Yet another colored marble

The code I used to create these textures is below. Copy and drop the file into your js-plugins folder to install it. All of the turbulence parameters should be tinkered with to experiment with the various textures you can make. Tinkering with the make_discrete function to change the palette is also fun.

If you want to learn more about Perlin and Simplex noise I recommend checking out Ken Perlin’s site. Sign up for email updates to hear about more ScriptCraft shenanigans!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s