Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg...

46
Procedural Content Alex Bunch Michael Schoenberg

Transcript of Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg...

Page 1: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Procedural ContentAlex Bunch

Michael Schoenberg

Page 2: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

● Background & Rationale● State of the world● Toolkits● Use cases● Demos

Agenda

Page 3: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Definition

Broadly, procedurally generated content is simply using functions to create unique content quickly and easily

Page 4: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Background

● Many different types of content are procedurally generated

● Environments○ Landscapes○ Cities○ Universes○ Dungeons

● Inhabitants○ People○ Creatures

● Difficulty mutators○ Make levels harder

http://derakon.dyndns.org/~chriswei/games/jbrl/mapgen40e.png

Page 5: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

● Natural○ Noise based height maps○ Fractal landscapes

■ Pseudo random surface with fractal behavior○ Shadow maps

● Urban○ City planning

● Celestial○ Random planets○ Random cosmic

features

http://en.wikipedia.org/wiki/File:Fractal_terrain_texture.jpg

Landscapes

Page 6: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Natural Clutter

● Beyond landscapes, could be used to create 'clutter' to make worlds feel more real○ Procedurally generate tree placement○ Procedurally generate unique trees

Fractal based trees http://illogictree.com/wp-content/uploads/2010/09/big.png

Page 7: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Urban Clutter

● In urban games can create trash/gentrification procedurally

● Create a city population● Make random businesses

Page 8: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

In Game Assets

● Can populate cities with unique individuals easily● Used to create mini-bosses● Animals● Items

http://www.blogcdn.com/www.joystiq.com/media/2010/03/borderlandsguns.jpg

Page 9: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Difficulty

● Can be used to make enemies harder○ More health○ More spawns○ Attack faster

● Can be used to make environment less forgiving○ Less cover spots○ More choke points

http://reddingmineshaft.files.wordpress.com/2008/10/picture-12.png

Page 10: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Background

The game 'helicopter' uses procedural level generation http://i245.photobucket.com/albums/gg62/witchyhoy3/myspace/Untitled-1-6.jpg

● Procedurally generated content (PGC) has been part of video game history since the 80's

● Initially stemmed from memory constraints○ Creating unique environments for each level created games

that were too large○ Could allow for 'endless'

games○ TES Daggerfall - Allowed

for a very large world ■ 2x British Isles

Page 11: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Background

● 2004 game .kkrieger was only 97,280 bytes due to extensive use of PGC, estimated to be ~250MB if done traditionally

● Procedurally generated content places more of the burden on CPU rather than memory

● Weigh smaller game size vs. additional CPU usage ● Used in film to create non-identical objects that are used

frequently

Page 12: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Recent Examples● Diablo 2

○ Quests and npc's static○ World and creeps generated for each playthrough

● Spore○ World was generated based on decisions○ Enemies races generated dynamically

● Left 4 Dead○ Controls difficulty○ Fine grained controls on level layout

● Minecraft○ World generated as players explore it○ Tops out at ~8x surface area of earth

Page 13: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Creation

● Many different methods to create procedurally generated content○ Fractals○ Perlin Noise○ Home brewed○ Statistic based

● Algorithm based on what is needed

http://www.naixela.com/alex/screens/cuda_perlin_3d.jpg

Page 14: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Fractals

● Common fractals are recursive algorithms that modify a shape, often with midpoint subidvision

● Exhibit 'self similarity'● Often seen in nature

● Described with fractal dimensions● Log(N)/Log(1/s)

○ n = # of segments○ s = scaling factor

http://upload.wikimedia.org/wikipedia/commons/d/d9/KochFlake.svg

http://www.wahl.org/fe/HTML_version/link/FE4W/c4.htm

Page 15: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

● Have a controlled random appearance○ Allows for coherent noise (no discontinuities)

● Uses noise function and interpolation function to create a curve with a unique frequency and amplitude

● Add many different curves together to create the final noise

● described by its octave○ how many times the frequency is doubled

http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Noise

Page 16: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Perlin Noise

● Named after Ken Perlin● Can be done in n dimensional space easily

○ Use an n dimensional grid○ Give each vertex has a pseudorandom gradient○ Dot product each with the distance to the point desired○ Calculate weighted average

http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselinks/perlin-noise-math-faq.html

Page 17: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Pitfalls

● Model reusage/tiling○ users 'see' seams

● Unlikely combinations○ Big eyes, small mouth

● Balance issues○ Some users have larger world○ Some users have harder 'levels'

http://devmag.org.za/2009/05/28/getting-more-out-of-seamless-tiles/

Oblivion Face Generation

Page 18: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Replayability vs. Control● PGC

○ New experiences each playthrough

○ No two games are exactly the same

○ Requires more 'thought'

■ The players should be able to find the 'Den of Evil' relatively easily - modify function appropriately

● Non PGC○ More control over the

atmosphere○ Requires more time to

physically create everything○ May still use as a basis

http://www.d2tomb.com/images/quests/acti/den_entrance.gif

Page 19: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Uses

● Build time○ Generate trees, flowers, landscapes○ Generate Cities, people, ○ Consistent through a playthrough

● Run time○ Control 'flow' of enemies and items○ Change difficulty of the game○ Fire and forget

Page 20: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

ToolKits

● Build time○ e-on software○ SpeedTree○ Many more http://en.wikipedia.

org/wiki/Procedural_generation#Middleware

● Run time

○ Tend to be proprietary○ Often simply an ai algorithm with heavy tweaks

Page 21: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Applications

● Incredibly varied, application dependent○ “Roll your own”

● Three example use cases● Build-time toolkits for each● A few demos

Page 22: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Build-Time Toolkits● Content generation is expensive!● Look-and-feel desired

○ Can fake variety● Lots of expensive operations possible

○ e.g. Lightmap/Navmesh baking● Example: Generate many levels, pick the best● Strongly task-specific

Page 23: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

lBig lumps of rocklShould be bumpylNon-uniform scaling, directionlIntuitively, a heavily deformed ellipsoid l(This is Eros, a NEO)

Use Case #1: Asteroids

Page 24: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #1: Asteroids● Paul Bourke's method:

○ Repeatedly impact sphere○ Impacts cause sloping

deformation○ Any kind of falloff,

Bourke uses linear

http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/asteroid

Page 25: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #1: Asteroids● Increasing polycount

improves visual appeal○ ~500,000 polys

● Note the texture● Improvements:

Normal mapping, parallax mapping

Page 26: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #1: Asteroids● Option 2: Generate static assets● Used in Monodon● Random sizing, rotation● Users are easy(ish) to

fool

Page 27: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #1: Asteroids● How does Monodon do this?

○ 4 asteroid models○ Random size, orientation○ Level of detail system

● Key: “Only if you're looking for it”

Page 28: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #1: Asteroids● How do we generate

these?● Blender● Subdivide and displace● Random “cloud”

displacement map● LoD easy: reduce

subdivisions

Page 29: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,
Page 30: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,
Page 31: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,
Page 32: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,
Page 33: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #2: Plants● L-systems

○ Lindenmayer Systems (1968)○ Generating grammar

● Apply as many rules as possible each iteration○ NOT a language

● Can be regular

http://upload.wikimedia.org/wikipedia/commons/a/af/Fractal_weeds.jpg

Page 34: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #2: Plants● FracInt● Flea (Ruby)● L-System3 for Blender● Algorithmic Botany L-

studio● Unity implementations● Many implementations in

virtually all major languages

http://algorithmicbotany.org/lstudio/whatis.html

Page 35: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #2: Plants● SpeedTree deserves special mention● Seemingly everything uses it

○ Extremely poplar (This was irresistible)● Gears of War, Grand Theft Auto,

Neverwinter Nights, Dragon Age, Batman, Battlefield 3

● Used to make the trees in Avatar

Page 36: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #2: Plants

http://www.speedtree.com/gallery/images/img4e823494cfb51.jpg (Gears of War 3)

Page 37: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #2: Plants

L-SYSTEMDEMO

Page 38: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain● Extremely popular use-

case● Modern games =

enormous worlds○ Too large to generate

entirely by hand● Terrain-as-game

○ Minecraft, Terraria

Page 39: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain● Voluminous literature● Just the highlights● Heightmap generation

○ Random noise is too noisy ○ Perlin Noise○ Simplex Noise (cheaper, faster in higher

dimensions)○ Random Midpoint Displacement

● Coloring

Page 40: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain● Perlin Noise● Sample from regular grid● Interpolate dot products of

random unit vectors from grid cell corners

● Any number of dimensions● Fractal Brownian Motion:

Add noise of differing scales/weights

Page 41: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain● Another method Frequency synthesis:

○ Generate random heightmap○ FFT○ Scale by 1/frequency^(some power)○ Inverse FFT

● Some nice properties:○ Tiling○ Power controls 'roughness'

● Described in more detail here (http://paulbourke.net/fractals/noise/)

Page 42: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain● Random midpoint displacement● Generate random initial heights● Subdivide, add small random value to

each center vertex

http://paulbourke.net/fractals/noise

Page 43: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain

RMDF and Spectral Synthesis Demo

Page 44: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Use Case #3: Terrain● Combine noise functions● Coloring by height, slope● Many editors exist

○ Terragen○ World Machine○ Bryce

● Consult http://vterrain.org/ if curious

Page 45: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Takeaways

● Improve asset variety● Minimize human work● Generate complex but coherent structure

Page 46: Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg Background & Rationale State of the world Toolkits Use cases Demos Agenda. Definition Broadly,

Questions?