57
Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * [email protected] * Now at Boeing - Autometric, Inc.

Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * [email protected] * Now at Boeing - Autometric, Inc

Embed Size (px)

Citation preview

Page 1: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game Hardware and Engines

J. Scott Hofmann

Bethesda Softworks, Inc.*

[email protected]

*Now at Boeing - Autometric, Inc.

Page 2: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

IntroductionGame Hardware

History Examples

Game Engines Definition Examples Implementation

Game Engineering

Page 3: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game History Source:

http://gamespot.com/gamespot/features/video/hov/p2_01.html

1889: Marufuku Company founded Changes name to Nintendo in 1951

1947: Tokyo Telecommunications Engineering Company founded Changes name to Sony in 1952

1958: “Table Tennis” played on an oscilloscope This later becomes Pong (in 1972)

Page 4: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game History1961: Spacewar developed for PDP-1

first game implemented in software1971: First arcade game shipped

Nolan Bushnell at Nutting Associates1972

Magnavox ships the Odyssey first home game console

Page 5: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game History 1972: Bushnell leaves Nutting to found Atari

Pong released 1977

Atari 2600 ships Nintendo releases first arcade game

1979: Milton Bradley releases Microvision first handheld programmable electronic game

1980: Activision founded first third-party developer

Page 6: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game History1981: IBM ships the IBM PC1985: Nintendo Entertainment System

released1989: Nintendo Gameboy released1994

Sony PlayStation released Entertainment Software Rating Board

(ESRB) established

Page 7: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game History2000

Playstation 2 released2001

Nintendo Gameboy Advance released Nintendo GameCube released Microsoft Xbox released

Page 8: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game Console HardwareSony Playstation 2

development done on a PSTool PSTool is a Linux-based workstation

Microsoft Xbox development done on a PC connected to

an Xbox Development Kit (XDK)Nintendo GameCube

code-named Dolphin

Page 9: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

PlayStation 2 Architecture

Page 10: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

PS2 Overview I/O Processor (IOP)

controllers, FireWire, and USB ports Emotion Engine (EE)

Geometry calculation Behavior/World simulation some program control and housekeeping

Graphics Synthesizer (GS) receives display lists from the EE Graphics Interface (GIF) unit mediates EE-GS

communications

Page 11: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Emotion Engine Architecture

CPU: 300MHz MIPS III derivativeVU: Vector UnitGS: Graphics Synthesizer

Page 12: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

EE overviewCPU + FPU: program control,

housekeepingCPU + FPU + VU0: AI, physics

simulationVU1: geometry processingMore info:

http://arstechnica.com/reviews/1q00/playstation2/ee-1.html

Page 13: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

GS Overview Massively parallel rendering engine

150MHz core processor 16 pixel engines 4MB DRAM (i.e. frame buffer)

75 million polygons per second 20 million textured lit zbuffered blended polygons per

second 2.4 billiion pixels per second Designed for massively multipass rendering

each frame may have 20+ passes NTSC TV is 30 frames per second

Page 14: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Microsoft Xbox Architecture PC-like architecture

Intel Pentium III 733 MHz NVIDIA graphics processing unit (GPU)

GeForce3 derivative

NVIDIA Media Communication Processor (MCP) sound, video, network processor

64MB DDR SDRAM Unified Memory Architecture (UMA) - No AGP or video

memory!

10GB 5400RPM hard drive!!!

Page 15: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Developing for the Xbox Xbox Development Kit (XDK)

Hardware: modified Xbox includes SCSI card for DVD emulator (hard drive in PC)

Software: Libraries, tools for Visual Studio 6 XDK hardware connected to PC via ethernet Xbox Debug Kit

XDK minus DVD emulator used by QA teams (cheaper than XDK)

Parts of DirectX 8.0 Modified versions of Direct3D, DirectInput,

DirectSound, Win32

Page 16: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

GPU ArchitectureGeForce3 derivative250MHz clock rate

between Ti200 and Ti500 in the PC worldVertex and Pixel Shaders

Apply a program to individual vertices or polygon fragments (“pixels”)

Provides much more hardware acceleration

Page 17: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

NVIDIA MCPSound processing

256 voices over 64 channels Dolby Digital encoding for surround sound

Video processing MPEG-2 decoding

used also for DVD playback

Network processing 10/100-base-T ethernet

Page 18: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Comparing the PS2 and Xbox PS2: Massively Multipass Xbox: Only a few passes required

2-3 passes per frame vs 20-30 passes per frame Xbox: 10 million polygons per second

125 million polys/sec theoretical peak PS2: 20 million polys/sec

75 million polys/sec theoretical peak Poly counts are per pass!

Xbox: 10M / 3 passes = 3.3M polys per frame PS2: 20M / 20 passes = 1M polys per frame

Page 19: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

GameCube Architecture485MHz IBM PowerPC 750CXe CPU

equivalent to a ~700MHz Pentium III24MB fast 1T-SRAM16MB slower DRAM162MHz ArtX (now ATI) GPU

2MB 1T-SRAM as zbuffer 1MB 1T-SRAM as texture cache

Page 20: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

GameCube MCPMacronix DSP provides sound

Not powerful enough for Dolby Digital Dolby Pro Logic II possible instead

Network adapter not included optional peripheral

DVD playback not included possible in Matsushita device

Page 21: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game EnginesControl the presentation of game

content Geometry and Texture Script Sound Simulation (i.e. Physics) AI Network Traffic

Page 22: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Engine Architecture

Core Library

GeometryManagement

Animation andSimulation Sound Script

Interpreter

Game Content

Network

Page 23: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Core LibraryMath

Range-checked Trigonometric functions Linear Algebra

Vector, Matrix, Quaternion Curves and Surfaces

Linear, Quadratic, and Cubic curves Bezier and Tension-Continuity-Bias (TCB) curves

Bezier and Subdivision Surfaces

Page 24: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Core Library Bounding Volumes

Box and Sphere Intersection testing

Memory Management Leak detection Reference counting and/or garbage collection

Error Reporting Miscellaneous Types

Page 25: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Geometry Management Move as many polygons as possible as

quickly as possible Apply Texture (usually multiple textures) Lighting Color and Blending Depth sort (ZBuffer, BSP tree) Bind shader programs (DX8)

Control each rendering pass Cull out invisible geometry

Page 26: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Geometry Management Meshes are exported from the art tool

Usually 3D Studio MAX or Maya Some additional processing is done

Level-of-detail simplification Polygons organized into engine-friendly structures

Vertex arrays Triangle strips Scene graph

Texture compression Colors checked for “illegal” values

Important if the display is a TV

Page 27: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Vertex Arrays Vertex Buffers (DX) / Vertex Arrays (OGL)

An array of per-vertex information x, y, z: position r, g, b: color i, j, k: normal (for lighting and physics) u, v, w: texture (w optional) Multitexturing would append other (u, v, w)

coordinates Other stuff (tangent, binormal for bump

mapping; other application-specific per-vertex information)

Page 28: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Vertex ArraysEach array has a primitive type

Points Lines Triangles Triangle Strip or Fan Quadrilaterals Quad strip Polygons

Page 29: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Triangle and Quad StripsReduce the number of redundant vertex

specifications

Reduces the function-call overhead Vertices transformed only once More efficient use of bus bandwidth

Page 30: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Triangle Stripping Triangle strips can be created from an

arbitrary triangle mesh generating optimal strips is NP-hard Usually done by a noninteractive tool

Page 31: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Render State ManagementMinimize the number of state changes

Enable/disable lights Change textures Enable/disable blending

Geometry organized to batch similar polygons

Scene graph and/or display lists built

Page 32: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Scene GraphDirected Graph structureUsed for scene-database management

includes culling and interaction support graph traversal paramount for speed

OpenInventor, VRML, Fly3D (in book)

Page 33: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Scene Graph

Page 34: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Display ListsBasic support for scene-database

management Store a list of render commands in an

optimized fashion Display lists are immutable once created

OpenGL: called display lists Also compiled vertex arrays

Direct3D: part of the vertex buffer

Page 35: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

CullingSelect what geometry should be drawnThree kinds of culling

Frustum culling Occlusion culling Detail culling

Culling algorithms use bounding volumes (BVs) The actual polygon mesh is too big Also useful for collision detection

Page 36: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Bounding Volumes Oriented Bounding Boxes (OBB)

Axis-Aligned Bounding Boxes (AABB) a subset slow, but usually the tightest bound

Bounding Spheres fastest intersection tests lots of wasted space, which causes false positive

tests Bounding Capsules

middle ground between OBBs and Bounding Spheres

Page 37: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Hierarchical Bounding Volumes

Tree of bounding volumes Parent node’s volume encloses child node

volumes Leaf nodes are actual geometry Usually built using boxes or spheres

Page 38: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Frustum CullingWalk bounding volume tree, testing

each BV for intersection with frustumFor static scenes, a spatial data

structure is faster than the BV tree octtree or BSP tree best for dynamic scenes, data structure

management swamps culling speedup

Page 39: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Backface Culling A simple form of occlusion culling

remove all polygons which face away from the eye

Usually done by calculating the winding order of a polygon Mirroring transforms can flip this order

Acceleration through normal masks sort polygons into clusters by normal vector test each cluster once for culling

Page 40: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Occlusion CullingRemove geometry in the camera

frustum but not visibleDifficult to do

Portals Research still being done:

Hierarchical Z-Buffer Occlusion Masks Shadow volume culling

Page 41: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

PortalsDivide indoor scene into convex cells

connected by portals

Build cell graph from this representation

Page 42: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

PortalsWhat is rendered is then determined by

querying the cell graph cell identified containing eye point That cell is rendered For each portal, that portal is projected

onto the view plane if portal’s projection is non-empty, recursively

render that cell

Page 43: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Detail CullingSelect the appropriate number of

polygons to display view-independent criteria:

per-frame polygon count arbitrary number picked by developer

view-dependent criteria: size of screen projection distance from eye

Page 44: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Static Level-of-DetailPre-generate a fixed number of

reduced-polygon-count meshesSwitch between meshes at runtime

view-independent: polygon count caps view-dependent: remove redundant detail

Morph between meshes eliminates “popping” artifacts during the

switch

Page 45: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Continuous Level-of-DetailPrecalculate a sequence of vertex splits

or edge collapses to generate a LOD level at runtime

Page 46: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Image-based Rendering Textures with pre-rendered images are used

to replace overly complex geometry Billboards

screen- or world-aligned polygons used for trees, smoke, explosions, etc.

Impostors (aka sprites) Polygons containing images of complex scenes Regenerated when the eye moves beyond

threshold

Page 47: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

AnimationRigid Body Animation

Controlling a mesh’s position and orientation

TCB curves usedSoft Body Deformation

Character Animation 3D Studio MAX’s Physique plugin

Freeform Deformation

Page 48: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Character AnimationCreate a hierarchy of “bones”

Bones are usually scene-graph nodes The bones are then animated

Rigid-body animation Skin animation derived from the bone

animation

Page 49: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Character Animation

Page 50: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

SimulationPhysics SimulationBehavior Simulation

Often part of AIFor each frame:

Calculate Motion Apply Constraints (e.g. collision detection) Apply Motion to Geometry Draw Frame

Page 51: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Collision DetectionNecessary for “realistic” gameplay

Prevent walking through walls, other objects Used by most dynamics algorithms

Two phases Collision Detection

Does one object intersect another? Collision Resolution

Given two intersecting objects, what should happen?

Bounding Volumes used here

Page 52: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

SoundPlatform-specific APIs used3D audio

Sounds are part of the scene graph Each sound has a geometric location Occlusion, attenuation, doppler shifting

Dolby Pro Logic and Dolby Digital “5.1” channels:

2 main, center, 2 rear surround, subwoofer

Page 53: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

NetworkManage network connections

Connect to game server Battle.net, MSN Game Zone

LAN play Peer-to-peer

Synchronize game clients Game world is a distributed database Scene graph derived from game world

Page 54: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Script InterpreterGame content implemented through

scripts “When this door opens, summon monster” UnrealScript, QuakeC

Scripts are usually interpreted Scripts are compiled to bytecodes More engines are now using the Java VM

Page 55: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game ContentWhat the player sees and does

Art, sound, scriptsUsually not developed by the

programmers Programmers provide engine and

technology

Page 56: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Game DevelopmentGame Team Composition

Management Programmers

Software Development Content Developers

Game Play Script Development

Artists Graphics and Sound

Page 57: Game Hardware and Engines J. Scott Hofmann Bethesda Softworks, Inc. * shofmann@mindspring.com * Now at Boeing - Autometric, Inc

Conclusion Game hardware changes every 3-5 years

NES -> SNES -> N64 -> GameCube PlayStation -> PlayStation2 Usually no backwards compatibility PC: software -> Voodoo -> GeForce ->GeForce3

When hardware changes, the engine must change Hardware transformation & lighting (T&L) Programmable geometry Networks