Procedural Generation Kaarel T onisson 2018-04-20 Kaarel T - - PowerPoint PPT Presentation

procedural generation
SMART_READER_LITE
LIVE PREVIEW

Procedural Generation Kaarel T onisson 2018-04-20 Kaarel T - - PowerPoint PPT Presentation

Procedural Generation Kaarel T onisson 2018-04-20 Kaarel T onisson Procedural Generation 2018-04-20 1 / 37 Contents Procedural generation overview Development-time generation Execution-time generation Noise-based


slide-1
SLIDE 1

Procedural Generation

Kaarel T˜

  • nisson

2018-04-20

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 1 / 37

slide-2
SLIDE 2

Contents

◮ Procedural generation overview

◮ Development-time generation ◮ Execution-time generation

◮ Noise-based techniques

◮ Perlin noise ◮ Simplex noise

◮ Synthesis-based techniques

◮ Tiling ◮ Image quilting ◮ Deep learning

◮ Procedural content generation

◮ Early history

◮ Case study: Minecraft

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 2 / 37

slide-3
SLIDE 3

What is procedural generation?

◮ Method of creating something algorithmically

◮ As opposed to creating something manually

◮ Few inputs can generate many different outputs

◮ One seed number can generate a unique world Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 3 / 37

slide-4
SLIDE 4

Where can procedural generation be used?

In theory

◮ Every field of creative development

◮ Textures ◮ Models (characters, trees, equipment) ◮ Worlds (terrain geometry, object placement) ◮ Item parameters ◮ Stories and history ◮ Sound effects and music Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 4 / 37

slide-5
SLIDE 5

Where is it actually used?

In practice

◮ Often: Extent is limited

◮ Most assets are made by hand ◮ Procedural parts are edited by hand

◮ Sometimes: Heavily reliant on procedural generation

◮ Certain games ◮ Size-limit challenges Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 5 / 37

slide-6
SLIDE 6

When is generation performed? (Option 1)

During development

◮ Asset is generated, then enhanced by hand ◮ Examples:

◮ Algorithm generates terrain, developer adds objects and detail ◮ Algorithm generates basic texture, developer adds detail

◮ Used in games, movies, images

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 6 / 37

slide-7
SLIDE 7

What is development-time procedural generation good for?

◮ Hand-crafting assets requires extensive work ◮ Allows developers to focus on important areas and details

◮ Not every tree has to be made by hand

◮ Reduced number of manual mistakes

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 7 / 37

slide-8
SLIDE 8

What are the drawbacks of development-time generation?

◮ Algorithm development can be difficult

◮ May be easier to create assets by hand

◮ Using the algorithm may require skill

◮ The user may require additional training

◮ Algorithm has to produce desirable results

◮ Hand-made assets are nicer Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 8 / 37

slide-9
SLIDE 9

When does generation take place? (Option 2)

During execution

◮ Generation happens when the program is executed by the end-user ◮ Results are not edited by hand ◮ Examples:

◮ Generate a procedural landscape when the game is first started ◮ Generate procedural objects when a treasure chest is opened

◮ Used in video games ◮ Mostly procedural content generation

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 9 / 37

slide-10
SLIDE 10

What is execution-time generation good for?

◮ Smaller initial installation ◮ Added variance and replayability ◮ Enables emergent events

◮ Something exciting happens as a coincidence Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 10 / 37

slide-11
SLIDE 11

What are the drawbacks of execution-time generation?

◮ Less attractive than human-made assets

◮ Generated textures can look ugly ◮ Generated worlds can feel boring

◮ Heavy focus on algorithm development ◮ Asset generation requires storage space and computation time

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 11 / 37

slide-12
SLIDE 12

Procedural generation approaches

◮ Noise-based techniques

◮ Perlin noise ◮ Simplex noise

◮ Synthesis-based techniques

◮ Tiling ◮ Image quilting ◮ Deep learning

(This list of techniques is not exhaustive)

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 12 / 37

slide-13
SLIDE 13

Noise-based techniques

◮ Idea: Generate assets from randomness ◮ Challenge: Pure randomness is not appealing ◮ Several uses: terrain, fog, clouds, skies, certain textures

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 13 / 37

slide-14
SLIDE 14

Perlin noise

◮ Idea: Interpolate a smooth function from randomly generated

gradients in a grid

◮ Developed by Ken Perlin in 1983 ◮ 2n time complexity for n dimensions

Mechanism

◮ Generate grid with a random gradient (vector) at each node ◮ To calculate value at point P, find vectors to nearest nodes

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 14 / 37

slide-15
SLIDE 15

Perlin noise cont.

◮ For each nearest node, calculate dot product between distance vector

and gradient vector

◮ Blend the noise contribution for each node using the curve:

f (t) = 6t5 − 15t4 + 10t3

◮ nx0 = n00(1 − f (x − i)) + n10f (x − i) ◮ nx1 = n01(1 − f (x − i)) + n11f (x − i) ◮ nxy = nx0(1 − f (y − j)) + nx1f (y − j)

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 15 / 37

slide-16
SLIDE 16

Simplex noise

◮ Idea: Use simplex shapes instead of points ◮ Also by Ken Perlin ◮ n2 time complexity for n dimensions ◮ Better higher-dimension scaling than Perlin noise ◮ Fewer artifacts than Perlin noise ◮ Patented

◮ OpenSimplex noise is a free alternative Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 16 / 37

slide-17
SLIDE 17

Simplex noise cont.

◮ An n-dimensional simplex has n+1 corners ◮ For a point inside a simplex, each corner contributes according to

distance function

◮ 2D example of simplex noise usage:

https://codepen.io/jwagner/pen/BNmpdm?editors=001

◮ 3D example of simplex noise usage:

https://29a.ch/sandbox/2012/voxelworld/

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 17 / 37

slide-18
SLIDE 18

Synthesis-based techniques

◮ A texture is an array of colored pixels

◮ The number of pixels is finite ◮ Can’t enlarge without losing detail

◮ Idea: Manipulate small sample textures to create large textures ◮ Also possible: Manipulate other assets to create more assets

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 18 / 37

slide-19
SLIDE 19

Tiling

◮ Idea: Replicate one texture sample until the area is filled ◮ Can have noticeable tile edges and repetition ◮ Cheap to compute ◮ Simple to implement

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 19 / 37

slide-20
SLIDE 20

Better tiling

◮ Improved idea: Tile different samples with randomized locations ◮ Requirement: Each edge must match edge of another sample ◮ Example: blue edges match blues, orange edges match oranges ◮ Requires more samples than simple tiling

http://www.pathofexile.com/forum/view-thread/55091 Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 20 / 37

slide-21
SLIDE 21

Image quilting

◮ Idea: Take small blocks from input texture, paste to output with

  • verlap

◮ Required parameters: block size, overlap size ◮ More natural outcome than tiling ◮ Requires more configuring than tiling

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 21 / 37

slide-22
SLIDE 22

Image quilting cont.

Mechanism

◮ Go through target image in steps of one block (minus overlap) ◮ For each target block, search input for blocks which satisfy overlap

constraints, pick one at random

◮ Find overlap location with minimum overlap error ◮ Paste new block at the location

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 22 / 37

slide-23
SLIDE 23

Deep learning

◮ Idea: Teach machine learning algorithms how to create assets ◮ Potentially excellent results ◮ Difficult to control

BETHGE LAB http://bethgelab.org/deeptextures/

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 23 / 37

slide-24
SLIDE 24

Procedural content generation

◮ Includes procedural assets which directly influence gameplay

◮ Can include terrain, objects, characters, events Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 24 / 37

slide-25
SLIDE 25

Early procedural content generation

Early games: Beneath Apple Manor(1978), Rogue(1980)

◮ Procedural world because of memory limits ◮ Not enough space to include the world with the game

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 25 / 37

slide-26
SLIDE 26

Early procedural content generation cont.

Elite(1984): seed-based world generation

◮ Fixed seeds ◮ 8 galaxies with 256 planets each ◮ Planet properties (trade, inhabitants) are all generated from the seed ◮ Intentionally small number of galaxies to hide artificiality

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 26 / 37

slide-27
SLIDE 27

Contemporary procedural generation

Dwarf fortress(2006-): procedurally generated world with history

◮ World generation includes several hundred years of generated history ◮ World generation takes several (tens of) minutes ◮ Many world generation options ◮ The generator may reject the world in the progress and start over ◮ Generates continents, nations, terrain, individuals and all history

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 27 / 37

slide-28
SLIDE 28

Case study: Minecraft(2009-)

◮ Adventure/sandbox game ◮ Heavily procedural world generation ◮ World is composed of blocks

◮ Blocks exist in a discrete 3D grid ◮ Players and entities can move in continuous space Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 28 / 37

slide-29
SLIDE 29

Minecraft worlds

◮ A world is potentially infinite

◮ World height is limited (no blocks exist below or above certain heights)

◮ 30+ main biome types

◮ Each biome has certain properties ◮ Pre-determined block types (ground cover, plants) ◮ Pre-determined rainfall and temperature values ◮ Category (snow-covered, cold, medium, dry/warm, neutral)

◮ Transition biomes (jungle edge, extreme hills edge, river) to improve

appearance of biome edges

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 29 / 37

slide-30
SLIDE 30

Minecraft colors

◮ Grass, foliage, water, and sky color are determined by rainfall and

temperature

◮ Rainfall and temperature are adjusted by height ◮ Grass and foliage sampled from a gradient colormap ◮ Some biomes use other coloration

◮ Swamplands: Perlin noise is used for small temperature variation ◮ Roofed forest: grass color sample is averaged with a dark green

constant

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 30 / 37

slide-31
SLIDE 31

Minecraft world generation algorithm

World generation algorithm is not exactly known

◮ Early versions: 2D Perlin noise

◮ Boring outcomes ◮ No overhangs

◮ Later: 3D Perlin noise

◮ Value less than 0 is air, greater than 0 is ground ◮ Higher computational cost ◮ Solution: Generate some points, interpolate others

◮ Now: possibly another algorithm

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 31 / 37

slide-32
SLIDE 32

World generation rules

◮ World is loaded in chunks

◮ Only a small number of chunks around the player are kept loaded ◮ If a chunk does not exist, it is generated immediately ◮ Generated chunks are saved to disk

◮ Biomes from distant categories are not generated next to each other ◮ Secondary features are generated after main terrain

◮ Caves and ravines: fully procedural ◮ Villages, strongholds, mineshafts: prefabricated components with

randomized layouts

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 32 / 37

slide-33
SLIDE 33

Chunk-based caveats

Chunk-based generation strengths

◮ Allows world to persist ◮ Initial world takes little space ◮ New worlds can be created quickly

Chunk-based generation weaknesses

◮ World size can increase to several gigabytes ◮ Chunk generation can be slower than player movement ◮ Chunk generation can hinder server performance

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 33 / 37

slide-34
SLIDE 34

Generation caveats

◮ Secondary feature generation may create anomalies

◮ houses without floors ◮ doors too high or underground

◮ Discovering necessary resources can be bothersome

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 34 / 37

slide-35
SLIDE 35

To sum up

◮ There are numerous methods of procedural generation ◮ Noise-based methods create from randomness ◮ Synthesis-based methods create from existing assets ◮ Asset generation can reduce human workloads ◮ Algorithm design can increase human workloads ◮ Computers do not have a sense of beauty (yet)

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 35 / 37

slide-36
SLIDE 36

Thank you for listening!

Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 36 / 37

slide-37
SLIDE 37

References

Minecraft Wiki: Biomes https://minecraft.gamepedia.com/Biome http://people.wku.edu/qi.li/teaching/446/cg13_texturing.pdf

  • J. Freiknecht, W. Effelsberg: A Survey on the Procedural Generation of Virtual

Worldswww.mdpi.com/2414-4088/1/4/27/pdf Path of Exile Dev Diary: Tile-Based Texture Maps for Games http://www.pathofexile.com/forum/view-thread/55091 H-Immersion (64K intro competition) http://www.ctrl-alt-test.fr/2018/a-dive-into-the-making-of-immersion/ Kotaku: No Man’s Sky creature generation https://kotaku.com/a-look-at-how-no-mans-skys-procedural-generation-works-1787928446 Graphcut algorithm https://www.cc.gatech.edu/cpl/projects/graphcuttextures/

  • B. Kachscovski, Interactive Methods for Procedural Texture Generation with Noise

http://www.diva-portal.org/smash/get/diva2:839579/FULLTEXT01.pdf

  • S. Gustavson: Simplex Noise Demystified http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf

necessarydisorder blog: GIF loop tutorialshttps://necessarydisorder.wordpress.com/ A.A. Efros, W.T. Freeman: Image Quilting for Texture Synthesis and Transfer https://people.eecs.berkeley.edu/~efros/research/quilting/quilting.pdf The Guardian: Masters of their universe https://www.theguardian.com/books/2003/oct/18/features.weekend The Word of Notch blog: Minecraft Terrain generation https://notch.tumblr.com/post/3746989361/terrain-generation-part-1 Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 37 / 37

slide-38
SLIDE 38

Image Sources

https://minecraft.gamepedia.com/File:Swampland_M.png http://www.bay12games.com/dwarves/screens.html https://upload.wikimedia.org/wikipedia/commons/b/bc/Imagequilting.gif https://blendercgtips.files.wordpress.com/2014/12/fog2.png?w=672&h=372&crop=1 http://genekogan.com/code/p5js-perlin-noise/ https://upload.wikimedia.org/wikipedia/commons/1/17/Rogue_Screen_Shot_CAR.PNG http://mcpedl.com/50975-3/ https://www.rollapp.com/app/dwarffortress Kaarel T˜

  • nisson

Procedural Generation 2018-04-20 38 / 37