27
PROCEDURAL CONTENT How I learned to stop saying I'm bad at art and love the code

Procedural Content Presentation

Embed Size (px)

Citation preview

PROCEDURAL CONTENTHow I learned to stop saying I'm bad at art and love the code

PERLIN NOISE1. Noise2. Interpolation3. Higher Dimensions!

Invented by Ken Perlin

NOISE

Is anyone familiar with a random number generator?

NOISE USED BY PERLINA pseudo-random number generator was used, but it wasimportant that each seed would always produce the same

"random" number

This was done so that wide landscapes, like in DUST, could bemoved in and out of memory depending on where you were, but

would look the same if you revisited a place you had left. Thecomputer would regenerate that section of the map, but it would

look how you remember it looking.

This also happens to be the reason seeds are identical on different computers in Minecraft. However,Minecraft uses a tweaked 3D perlin noise to generate the landscape now. If there is interest and time I'll draw

how they accomplish this.

2. INTERPOLATION

We want smooth terrain, or edges, on any perlin noise use. Wedo this by interpolating between the points. We don't wantjaggies, and in fact a derivative at each point is preferable.

COMMON INTERPOLATION FUNCTIONS3x2+2x3

6x5-15x4+10x3

The second seems more complicated. Why use it? Because it also has a SECOND derivative. That can beuseful in some cases.

WHAT ABOUT LINEAR INTERPOLATION?

Linear:

Cubic:

Cosine:

Why suddenly cosine? It is another non-polynomial interpolation method, that gives pretty good results while also being fast.

BEYOND 1D

2DThis can also be used, and is common in generating heightmaps. A

2D image is given white through black values, which can beinterpreted as higher vs lower ground.

Note: This uses blue instead of white, but the same idea still applies

EVEN HIGHER DIMENSIONS?3D

Think of a cube with varying densities. This is often used togenerate clouds.

4D?

This is used to show moving/morphing clouds. The fourthdimention is time. In the same way that slicing through a 3DPerlin field will look in 2D like morphing 2D "clouds", slicingthrough a 4D Perlin field will look like morphing 3D clouds.

5D?!?

Yes. It has been used. I don't have any good examples of it though.Even 6D has applications, but I'm too scared to think about

anything above 4D.

FRACTALS!If you add up Perlin fields of different frequencies (granularities),

you will end up with a fractal image that has both large hills ofnoise, as well as small bumps.

Each level should be weighed less than previous levels so it will converge to zero. We don't want pixel sizedbumps contributing as much elevation as a mountain!

OTHER PROCEDURALCONTENT

L-SYSTEMGreat for plants!

This still uses fractals (they're everywhere in nature) but addingrandomness makes things look more natural.

WHICH LOOKS MORE NATURAL, THE NON-RANDOM OR THERANDOM?

MIDPOINT DISPLACEMENT(DIAMOND-SQUARE)

Assign random points to 4 corners of a 2n+1 square. Find theaverage of two points on a side, make the middle point that

plus/minus a small random value to give the terrain variety. Dothis for each side of the square. Then average the 4 corners, setmiddle of the square to that value, plus/minus a random value

again. Then do the same procedure to each of the 4 subsquaresyou just created. Keep doing this until you give every vertex a

value.

Notice the corners are low. If the water was high enough, this could be an island.

APPLICATIONSThis approach is pretty good when you are trying to make a

procedural island. Perlin noise would not allow you to ensurethat the edges are all under water, but if the 4 initial corners areset underwater, you'll generally end up with an island. For non-infinite worlds that still want procedural terrain, this is a good

method. However, the downfall is that if you want to add moreterrain on, you have to start from scratch.

This is actually the technique Dwarf Fortress uses, before it erodes, rains on, floods, and all the other stuff itdoes before it says your world is finished.

HYBRID APPROACHES

This is the eye candy section. These games have decided to usemany different procedural techniques to make worlds not

feasible for an artist to create (i.e. infinite worlds).

No Man's Sky

No Man's Sky

Voxel Farm Demo

Voxel Farm Demo