Video Game Rendering Mathematics

Slides:



Advertisements
Similar presentations
BELLWORK SINGLE POINT PERSPECTIVE
Advertisements

3D Geometry for Computer Graphics
Computer Graphics Lecture 4 Geometry & Transformations.
Chapter 5 Matrices & Linear Transforms
Special Right Triangles
VECTORS Computer Graphics. A REVIEW OF VECTORS:  Scalar Quantity  Vector Quantity  2D vectors  Graphical Representation of Vectors  Magnitude of.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
Outline for Today More math… Finish linear algebra: Matrix composition
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
Chapter 2: Vectors Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics and Game Development.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
CAP4730: Computational Structures in Computer Graphics
CS 450: Computer Graphics 2D TRANSFORMATIONS
Last lecture summary Fundamental system in linear algebra : system of linear equations Ax = b. nice case – n equations, n unknowns matrix notation row.
Reference: “3D Math Primer for Graphics and Game Development, 2 nd ed.” Chapter 5 Chapter 6.x MATRIX.
2IV60 Computer Graphics Basic Math for CG
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Mathematical Fundamentals
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Game Physics – Part IV Moving to 3D
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Patrick Nichols Thursday, September 18, Linear Algebra Review.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Chapter 4.1 Mathematical Concepts
COMP 175: Computer Graphics March 24, 2015
Pythagorean Theorem, Special angles, and Trig Triangles Right Triangles Test Review.
The Pythagorean Theorem in 3D
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
CSCE 552 Spring 2011 Math By Jijun Tang. Layered.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
The Law of Sines The Law of Cosines And we’re not talking traffic (7.1, 7.2)
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Matthew Christian. About Me Introduction to Linear Algebra Vectors Matrices Quaternions Links.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Vectors have magnitude AND direction. – (14m/s west, 32° and falling [brrr!]) Scalars do not have direction, only magnitude. – ( 14m/s, 32° ) Vectors tip.
Higher Dimensions. x Let's say we use a pencil to mark a point on paper. x is this point. We pick a direction and move the pencil along this direction.
Computer Graphics Matrices
Honours Graphics 2008 Session 2. Today’s focus Vectors, matrices and associated math Transformations and concatenation 3D space.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
2/28/2016 CS 551 / 645: Introductory Computer Graphics Framebuffer Mathematical Foundations The Rendering Pipeline.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
Transformations for GCSE Maths Enlargement Translation Reflection Rotation.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Linear Algebra Review Tuesday, September 7, 2010.
Matrix Transformations Reference: “3D Math Primer for Graphics and Game Development” – , , , , 9.4
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Complete Math Skills Review for Science and Mathematics
- Introduction - Graphics Pipeline
CENG 477 Introduction to Computer Graphics
COMP 175: Computer Graphics February 9, 2016
GAM 325/425: Applied 3D Geometry
Transformations for GCSE Maths
S4 Coordinates and transformations 1
Transformations for GCSE Maths
Eureka Math 8th Grade Module 2
Transformations for GCSE Maths
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Linear Algebra A gentle introduction
Game Programming Algorithms and Techniques
Presentation transcript:

Video Game Rendering Mathematics Zack Booth Simpson

From unrealtechnology.com How to we model a body? Break each object up into lots of triangles. Each “face” is connected to a mesh of “vertices” Make each part of a “body” rigid Connect the rigid parts together with joints Let the joints rotate From unrealtechnology.com

Rendering Meshes Each vertex is positioned by an artist. The programmers get this vertex list and tell the computer to connect the dots. But the vertices are in 3D?! How do we get from a 3D model to a 2D view on the screen? Create a virtual camera

Pretend Cameras What does the camera see of this box? Two problems to solve: Relative position and orientation of the box versus the camera The perspective distortion

Perspective: Things further away appear smaller Create a pretend “projection plane” that represents the computer screen

Exercise: The Perspectometer

Answers: The Perspectometer The length of the line on the board is 3 feet. The units are feet, because the distance from your eye to the board was measured in feet. Note that the length of your arm and the apparent height of the line were both measured in inches.

Position and Orientation Meet “vector” From Latin “vehere” = “to carry” same root as “vehicle” Each object in the world is placed and oriented. Vectors let us get from place to place and orient ourselves. Where are the vertices of the box from the point of view of the camera? (Never mind perspective for now)

Translate = Move without rotate Relative position is easy Vector addition and subtraction! a + b - c = d d is relative to the camera… we say “d is the position of the vertex in camera space”

Rotation Now things get harder From the camera’s point of view the box is rotated From the box’s point of view the camera is rotated Coping with differing points of view is always a challenge!

Who’s point of view is right?

Both / Neither side is right We need a way to measure each vector using the other one as the unit ruler. In other words: we need tools to convert from one point of view to the other.

Projection a/b from b’s perspective; b/a from a’s perspective Remember always: “a/b” means “measure a against b” or “using b as the ruler, how long is a?” It is easy to forget/get confused about this… I wish a teacher had beaten this into my head with a stick!

Oh boy, here we go again…

Projection from different directions Each side can be projected onto the other.

As a is rotated away from b, the projection diminishes until at 90 degrees it is zero Perpendicular vectors can not measure each other; they have zero relative projections!

Projection with Cosine We don’t want no stinking cosines – they’re a pain! Here’s a great trick…

Ever seen this lovely proof of the Pythagorean theorem?

Rectangular Version of the Pythagorean Theorem Dot product graphic removed pending publication Cool! We can compute the projection with just two multiplies and add! Games have millions of vertices so this is very important! Considering speed is the difference between mathematics and computation!

Projection with the dot product from b’s point of view TADA! p can be computed without angles or cosines!

More Dot Product Goodness Dot product sign tells you about the relationship of the vectors. Same general direction Orthogonal Opposite directions

Exercise: Dot Products

Answers: Dot Products

Back to Rotations Ok, so now we can project a vector onto another What’s this got to do with rotations again? Represent the camera’s POV as aligned vectors. Call these “basis vectors” as in “base” The projection onto these vectors gives us the rotation we want! i.e. the box from the POV of camera

Basis Vector Demo Run demo app Skew, rotation, scale, reflection, projection Orthogonal basis vectors create a rotation or reflection

The Matrix A cool way to organize basis vectors: The Matrix The default basis vectors are one unit in each direction. Write each basis vector as a column in the matrix Write a block of numbers but visualize vectors! The matrix encodes any “linear” transformation

The Power of The Matrix

The Matrix as a Teleporter The matrix is a “teleportation machine” which moves points from one space to another

A Teleporter inside a Teleporter?! What happens if you put a teleporter inside a teleporter? Compounding teleportations!

Matrix Concatenation Map the basis vectors of one space into the another

Matrix Concatenation Using Dot product

Matrix Concatenation Using Dot product

Matrix Concatenation Using Dot product

Matrix Concatenation Using Dot product

Exercise: Matrix Arithmetic

Answers: Matrix Arithmetic

Rotate, Scale, and Translate? So now we can rotate, scale, etc. but what ever happened to translations? The ugly way Would be nice to matrixify™ it!

Stuffin’ the Matrix Make up a pretend dimension for the translation Hardwire “1” unit of this extra dimension in all vertices to be transformed. Where is this extra dimension exactly? Who cares! It works! Math is so cool

Moving to 3D Just add a dimension again. Now matrices are 4x4 Right-hand rule From math.montana.edu

Exercise: Matrix Transforms

Answers: Matrix Transformations

Game: Matrix Mine Sweeper There’s a bomb in a house There’s two rounds You must move the bomb with one of the three given matrices in each round You can not go off the map Plan ahead!!

Game: Matrix Mine Sweeper There’s a bomb in a house There’s two rounds You must move the bomb with one of the three given matrices in each round You can not go off the map Plan ahead!! GO!

Answers: Matrix Mine Sweeper Round 1

Game: Matrix Mine Sweeper Round 2. GO!!

Answers: Matrix Mine Sweeper Round 2

Answers: Matrix Mine Sweeper Bonus Round!! If you are outside a building, you’re a hero!

Answers: Matrix Mine Sweeper Bonus Round!! If you are outside a building, you’re a hero! If you are inside, this is your last chance! You are almost dead! Quick! Make up your own matrix! You have 20 seconds! GO!

BOOM! From www.prostunts.net

A final desperate solution! The zero matrix! Collapse all paths to a singularity!