540 likes | 642 Vues
Modern Game Development. Oliver Franzke & Javier Blazquez LucasArts. Stanford University February 6 th , 2009. ofranzke@lucasarts.com. jblazquez@lucasarts.com. Agenda. Introduction Facts ‘Next-gen’ graphics Challenges Realistic Rendering Asset pipeline Multithreaded games
E N D
Modern Game Development Oliver Franzke & Javier BlazquezLucasArts Stanford University February 6th, 2009 ofranzke@lucasarts.com jblazquez@lucasarts.com
Agenda • Introduction • Facts • ‘Next-gen’ graphics • Challenges • Realistic Rendering • Asset pipeline • Multithreaded games • Parallel game loop approaches
Introduction • Disclaimer This talk is not specifically about LucasArts! It is an attempt to present typical challenges games companies have to deal with as well as common processes and techniques used in the industry. Please be aware that every company is unique and will therefore handle things differently.
Introduction • Modern Game Development Facts • Timeframe: 2 – 4 years • Team: 100+ (peak) • Budget: 15+ million $ • Number of source code lines: ~1 million • Code build times: up to 30 minutes • Size of assets: 100+ GB • Units sold: 2 – 3 million [VGChartz]
Art Lead Concept Character Environment Animation Effects Introduction • Team structure Project Lead Engineering Design Sound/Music Lead Lead Quality Assurance Gameplay System AI Level PR HR Core Narrative Graphics Finance Tools Network Technical Artist Production Producer Product Manager
Introduction • Timeline (3 year production) • Concept phase (1 – 2 month) • Develop ideas and prototypes • Pre-production (18 month) • Prove all game-play features • Prepare engine and tools for production • Production (12 month) • Create final code and content • Finaling (4 - 5 month) • Remove bugs and polish • Support • Customer support, patch development and updates (DLC)
‘Next-gen’ graphics • Introduction • Realistic rendering • Data pipeline Image courtesy of Crytek GmbH
Challenges • Consumer expectations • High resolution models • Detailed textures • Huge environments • Rendering speed • HD resolution: up to 1920 x 1080 • At least 30Hz (goal is 60Hz)
Challenges • Platform diversity • Next-gen consoles (Xbox 360, Playstation 3) • Handhelds (Nintendo DS, PSP, iPhone) • High-end PCs • Assets, assets, assets… • Increased development complexity • Specialized code and art for every platform
Comparison • TFU character complexity • Main character (Apprentice) • ~15.000 triangles • 3 x 1024² textures • Other characters: 7k – 10k • Comparison • Quake3: 800 – 900 (1999, id Software) • Half Life 2: 4k – 8k (2004, Valve) [Stirling07] • Gears of War: 10k – 15k (2006, Epic) [Stirling07]
Comparison • TFU character complexity • Main character (Apprentice) • ~15.000 triangles • 3 x 1024² textures • Other characters: 7k – 10k • Comparison • Wolfenstein 3D: 2 (1992, id Software) • Quake3: 800 – 900 (1999, id Software) • Half Life 2: 4k – 8k (2004, Valve) [Stirling07] • Gears of War: 10k – 15k (2006, Epic) [Stirling07]
Comparison • TFU level complexity • 500k triangles per frame in opaque pass • Memory limitation • Next sector is streamed in • Comparison [Stirling07] • Virtua Fighter 5: 100k – 300k (2006,Sega) • Lost Planet: ~500k (2007,Capcom)
Realistic Rendering • Goals • Imitation of light transport (kind of) • Create convincing images • Increased immersion • Solution • Solve the rendering equation • High quality approximation
Realistic Rendering • Rendering Equation [Kajiya86] [Wikipedia1]
Realistic Rendering • Rendering Equation [Kajiya86] [Wikipedia1]
Realistic Rendering • Rendering Equation [Kajiya86] [Wikipedia1]
Realistic Rendering • How hard can it be to solve? • Recursive integral equation • Spatial, temporal and spectral domain • Very hard!
Realistic Rendering • Constraints / Typical Simplifications • Must be controllable by artists!!! • Limited changes in the lighting condition: • BRDF is time independent: • Spatial relationships are static
Realistic Rendering • Solution • Distinguish between static / dynamic lighting and geometry • Pre-calculate static lighting information offline • No expensive calculations during run-time • Quick access • Low frequency lighting only • Memory intensive • Add dynamic lighting during run-time • No global lighting effects (local model) • Simplified lighting model
Realistic Rendering • Recap: Lightmaps
Realistic Rendering • ‘Radiosity Normal Mapping’ [McTaggart04] [Mitchell06] • Source™ Engine shading model • Developed by Valve for Half Life 2 Image courtesy of Valve
y z x Realistic Rendering • ‘Radiosity Normal Mapping’ • Use of basis function projection for lighting • Basis defined in tangent space Tangent space:
Realistic Rendering • ‘Radiosity Normal Mapping’ (Offline) • Project lighting into basis • Assumptions • Surface is smooth • BRDF is view independent (diffuse)
Realistic Rendering • ‘Radiosity Normal Mapping’ (Runtime) • Project perturbed normal into basis • Reconstruct incident lighting Normal map #1: Normal map #2:
Realistic Rendering • Lightmaps vs. ‘Radiosity Normal Mapping’
Realistic Rendering • Lightmaps vs. ‘Radiosity Normal Mapping’
Realistic Rendering • ‘Radiosity Normal Mapping’ • Low resolution sampling (Vertex, Lightmaps) • Easy to composite with dynamic lights • Works with other bump techniques • Only low-frequency diffuse lighting captured • More memory required (basis matrix vs. color)
Realistic Rendering • XNA demo is available (including source)!
+y -x -z +z +x -y Realistic Rendering • ‘Ambient Cube’ [McTaggart04] [Mitchell06] • Directional ambient lighting for objects • Simplified irradiance volume [Greger98]
Realistic Rendering • ‘Ambient Cube’ (Example) Ambient cube #2 Ambient cube #1
Realistic Rendering • ‘Ambient Cube’ (Example) Image courtesy of Valve
Asset Pipeline • ‘Next-gen’ challenge: Amount of assets • Asset-to-data transformation • Pre-calculation (lighting, PVS, nav mesh…) • Adaption for console hardware • Packing • Compression • Transformations depend on the game • Unique pipeline for every game
Asset Pipeline • Problem: Very time consuming • Solution: Build farm • Distribute asset transformation • Collection of dedicated machines • Server-client architecture • Pros and Cons • Speed-up • Incremental builds (fragment caching) • Scalable • Previewing assets can be complicated • Extra development cost
Conclusion • Complexity is increasing • Basis function projection used to improve image quality • HL2 2 basis, Spherical Harmonics, Wavelet • Amount of data is a big problem • Looking ahead • Sub-surface scattering • Facial animation techniques • GPU used for general purpose computations
Multithreading • Why a multithreaded game is important • Frame time on a typical game is very short • 16ms or 33ms max for everything • Can’t drop frames • Very noticeable, both visually and audibly • Might disrupt the player’s actions • Increasing amount of computation per frame • More precise physics • Realistic enemy behavior • Larger and more complex worlds
Multithreading One thread is no longer enough The console CPU’s single-threaded performance is not very good. You would be wasting ~80% of the CPU processing capacity. Your game wouldn’t live to expectations. Future trend is to add more cores, not to have faster ones.
CPU Comparison No out-of-order execution kills single-threaded performance
Multithreading Challenges What makes parallelizing games difficult: Many different kinds of processes: Graphics, Physics, Audio AI, Gameplay Lots of shared state: World geometry, game objects, navigation graphs, player state, etc. Game loop has traditionally been very sequential in nature.
Typical Game Loop Process Input Update Player Gameplay AI Animation Audio Physics Render
Parallelizing the Game Loop Several approaches: Coarse-grained multithreading Long processes on their own thread Task-based multithreading Short jobs scheduled dynamically Well-defined dependencies Hybrid
Coarse-grained Approach Move certain systems to their own thread Good candidates: Rendering, Physics, Audio Provide sync points with the main thread Retrieve computed data Update state Kick off next frame’s work Relatively straightforward to set up
Coarse-grained Loop Render Render frame 0 Render frame 1 Sync Main Input Player Logic AI Anim Audio Input Player Frame 1 Frame 2 Sync Physics Physics for frame 2 Physics for frame 3
Coarse-grained Approach Problems: Main thread modifying state mid-frame Defer state-changing operations Use a command queue for the system Main thread expecting results mid-frame Return last frame’s data Use a cache / double-buffering scheme Expose a deferred query API Might introduce off-by-one-frame issues
Coarse-grained Approach Problems (cont.): Worker thread calling back into game E.g. collision response Can happen at any time Queue callbacks for later processing Or make systems thread-safe Uneven hardware thread usage Difficult to schedule work properly E.g. audio thread usually idle Not the best suited for PS3
Task-based Approach Code is partitioned into small tasks Tasks operate on streams of regular data Well-defined inputs and outputs Limited access to other resources Tasks can be scheduled independently Ordering is defined by data dependencies
Task-based Approach Custom scheduler for running tasks Build / traverse dependency graph Schedule independent tasks in parallel Opportunity for additional simulations Cloth Fluids Best suited for PS3 / Xbox 360 architecture
Task-based Approach Picture from [Turner07]
Task-based Approach Problems: Typical game code is very difficult to partition in tasks Lots of dependencies, very order-sensitive Object-oriented designs do not help Many small objects Required data is in disparate memory locations Not very suitable for stream processing Focus is usually on maintainability, not performance
Conclusions Game must be parallelized as much as possible Including systems that were traditionally sequential Usually requires hand-tailored solutions OOP sometimes gets in the way