Download presentation

Presentation is loading. Please wait.

Published byNina Hickmon Modified over 3 years ago

1
3D Computer Games Peter Wonka pwonka@gmail.com

2
Peter Wonka, ASU 101 1 Doom

3
Peter Wonka, ASU 101 2 Unreal Tournament

4
Peter Wonka, ASU 101 3 How to implement a Computer Game? Computer Games need to be fast at least 60 image per second (the monitor refresh rate) You need an efficient programming language You have to learn C++ You cannot use Java, Visual Basic, C# for critical routines. Note: A mixture of languages can be used but right now the performance critical parts are dominated by C++ in the industry Efficient Programming Language is not enough We need an efficient architecture Regular Intel / AMD CPU is too slow

5
Peter Wonka, ASU 101 4 Computation Speed How can we make computation faster? Idea: Parallel Computing In the last years most speed gains come from massive parallel computation Graphics hardware is a cheap parallel “supercomputer” that can work with your PC You need to study computer architecture and parallel computing to build fast hardware You need to study computer architecture and parallel computing to implement fast algorithms! Fast implementation is not always intuitive and requires detailed system level knowledge

6
Peter Wonka, ASU 101 5 NVidia Architecture / DirectX 10 16 Sets of 8 “streaming processors” (SP) 128 processors are a lot faster than one

7
Peter Wonka, ASU 101 6 Why is graphics hardware so fast? Same small program is run for a large amount of data Restricted memory access for reading memory Very restricted memory access for writing to memory

8
Peter Wonka, ASU 101 7 How to control the game? Keyboard, Mouse, Trackball You need a good library to manage input You need to know about operating systems

9
Peter Wonka, ASU 101 8 How to store a scene? How to model a scene? Professional 3D software (e.g. Maya, 3D Max) Design problem, not taught in computer science! How to store a scene? Super Simple First Try (no colors) class point { float x,y,z; }; class triangle { point v1, v2, v2; }; class object{ DynamicArray TriangleArray; }; v1 v2 v3

10
Peter Wonka, ASU 101 9 How to draw a scene? Super Simple Rendering Algorithm (Wireframe) For each object o For each triangle t in o.TriangleArray v1 projected = project t.v1 onto image plane v2 projected = project t.v2 onto image plane v3 projected = project t.v3 onto image plane Draw line from v1 projected to v2 projected Draw line from v2 projected to v1 projected Draw line from v3 projected to v1 projected

11
Peter Wonka, ASU 101 10 How to project a point on an image plane? Points in 3D are encoded as vectors in a 4D vector space. v1 = (x,y,z,1), e.g. v1 = (7, 5, 3, 1) You need to understand vectors and vector spaces Why do you need 4 coordinates and why is the fourth coordinate always 1? These coordinates are called homogenous coordinates Why will not be answered in this class y x z v1

12
Peter Wonka, ASU 101 11 How to project a point on an image plane? Points are projected using matrix multiplication: v1Projected = ProjectionMatrix * v1 ProjectionMatrix is defined by a virtual camera in the scene v1 Virtual Camera 1 Virtual Camera 2 Virtual Camera 3

13
Peter Wonka, ASU 101 12 How to transform objects in the scene? Most important transformations: Translation and Rotation You need matrix vector multiplication again Simply multiply all vertices of an object Below: Rotation around the z-axis with angle theta y x z

14
Peter Wonka, ASU 101 13 More Transformations How to compound transformations? You need matrix - matrix multiplication How to invert a transformations? You need to compute inverse matrices How to determine which transformations can be inverted? You need the concept of singular matrices Summary You need to implement fast code in C++ You need to learn Linear Algebra!!

15
Peter Wonka, ASU 101 14 Shooting in Games? Your character shoots (along a straight line) What is hit? Super Simple Algorithm construct a straight line l for each object o for each triangle t in o.TriangleArray temp_dist / temp_loc Intersect( t, l ) if (hit_distance < smallest_distance) hit_dist / hit_location = temp_dist / temp_loc

16
Peter Wonka, ASU 101 15 Shooting in Games Problem: Algorithm is inefficient If the scene has 1M triangles we wait for a very long time Solution: Use hierarchical data structures Octree (quadtree is 2d version) Kd-tree BSP-tree We need knowledge about algorithms and (spatial) data structures

17
Peter Wonka, ASU 101 16 Quadtrees Quatree is a spatial data structure Root node encloses a quadratic (rectangular space) Every internal node has four children Space is subdivided regularly root 013 0123 2

18
Peter Wonka, ASU 101 17 Better Intersection Top down Front to back Recursive algorithm 1 2 3 4

19
Peter Wonka, ASU 101 18 How to create nice Shading Effects? Idea: Create a rough 3D models with Triangles Pretend the surfaces are smooth and have details You need to use (Vector) Calculus, Differential Geometry, and Geometric Modeling

20
Peter Wonka, ASU 101 19 How to compute nice lighting effects? Problem: What color has a point x in the image? During the game: there is not time Solution: Precomputation Example Formulation: Translation: The color (light energy) of the point E(x) is the sum of all incoming light energy in a hemisphere of x You need Calculus x

21
Peter Wonka, ASU 101 20 Integration? Good news: no analytic computation required nice and simple methods exist

22
Peter Wonka, ASU 101 21 Integration Low dimensional Integrals trapezoidal integration gaussian quadrature Higher dimensional Integrals Monte Carlo integration Randomized Algorithms Monte Carlo – use randomness but results depends on the sequence of random numbers Las Vegas – use randomness but always give the same answer in the end (differ in speed)

23
Peter Wonka, ASU 101 22 Monte Carlo Estimator Algorithm Idea: Pick N random variables Xi Sample function at Xi Compute weighted average Question: How to exactly compute the average? a b

24
Peter Wonka, ASU 101 23 Monte Carlo Estimator How can we show that the estimate is “correct”? What does it mean to be correct? You need to learn Probability and Statistics

25
Peter Wonka, ASU 101 24 Monte Carlo Estimator Proof Idea: Show that the expected value is the value of the integral Proof details are beyond the scope of this lecture, just to give you an idea:

26
Peter Wonka, ASU 101 25 Monte Carlo Estimator Extends easily to multiple dimensions Still very simple to implement

27
Peter Wonka, ASU 101 26 How to cheat in games? Multiplayer Online Games Cheating Ideas Modify the rendering of the game so you can see through walls Send incorrect movement updates for your opponents Use a bot You connect to a bot server, the bot connects to the real game bot filters your interaction You move, but the bot automatically shoots with “perfect” aim Game companies need to prevent cheating You need to learn about Networking Security Artificial Intelligence

28
Peter Wonka, ASU 101 27 How to animate fire, water, smoke? You need PDEs = partial differential equations E.g. Navier Stokes Equations

29
Peter Wonka, ASU 101 28 Summary Implementation skills and algorithms are important for computer games Mathematics is also important (especially if you want to have a very good job)

30
Peter Wonka, ASU 101 29 Faculty Peter Wonka (Computer Graphics) Gerald Farin (Geometric Modeling) Greg Nielson (Scientific Visualization) Ashish Amresh (Computer Games)

Similar presentations

OK

Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.

Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google