Transformations in the pipeline

Similar documents
4BA6 - Topic 4 Dr. Steven Collins. Chap. 5 3D Viewing and Projections

CS 4204 Computer Graphics

3D Viewing. Chapter 7. Projections. 3D clipping. OpenGL viewing functions and clipping planes

Realtime 3D Computer Graphics Virtual Reality

Basic Problem: Map a 3D object to a 2D display surface. Analogy - Taking a snapshot with a camera

CS 4204 Computer Graphics

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

INTRODUCTION TO RENDERING TECHNIQUES

Graphics Pipeline in a Nutshell

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

2D Geometrical Transformations. Foley & Van Dam, Chapter 5

Geometry for Computer Graphics

The Geometry of Perspective Projection

Line and Polygon Clipping. Foley & Van Dam, Chapter 3

An Introduction to. Graphics Programming

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Solutions to Practice Problems

Lecture 3: Coordinate Systems and Transformations

Geometric Transformation CS 211A

From 3D to 2D: Orthographic and Perspective Projection Part 1

Equations Involving Lines and Planes Standard equations for lines in space

42 CHAPTER 1. VECTORS AND THE GEOMETRY OF SPACE. Figure 1.18: Parabola y = 2x Brief review of Conic Sections

CATIA: Navigating the CATIA V5 environment. D. CHABLAT / S. CARO Damien.Chablat@irccyn.ec-nantes.fr

The mouse callback. Positioning. Working with Callbacks. Obtaining the window size. Objectives

Section 9.5: Equations of Lines and Planes

(a) We have x = 3 + 2t, y = 2 t, z = 6 so solving for t we get the symmetric equations. x 3 2. = 2 y, z = 6. t 2 2t + 1 = 0,

CHAPTER 8, GEOMETRY. 4. A circular cylinder has a circumference of 33 in. Use 22 as the approximate value of π and find the radius of this cylinder.

How To Draw A Billiards Ball In Gta 3D With Texture Mapping (Gta 3) On A Computer Or 2D Or Gta 2D (Gt) On Your Computer Or Computer Or Your Computer (Or Your Computer)

Methodology for Lecture. Review of Last Demo

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

MATHEMATICS FOR ENGINEERING BASIC ALGEBRA

Algebra Geometry Glossary. 90 angle

Chapter 4.1 Parallel Lines and Planes

2D Geometric Transformations

FURTHER VECTORS (MEI)

DERIVATIVES AS MATRICES; CHAIN RULE

x(x + 5) x 2 25 (x + 5)(x 5) = x 6(x 4) x ( x 4) + 3

Reflection and Refraction

Introduction to Computer Graphics

L 2 : x = s + 1, y = s, z = 4s Suppose that C has coordinates (x, y, z). Then from the vector equality AC = BD, one has

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Lecture Notes. Fundamentals of Computer Graphics. Prof. Michael Langer School of Computer Science McGill University

Section 12.6: Directional Derivatives and the Gradient Vector

discuss how to describe points, lines and planes in 3 space.

BLENDER INTRO BLENDER TIPS

THREE DIMENSIONAL GEOMETRY

B4 Computational Geometry

521493S Computer Graphics. Exercise 2 & course schedule change

Geometry in architecture and building

ME 111: Engineering Drawing

Fourth Grade Math Standards and "I Can Statements"

Epipolar Geometry. Readings: See Sections 10.1 and 15.6 of Forsyth and Ponce. Right Image. Left Image. e(p ) Epipolar Lines. e(q ) q R.

Essential Mathematics for Computer Graphics fast

Definition 8.1 Two inequalities are equivalent if they have the same solution set. Add or Subtract the same value on both sides of the inequality.

CIRCLE COORDINATE GEOMETRY

Three-Dimensional Figures or Space Figures. Rectangular Prism Cylinder Cone Sphere. Two-Dimensional Figures or Plane Figures

Mathematics Placement Examination (MPE)

Analysis of Stresses and Strains

Chapter 8 Geometry We will discuss following concepts in this chapter.

( ) ( ) Math 0310 Final Exam Review. # Problem Section Answer. 1. Factor completely: Factor completely: 3. Factor completely:

Introduction to Algebraic Geometry. Bézout s Theorem and Inflection Points

Chapter 23. The Reflection of Light: Mirrors

Algebra I Teacher Notes Expressions, Equations, and Formulas Review

Math 0980 Chapter Objectives. Chapter 1: Introduction to Algebra: The Integers.

CAMI Education linked to CAPS: Mathematics

SketchUp Instructions

Chapter 2 - Graphics Programming with JOGL

Exam 1 Sample Question SOLUTIONS. y = 2x

Solutions for Review Problems

ME 111: Engineering Drawing

Pro/ENGINEER Wildfire 4.0 Basic Design

Image Formation. 7-year old s question. Reference. Lecture Overview. It receives light from all directions. Pinhole

To Evaluate an Algebraic Expression

VOLUME of Rectangular Prisms Volume is the measure of occupied by a solid region.

2. SPATIAL TRANSFORMATIONS

Computer Graphics Labs

Rotation Matrices and Homogeneous Transformations

Grade 8 Mathematics Geometry: Lesson 2

Factoring Polynomials

PowerPoint: Graphics and SmartArt

Isometric Axes: The lines AB, AD and AE meeting at a point A and making an angle of 120 o with each other are termed isometric axes

TWO-DIMENSIONAL TRANSFORMATION

How to read Plans and Do Basic Drawings

MATH 60 NOTEBOOK CERTIFICATIONS

Introduction to 2D and 3D Computer Graphics Mastering 2D & 3D Computer Graphics Pipelines

Activity Set 4. Trainer Guide

Part I. Basic Maths for Game Design

SolidWorks. SolidWorks Teacher Guide. and Student Courseware

= y y 0. = z z 0. (a) Find a parametric vector equation for L. (b) Find parametric (scalar) equations for L.

Geometry and Measurement

SECOND DERIVATIVE TEST FOR CONSTRAINED EXTREMA

12-1 Representations of Three-Dimensional Figures

Section 1. Finding Common Terms

ACT Math Vocabulary. Altitude The height of a triangle that makes a 90-degree angle with the base of the triangle. Altitude

CBA Volume: Student Sheet 1

Lecture 2: Homogeneous Coordinates, Lines and Conics

C relative to O being abc,, respectively, then b a c.

Freehand Sketching. Sections

Transcription:

Transformations in the pipeline gltranslatef() Modeling transformation ModelView Matrix OCS WCS glulookat() VCS CCS Viewing transformation Projection transformation DCS Viewport transformation (e.g. pixels) NDCS Perspective division

Line (in 2D) Explicit Implicit Background (reminder) Parametric

Background (reminder) Plane equations Implicit Parametric Explicit

Reminder: Homogeneous Coordinates

Projection transformations

Introduction to Projection [Hill: 371-378, 398-404. Foley & van Dam: p. 229-242 ] Mapping: f : R n R m Projection: n > m Transformations Planar Projection: Projection on a plane. R 3 R 2 or R 4 R 3 homogenous coordinates.

Basic projections Parallel Perspective

Taxonomy

Examples

A basic orthographic projection x = x y = y z = N Matrix Form Y N Z I

A basic perspective projection Similar triangles x /d = x/(-z) -> x = x d/(-z) y /d = y/(-z) => y = y d/(-z) z = -d

In matrix form Matrix form of x = x d/(-z) y = y d/(-z) z = -d Moving from 4D to 3D

Projections in OpenGL

Camera coordinate system Image plane = near plane Camera at (0,0,0) Looking at z Image plane at z = -N

Perspective projection of a point In eye coordinates P =[Px,Py,Pz,1] T x/px = N/(-Pz) => x = NPx/(-Pz) y/px = N/(-Pz) => y = NPy/(-Pz)

Observations Perspective foreshortening Denominator becomes undefined for z = 0 If P is behind the eye Pz changes sign Near plane just scales the picture Straight line -> straight line

Perspective projection of a line Perspective Division, drop fourth coordinate

Is it a line? Cont d next slide

Is it a line? (cont d)

So is there a difference?

So is there a difference? The speed of the lines if cz is not 0

Inbetween points How do points on lines transform? M a Perspective division R B r R A b A B Viewing system: R(g) = (1-g)A + gb Projected (4D) : r = MR Projected cartesian: R (f) = (1-f)A + fb What is the relationship between g and f?

First step Viewing to homogeneous space (4D) M a R B r A b

Second step Perspective division A R M B a r b Perspective division A R B

Putting all together A R B M r a b Perspective division A R B

Relation between the fractions g R can be THAT texture MEANS: coordinates, For a color given etc. f in screen space and A,B in viewing space we can find the corresponding R (or g) in viewing space using the above formula. A can be texture coordinates, position, color, normal etc.

Effect of perspective projection Equations on lines [Hill 375] What happens to parallel lines?

Effect of perspective projection Parallel lines on lines [Hill 375] If parallel to view plane then:

Effect of perspective projection Parallel lines on lines [Hill 375] If not parallel to view plane then: Vanishing point!

Forshortening Non-linear Lines go to lines Summary Parallel lines either intersect or remain parallel Inbetweeness

Projections in the Graphics View volumes Our pipeline supports two projections: Orthographic Perspective Pipeline This stage also defines the view window What is visible with each projection? a cube or a pyramid Open GL Canonical view volume (left handed!)

View volumes Open GL Canonical view volume (left handed!)

Transformation vs Projection We want to keep z Why? Pseudodepth P 1 P 2 0 z 1 < z 2 -z I

Derivation of the orthographic Map each axis separately: Scaling and translation Let s look at y: y = ay+b such that bottom -1 top 1 transformation

Derivation of the orthographic transformation Scaling and Translation

All three coordinates Scaling and Translation

Matrix form

Perspective transformation Warps the view volume and the objects in it. Eye becomes a point at infiinity, and the projection rays become parallel lines (orthographic projection) We also want to keep z

Derivation of the perspective transformation It is basically a mapping of planes Normalized view volume is a left handed system!

Compute F and B: Deriving the Matrix

Forming the second equation From bottom plane

Solving the 2x2 system Compute F and B:

Compute E and A: Similarly for x

Compute C and D Similarly z

Putting everything together

Putting everything together Same as orthographic except the scaling and the position of the x,y translation parameters

Orthographic projection in OpenGL glmatrixmode(gl_projection) ; glloadidentity() ; Followed by one of: glortho(left,right,bottom,top,near,far) ; near plane at z = -near far plane at z = -far gluortho2d(left,right,bottom,top) ; assumes near = 0 far = 1

Perspective projection in OpenGL glmatrixmode(gl_projection) ; glloadidentity() ; Followed by one of: glfrustrum(left,right,bottom,top,near,far) ; near plane at z = -near far plane at z = -far gluperspective(fovy, aspect,bottom,top) ; fov measured in degrees and center at 0 Put the code in init or reshape callback.

Matrix pre-multiplies Modelview matrix M = Mproj*CM

Important Projection parameters are given in CAMERA Coordinate system (Viewing). So if camera is at z = 50 and you give near = 10 where is the near plane with respect to the world?

Important Projection parameters are given in CAMERA Coordinate system (Viewing). So if the camera is at z = 50 and you give near = 10 where is the near plane with respect to the world? Transformed by inverse(mvcs)

Tracks: Nonlinearity of perspective transformation Left: x= -1, y = -1 Right: x = 1, y = -1 Z = -inf, inf View volume: Left = -1, right = 1 Bot = -1, top = 1 Near = 1, far = 4

Comparison of cs s VCS CCS NDCS X X = EX + AZ X =X /W Y Y = FY + BZ Y = Y /W Z Z = CZ + D Z = Z /W Point Point Point 1 X = X = 1 X = -1/Z -1 Y = Y = -1 Y = 1 /Z Z Z = -5Z/3 8/3 Z = 5/3 +8/(3Z) W = -Z

Z in NDCS vs Z in VCS Z = 5/3 +8/(3Z) near far

Other comparisons X = -1/Z Z = -1/X

X = -1/Z Other comparisons Z = 5/3 +8/(3Z) Z = 5/3-(8/3)X

Keep what is visible 3D Clipping

Background (reminder) Plane equations Implicit Parametric Explicit

Intersection of line and plane

Planes Orthographic view volume Normals pointing inside left: x - left = 0 right: -x + right = 0 bottom: y - bottom = 0 top: -y + top = 0 front: -z - near = 0 back: z + far = 0

Planes Perspective View volume Normals pointing inside left: x + left*z/near = 0 right: -x - right*z/near = 0 top: -y - top*z/near = 0 bottom: y + bottom*z/near = 0 front: -z - near = 0 back: z + far = 0

Clipping in NDCS Normalized view volume Constant planes Lines in VCS lines NDCS Problem Z coordinate loses its sign

Clipping in CCS We'll define the clipping region in CCS by first looking at the clipping region in NDCS: -1 <= x/w <= 1 This means that in CCS, we have: -w <= x <= w Similarly for y,z

Example The perspective transformation creates W = -z Typo: they should have different z

Viewport transformation M -1 cam OCS WCS VCS CCS Modeling transformation Viewing transformation Projection transformation DCS Viewport transformation NDCS Perspective division

Viewport

Viewport matrix Scales the x,y to the dimensions of the viewport Scales z to be in [0,1] Matrix form left as an exercise.

Why viewports? Undo the distortion of the projection transformation

Stereo views

Viewport in OpenGL glviewport(glint x, GLint y, GLsizei width, GLsizei height) ; x,y: lower left corner of viewport rectangle in pixels width, height: width and height of viewport. Put the code in reshape callback.

Transformations in the pipeline ModelView Matrix glortho() glfrustrum() OCS WCS glulookat() VCS gluperspective CCS gltranslatef() Modeling transformation Viewing transformation Projection transformation DCS Viewport transformation (e.g. pixels) glviewport() NDCS Perspective division