misc topics: audio and pcg

36
Mark Nelson [email protected] Misc topics: Audio and PCG Fall 2013 www.itu.dk

Upload: lassie

Post on 16-Jan-2016

37 views

Category:

Documents


0 download

DESCRIPTION

Misc topics: Audio and PCG. Mark Nelson [email protected]. Other parts of game engines. Audio Animation Debugging/toolchain Procedural components Etc. Audio. Traditionally not a big part of engine design - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Misc topics: Audio and PCG

Mark Nelson [email protected]

Misc topics: Audio and PCG

Fall 2013 www.itu.dk

Page 2: Misc topics: Audio and PCG

Other parts of game engines

Audio

Animation

Debugging/toolchain

Procedural components

Etc.

Page 3: Misc topics: Audio and PCG

Audio

Traditionally not a big part of engine design

Sound design can impact a game significantly, but was seen as mainly an aesthetic concern

Bigger technical concern more recently with 3d positional audio, lots of simultaneous sounds, etc.

Page 4: Misc topics: Audio and PCG

Types of audio in games

Two familiar types:

Music

Sound effects

Page 5: Misc topics: Audio and PCG

Music

Typically plays in the background

Significant length, plus looping

Infrequent changes Per-level or per-segment music Can be tied to in-game status

Page 6: Misc topics: Audio and PCG

Music

Main technical concern: Keep it playing with a minimum of hassle No skips, low CPU/memory usage

Format depends on hardware: On limited hardware, avoid audio files MIDI driving a wavetable synth Specialized sound hardware, e.g. SNES sound module Otherwise, commonly use Ogg Vorbis

Page 7: Misc topics: Audio and PCG

Sound effects

Happen in response to events

Can be near-instantaneous or extended Keycard beep, gunshot, explosion NPC voice clip

Page 8: Misc topics: Audio and PCG

Sound effects

Main technical conerns: Integrate into the engine’s event system Trigger with low latency

Simultaneous sounds? Old-school approach has a new sound effect cut off an old one Still common to have a limit, avoid things going haywire from trying to play

dozens of sound effects at once

Page 9: Misc topics: Audio and PCG

Environmental audio

Sounds with position in the world

Can be sound effects, but often ongoing Waterfalls, machinery, crackling bonfire, television

In the background like music, but without the disembodied, comes-from-nowhere aspect

Page 10: Misc topics: Audio and PCG

Simple environmental audio

Give sound sources an (x,y,z) position E.g. In Unity, attach an AudioSource to a GameObject

Attenuate volume by distance from player

Optimize by having a max audible distance and doing a collision-detection-style search to only play nearby sounds

Page 11: Misc topics: Audio and PCG

Sound attenuation Sound energy falls off by 1/d2

Or 1/d if measured in decibels (a logarithmic unit) Doubling or halving distance to a source equals about +/-6 dB

Can use other attenuation curves Exaggerated positional effects Account for un-modeled features of the environment

Page 12: Misc topics: Audio and PCG

Sound position Attenuation accounts for distance

Do something else for orientation? Sounds coming from the left, in front, behind, etc.

Page 13: Misc topics: Audio and PCG

Sound position Two-channel (stereo) case is easiest

Basic model:

Consider headphones as capturing what comes into each of an avatar’s ears

Shift volume towards left or right based on angle

Page 14: Misc topics: Audio and PCG

Sound position Not just level differences, but time differences:

Slight delay in sound reaching the far ear

On the order of hundreds of microseconds, but perceptible through phase differences

Instead of engine-level delay (too precise), can slightly phase-offset the stereo channels

Page 15: Misc topics: Audio and PCG

Sound position Additional complex stuff going on

Sound travels through the head to the far ear: ”head-transfer function”

Reverberations: sound echoes, and/or feels like it fills a room rather than point source

Page 16: Misc topics: Audio and PCG

Sound position Games commonly support more than 2-channel audio now

as well

Better 3d reproduction, but also more complex Map 3d position to 5.1 speakers 5.1 speakers no longer match 1:1 with ears, so may need to model those

effects separately

Often this is a whole API/subsystem, possibly outsourced

Page 17: Misc topics: Audio and PCG

3d audio middleware OpenAL

OpenGL-like interface for 3d audio Open source

FMOD Commercial game-engine audio middleware 3d audio API Low-level sound/event management Used in Unity

Page 18: Misc topics: Audio and PCG

Procedural content generation

Algorithmic generation, of what would traditionally be hand-created assets

Terrain, levels, vehicles, trees, rocks, games …

Page 19: Misc topics: Audio and PCG

Different design uses of PCG

Tool: Help designers create content Material: A new kind of dynamic material to work with Designer: Automated or semi-automated AI designer Expert: Knows about players and/or aesthetics

R. Khaled, M.J. Nelson, P. Barr, ”Design metaphors for procedural content generation in games”, CHI 2013

Page 20: Misc topics: Audio and PCG

Offline v. online

Offline procedural content generation (PCG) External tool generates assets Assets are then used in an engine the normal way Purpose is to reduce costs or allow greater range of content

Online PCG Assets or components of them are generated at runtime Closer integration with the engine Various motivations, from compression to allowing infinite worlds

Page 21: Misc topics: Audio and PCG

Online PCG for compression

An early use: Elite (1984) Universe, planet locations, even planet names are algorithmically generated Avoids storing them as data on limited-memory machines

Algorithmic PCG, with hand-coded algorithm: Store a smallish seed and a smallish algorithm Pick a seed and expand out to content on the fly

Page 22: Misc topics: Audio and PCG

Algorithmic PCG

Works well if variation either: Has a precise mathematical description (fractals, etc.) Doesn’t have strong constraints, so some weirdness is ok

Fractal terrain generation

Page 23: Misc topics: Audio and PCG

Algorithmic PCG user control

Not fully controllable: algorithm does what it does

Two common ways of taking user input:

Algorithm takes parameters that control its behavior

”Seed” is more than a number; instead is a starting point that’s expanded

Page 24: Misc topics: Audio and PCG

Algorithmic PCG parameter control

Page 25: Misc topics: Audio and PCG

Algorithmic PCG as seed-content-expansion

SpeedTree: the de-facto standard for videogame trees

In this case, also interactive and real-time in a nice editor

Page 26: Misc topics: Audio and PCG

Infinite worlds

Common use of algorithmic, online PCG

Rogue dungeon generation

Minecraft terrain generation

Infinite Mario

Page 27: Misc topics: Audio and PCG

Infinite worlds: Rogue

Rogue dungeon generation: Start with a grid of rooms Mark a random starting room as ’connected’ If current room has unconnected neighbors, connect to one of them randomly,

then make that room the current room Otherwise, pick a random unconnected room and repeat Stop when all rooms are connected to the dungeon

Entrance in the first room chosen, exit in the last room to be connected

Page 28: Misc topics: Audio and PCG

Infinite worlds: Minecraft

3d Perlin noise with some tweaks

Generates based on a 2d world grid, filled/unfilled

When any player gets near enough to an unfilled part of the map, fill in that grid’s terrain

Page 29: Misc topics: Audio and PCG

Infinite worlds: Infinite Mario

Grammar-based generation

Extracted common Mario level elements into a grammar specifying how they combine

As player goes right, generates new parts of the level

Page 30: Misc topics: Audio and PCG

Intelligence in PCG

Instead of a hand-coded algorithm, generator can do some kind of intelligent evaluation of the content

Ensure constraints like level-playability are respected

Optimize a function encapsulating aesthetic judgment

Page 31: Misc topics: Audio and PCG

Intelligence in PCG: SketchaWorld

Page 32: Misc topics: Audio and PCG

Intelligence in PCG

Other examples:

Genetic algorithms optimizing aesthetic or ”fun” criteria (lots of work by Julian Togelius et al)

Constraint-solvers finding optimal map according to set of constraints (answer-set-programming-based level generator for Warzone 2100)

Page 33: Misc topics: Audio and PCG

Simulation-based PCG

Simulate a ”real” process to produce content Attempt to recreate how the content would’ve actually been generated in real

life (with simplifications)

For example: Produce canyons by simulating millions of years of erosion Simulate city-building using agent models

Page 34: Misc topics: Audio and PCG

Simulation-based PCG: Transport Tycoon

Transportation-oriented game, where you build railroads, roads, bus lines, etc. to connect cities

Cities grow or shrink according to a model of how the transportation affects their economies

In-game PCG as a game mechanic Fuzzy line to ”normal” simulation gaming

Page 35: Misc topics: Audio and PCG

Simulation-based PCG: Dwarf Fortress

World generated by insane levels of simulation

Generates terrain, simulations millions of years of sedimentation and erosion

Simulates thousands of years of the world’s history, battles, civilizations, etc…

Then game starts

Page 36: Misc topics: Audio and PCG

PCG resources

Lots more can be found:

Our new PCG book! http://www.pcgbook.com/

ITU PCG course: https://blog.itu.dk/MPGG-E2013/schedule/

PCG mailing list