1 / 30

3D Computer Games

3D Computer Games. Peter Wonka pwonka@gmail.com. Doom. Unreal Tournament. 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++

samuel-buck
Download Presentation

3D Computer Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Doom Peter Wonka, ASU 101

  3. Unreal Tournament Peter Wonka, ASU 101

  4. 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 Peter Wonka, ASU 101

  5. 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 Peter Wonka, ASU 101

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

  7. 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 Peter Wonka, ASU 101

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

  9. 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< triangle > TriangleArray; }; v1 v2 v3 Peter Wonka, ASU 101

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

  11. 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 v1 x z Peter Wonka, ASU 101

  12. 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 Virtual Camera 3 Virtual Camera 1 v1 Virtual Camera 2 Peter Wonka, ASU 101

  13. 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 Peter Wonka, ASU 101

  14. 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!! Peter Wonka, ASU 101

  15. Shooting in Games? • Your character shoots (along a straight line)What is hit? • Super Simple Algorithm construct a straight line l for each object ofor 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 Peter Wonka, ASU 101

  16. 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 Peter Wonka, ASU 101

  17. 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 0 1 2 3 0 1 2 3 Peter Wonka, ASU 101

  18. Better Intersection • Top down • Front to back • Recursivealgorithm 4 3 2 1 Peter Wonka, ASU 101

  19. 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 GeometricModeling Peter Wonka, ASU 101

  20. 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 How to compute nice lighting effects? x Peter Wonka, ASU 101

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

  22. 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) Peter Wonka, ASU 101

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

  24. 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 Peter Wonka, ASU 101

  25. 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: Peter Wonka, ASU 101

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

  27. 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 Peter Wonka, ASU 101

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

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

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

More Related