Upload
howe
View
42
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Game Technology. Overview. Game Engines Rendering Culling Setup Drawing Phong Lighting Physics Collision Detection Forces Integration Scripting Production. Simplified Game Architecture. Game Scripts. Game Engine. Sound. Scene Manager. Renderer. Graphics Card. AI. Physics. - PowerPoint PPT Presentation
Citation preview
ELIS – Multimedia Lab
Game Technology
2/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Game Engines• Rendering
• Culling• Setup• Drawing
• Phong Lighting• Physics
• Collision Detection• Forces• Integration
• Scripting• Production
Overview
3/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Simplified Game Architecture
Game Engine
Rend
erer
SceneManager
Sound
Physics
GraphicsCard
AI
Game Scripts
4/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• “Engine” is independent of one particular game• Scripts define individual game behavior and game play
Game “Engines”
5/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Engine Overview
Game Engine
Rend
erer
SceneManager
Sound
Physics
AI
6/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Different parts of engine all need to access the “world”• Linear search of all objects is slow for large worlds• Create sub-linear structure• O(1) or O(log(n))• Hash structures• Tree structure
Need for Scene Structures
Quad Tree
7/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Examples of Scene Structures
Wolfenstein 3D:Regular 2D GridTomb Raider:
Regular 3D GridQuake:3D BSP, Arbitrary world geometryGTA:
Complex trees, streaming, LOD
8/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Engine Overview
Game Engine
Rend
erer
SceneManager
Sound
Physics
AI
9/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Renderer Overview
Renderer
Culling SetupGraphics
CardDraw
• OpenGL• DirectX
10/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• The scene is presented to the renderer to draw it.• Contains all objects in the game world• Sending everything to the graphics card is slow• Send only limited set of objects visible by camera
View Culling
To be culled
11/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Use fast operations provided by the scene manager• Example: 2D Quad Tree
Optimizing Culling
Level1 Level2 Level3 Level…
12/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Renderer Overview
Renderer
Culling SetupGraphics
CardDraw
• OpenGL• DirectX
13/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Prepare data for efficient rendering• Sort objects per material• Create batches• Calculate per object shader parameters
• Send to Graphics Card for rendering
Setup
14/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Renderer Overview
Renderer
Culling SetupGraphics
CardDraw
• OpenGL• DirectX
15/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Recapitulation
Rendering
YU
X
Z
V
Texture Coordinate
Vertex
Triangle
16/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Light intensity is dependent on surface normalCosine Law
Same amount light reaches both surfaces.
• Light distributed over small area.• Surface will appear bright.
• Light distributed over larger area.• Surface will appear dark
17/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Simplified Light-Surface interactions
Diffuse• Light scattered in all
directions equally.
Specular• Light reflected in one
particular direction.
Many real-life materials can be modeled by a combination of specular and diffuse models.
18/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Based on these observations create simple ad-hoc model to calculate lighting.
Diffuse Term Specular Term
max(0, L.n) Cd Cl + max(0, R.n)e Cs Cl
Phong Lighting
Calculate area hit by light rays
Take color of surface Take color of
light sourceCheck if camera looking in reflected direction
Make the reflected beam narrow
Take color of surface
Take color of light source
19/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Additional lights and shadows
More than one light• Independent of each other.• Add output of Phong
equations for all lights
Shadows• Mask out contribution of
Phong equation if in shadow.
20/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Attenuation• Further from source light gets dimmer• Theoretically infinite radius
• Light Culling• At certain point assume light level zero• Use techniques similar to view culling
Attenuation & Light Culling
21/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• We evaluate this equation to determine the lighting at a certain point.
Full equation
i
i
ie
iii S )Cl Cs .n)R max(0, Cl Cd .n)L (max(0, i
Shadow contributionAdd all lights in scene
Phong for ith light
22/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Object:
Evaluate on CPU
Triangle:
<Not used in practice>
Vertex:
Evaluate in vertex shader
Pixel
Evaluate in pixel shader
Where to evaluate equation?
23/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Where to store equation parameters
• Per object
• Per pixel (in texture)
24/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Normals are geometric property of surface
• Low poly surface: Renders fast but low lighting detail
• Normalmapping: Store approximate normals in texture
Normal/Bump mapping
25/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Using the GPU to evaluate model: Shaders
26/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Shadow Mapping
Texture: Stores length of blue arrows• Check green length to blue to determine shadows
Depth as seen from light source
27/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Shadow Techniques - Comparison
SM PCF 5x5 Bil.PCF 5x5 VSMStencil
28/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Engine Overview
Game Engine
Rend
erer
SceneManager
Sound
Physics
AI
29/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Physics Overview
CollisionDetection Forces Integration
30/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Physics Overview
CollisionDetection Forces Integration
31/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Broad phase• Use the scene manager to determine nearby objects
• Narrow phase• Object – Object interactions• To simplify calculations, use simple shapes:
• Spheres, boxes, …
Collision Detection
32/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Example of simplification
Collision detection – Rag Dolls
33/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Physics Overview
CollisionDetection Forces Integration
34/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Forces acting on the objects are accumulated• “Traditional” forces:
• Gravity• Collisions• …
• “Simulation” forces• Collision detection• Constraints
• “Game” forces• Explosions, magic, • Not simulated correctly what looks fun
Forces
35/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Physics Overview
CollisionDetection Forces Integration
36/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Good old Newton
• Object’s state vector is integrated using numerical integration methods• Euler• Runge Kutta
Integration
trv
dd
tva
dd
…
37/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Use computational power of the GPU• Parallelize algorithms• For example:• PhysX engine by NVIDIA• Uses CUDA to drive the GPU
Physics on the GPU
38/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Engine Overview
Game Engine
Rend
erer
SceneManager
Sound
Physics
AI
Game Scripts
39/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
Scripting
• Script programmers & technical artists• AI & Behavior• Physical properties• Animation behavior
World Objec t
Static Objec t
Tree
Birc h
Fir
House
Phy sic s O bj ect
Monster
Zombie
Shark
Vehicl e
Tank
Jeep
Pla yer
Pla yer
…
40/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• “Making the game”• Use engine to create an unique game• Mainly artists, designers and script writers
Production
41/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
GDD• Visual
description
• Function in game
Concept art• Han
d drawn idea
Modelling• 3D
model of object is constructed
Rigging• A
skeleton is added to the model
Animation• The
skeleton is animated
• Motion capture
Texturing• A
texture is made for the model
Integration• AI
Code• Load
assets in game
Production – Asset Pipeline
Text
42/42
ELIS – Multimedia Lab
Game TechnologyCharles Hollemeersch
28/11/2008
• Contact:• [email protected]
Questions?