3D Computer Games - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

3D Computer Games

Description:

Title: Insitute of Computer Graphics and Algorithms, Vienna University of Technology Subject: Insitute of Computer Graphics and Algorithms, Vienna University of ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 31
Provided by: Insituteo84
Category:

less

Transcript and Presenter's Notes

Title: 3D Computer Games


1
3D Computer Games
  • Peter Wonka
  • pwonka_at_gmail.com

2
Doom
3
Unreal Tournament
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

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

6
NVidia Architecture / DirectX 10
  • 16 Sets of 8 streaming processors (SP)
  • 128 processors are a lot faster than one

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

8
How to control the game?
  • Keyboard, Mouse, Trackball
  • ? You need a good library to manage input
  • ? You need to know about operating systems

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 DynamicArraylt triangle gt
    TriangleArray

v1
v2
v3
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

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
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
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
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!!

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 o for each triangle t in
    o.TriangleArray
  • temp_dist / temp_loc ? Intersect( t, l )
  • if (hit_distance lt smallest_distance)
  • hit_dist / hit_location temp_dist / temp_loc

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

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
3
2
0
1
2
3
18
Better Intersection
  • Top down
  • Front to back
  • Recursivealgorithm

4
3
2
1
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

20
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
  • TranslationThe 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
Integration?
  • Good news
  • no analytic computation required
  • nice and simple methods exist

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)

23
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
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
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
Monte Carlo Estimator
  • Extends easily to multiple dimensions
  • Still very simple to implement

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

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

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)

30
Faculty
  • Peter Wonka (Computer Graphics)
  • Gerald Farin (Geometric Modeling)
  • Greg Nielson (Scientific Visualization)
  • Ashish Amresh (Computer Games)
Write a Comment
User Comments (0)
About PowerShow.com