550 likes | 1.52k Views
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.
E N D
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
Game “Engines” • “Engine” is independent of one particular game • Scripts define individual game behavior and game play
Engine Overview Game Engine Sound Scene Manager Renderer AI Physics
Need for Scene Structures • 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 Quad Tree
Examples of Scene Structures Wolfenstein 3D: Regular 2D Grid Tomb Raider: Regular 3D Grid Quake: 3D BSP, Arbitrary world geometry GTA: Complex trees, streaming, LOD
Engine Overview Game Engine Sound Scene Manager Renderer AI Physics
Renderer Overview Renderer Culling Setup • Draw • OpenGL • DirectX Graphics Card
View Culling • 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 To be culled
Optimizing Culling • Use fast operations provided by the scene manager • Example: 2D Quad Tree Level1 Level2 Level3 Level…
Renderer Overview Renderer Culling Setup • Draw • OpenGL • DirectX Graphics Card
Setup • Prepare data for efficient rendering • Sort objects per material • Create batches • Calculate per object shader parameters • Send to Graphics Card for rendering
Renderer Overview Renderer Culling Setup • Draw • OpenGL • DirectX Graphics Card
Rendering • Recapitulation Z Vertex V X Triangle Y U Texture Coordinate
Cosine Law • Light intensity is dependent on surface normal Same amount light reaches both surfaces. • Light distributed over small area. • Surface will appear bright. • Light distributed over larger area. • Surface will appear dark
Simplified Light-Surface interactions Diffuse Specular Light reflected in one particular direction. • Light scattered in all directions equally. Many real-life materials can be modeled by a combination of specular and diffuse models.
Phong Lighting • 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 Calculate area hit by light rays Take color of light source Take color of surface Take color of surface Check if camera looking in reflected direction Take color of light source Make the reflected beam narrow
Additional lights and shadows More than one light Shadows Mask out contribution of Phong equation if in shadow. • Independent of each other. • Add output of Phongequations for all lights
Attenuation & Light Culling • 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
Full equation • We evaluate this equation to determine the lighting at a certain point. Shadow contribution Add all lights in scene Phong for ith light
Where to store equation parameters • Per object • Per pixel (in texture)
Normal/Bump mapping • Normals are geometric property of surface • Low poly surface: Renders fast but low lighting detail • Normalmapping: Store approximate normals in texture
Shadow Mapping • Texture: Stores length of blue arrows • Check green length to blue to determine shadows Depth as seen from light source
Shadow Techniques - Comparison Stencil SM PCF 5x5 Bil.PCF 5x5 VSM
Engine Overview Game Engine Sound Scene Manager Renderer AI Physics
Physics Overview Collision Detection Forces Integration
Physics Overview Collision Detection Forces Integration
Collision Detection • 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 – Rag Dolls • Example of simplification
Physics Overview Collision Detection Forces Integration
Forces • 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
Physics Overview Collision Detection Forces Integration
Integration • Good old Newton • Object’s state vector is integrated using numerical integration methods • Euler • RungeKutta …
Physics on the GPU • Use computational power of the GPU • Parallelize algorithms • For example: • PhysX engine by NVIDIA • Uses CUDA to drive the GPU
Engine Overview Game Scripts Game Engine Sound Scene Manager Renderer AI Physics
Scripting • Script programmers & technical artists • AI & Behavior • Physical properties • Animation behavior
Production • “Making the game” • Use engine to create an unique game • Mainly artists, designers and script writers
Questions? • Contact: • charlesfrederik.hollemeersch@ugent.be