Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg...
Transcript of Procedural Contentcrawfis.3/cse786... · Procedural Content Alex Bunch Michael Schoenberg...
Procedural ContentAlex Bunch
Michael Schoenberg
● Background & Rationale● State of the world● Toolkits● Use cases● Demos
Agenda
Definition
Broadly, procedurally generated content is simply using functions to create unique content quickly and easily
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
● 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
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
Urban Clutter
● In urban games can create trash/gentrification procedurally
● Create a city population● Make random businesses
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
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
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
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
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
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
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
● 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
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
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
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
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
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
Applications
● Incredibly varied, application dependent○ “Roll your own”
● Three example use cases● Build-time toolkits for each● A few demos
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
lBig lumps of rocklShould be bumpylNon-uniform scaling, directionlIntuitively, a heavily deformed ellipsoid l(This is Eros, a NEO)
Use Case #1: Asteroids
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
Use Case #1: Asteroids● Increasing polycount
improves visual appeal○ ~500,000 polys
● Note the texture● Improvements:
Normal mapping, parallax mapping
Use Case #1: Asteroids● Option 2: Generate static assets● Used in Monodon● Random sizing, rotation● Users are easy(ish) to
fool
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”
Use Case #1: Asteroids● How do we generate
these?● Blender● Subdivide and displace● Random “cloud”
displacement map● LoD easy: reduce
subdivisions
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
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
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
Use Case #2: Plants
http://www.speedtree.com/gallery/images/img4e823494cfb51.jpg (Gears of War 3)
Use Case #2: Plants
L-SYSTEMDEMO
Use Case #3: Terrain● Extremely popular use-
case● Modern games =
enormous worlds○ Too large to generate
entirely by hand● Terrain-as-game
○ Minecraft, Terraria
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
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
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/)
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
Use Case #3: Terrain
RMDF and Spectral Synthesis Demo
Use Case #3: Terrain● Combine noise functions● Coloring by height, slope● Many editors exist
○ Terragen○ World Machine○ Bryce
● Consult http://vterrain.org/ if curious
Takeaways
● Improve asset variety● Minimize human work● Generate complex but coherent structure
Questions?