I knew no harm of Bonaparte

Ha ha, yes! Funny! When I signed off my last post with a cheery “see you in another nine months!”, that was supposed to be a joke. Of course I wasn’t going to leave it for months and months before I updated this devblog again. What kind of useless dilettante of a game developer would I be if I did a thing like that, right?

Anyway. I’ve been working on procedural textures, and like every other aspect of this project it’s proved to be not so much a time sink as a time bottomless pit into which you can tip whole wheelbarrows full of your life. I needed a tool for experimenting with procedural graphics techniques, and I needed code my game could use to turn those techniques into textures on the fly, and while there is masses of stuff concerning procedural graphics out there on the internet, there’s surprisingly little of it that goes beyond “here’s how you make marble.”

The guilty truth is, I was glad about this.

Procedural graphics is another of those computer-related byways that has fascinated me for years. I can’t tell you how many long, boring afternoons in the office were enlivened by fantasies about coding my own procedural texture explorer, and furtive peeks at Web pages on Perlin noise. So now the opportunity had come along, I jumped at it. I started coding an app to create, load, tweak and save procedural textures, and I started researching how you make the actual things themselves.

Long story short, here’s how you make marble:

blobMarble

That’s fractal Brownian motion noise. I won’t explain what that is because frankly there are about a million sites on the internet that do that already, although most of them incorrectly call it Perlin noise. In a sentence: Perlin noise is ‘coherent’ noise, noise that looks like this Perlin rather than this Noise, and if you overlay it at increasing frequencies with diminishing amplitudes you get fBm noise.

What happens if you map a palette of black and white stripes to those shades of grey above? You get this:

blobMarble#0001

Look closely and you can see it’s the same texture.

Marble!

But that’s only the start of the weird and wonderful things you can make using procedural techniques. This, for instance:

texTest3

I have no idea what I’m going to use this for.

That’s an example of what happens when you start layering different procedural textures together. For example, with my texture compositor you can take this fairly boring fBm texture…

brown3

overlay it with this slightly more exciting ridged fBm…

brown3#0001

and tell the compositor to blend the two together using this blobby pattern as a mask:

brown3#0002

Apply an earthy colour palette and hey presto:

brown3#0003

A close-up of a muddy river bed? The bark of an alien tree? I don’t know, but it looks good.

Here’s another example of masked blending:

damascus#0002

Isn’t that lovely? I call it Damascus because it reminds me of Damascus Steel.

This is what the texture compositor itself looks like:

Screenshot 2019-02-22 09.00.03

That list of items under the label ‘Tex gen stack’ is the series of texture generators used to create that image. Each has its own controls, which appear in the box below. What you can see there are the controls for the Colouriser, which let me create and fiddle with colour palettes. That whole UI is handmade, by the way. Every button and scrollbar. I wrote the library for that a few years back, and it’s really paying dividends now.

That was an example of fBm mixed with Voronoi noise, which is a very different algorithm. It creates textures like this:

alienSkin#0001

I call that one ‘Alien skin’.

fBm and friends are great for making organic-looking textures, but I’m also interested in making artificial-looking ones for sci-fi structures. This is an early experiment:

blocksTest

And finally, one of the most intriguing uses for procedurally generated textures I’m looking into is one where you’ll never see them at all:

TexGen1#0002

That’s a randomly generated path between two points, created on the texture compositor. I hope to use these to ensure my computer-generated terrain always has a route through it, no matter how rugged it gets, which is the kind of thing you have to worry about if you want to create a procedurally generated game people can actually finish. The early tests have been very promising.

It was a lot of work getting there. Computers are really, really bad at meandering. Let alone going for an amble. Trust me, you do not want to take a computer with you on a drunken country stroll.

Advertisements

1 thought on “I knew no harm of Bonaparte

  1. Pingback: A quick update and a movie? | Vague game blog

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