Introduction to Computer Graphics 4. Viewing in 3D

Similar documents
Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

Classical and Computer Viewing. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Computer Graphics. Jeng-Sheng Yeh 葉正聖 Ming Chuan University (modified from Bing-Yu Chen s slides)

2D and 3D Viewing Basics

Three-Dimensional Viewing Hearn & Baker Chapter 7

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Fundamental Types of Viewing

Course no. DIS4566 National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor

Computer Viewing Computer Graphics I, Fall 2008

Computer Viewing and Projection. Overview. Computer Viewing. David Carr Fundamentals of Computer Graphics Spring 2004 Based on Slides by E.

Computer Viewing. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Chap 7, 2008 Spring Yeong Gil Shin

Chapter 5. Projections and Rendering

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Building Models. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

Announcement. Project 1 has been posted online and in dropbox. Due: 11:59:59 pm, Friday, October 14

Computer Graphics. P05 Viewing in 3D. Part 1. Aleksandra Pizurica Ghent University

Chap 7, 2009 Spring Yeong Gil Shin

CS452/552; EE465/505. Models & Viewing

Chapter 8 Three-Dimensional Viewing Operations

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

5.8.3 Oblique Projections

Overview of Projections: From a 3D world to a 2D screen.

Computer Viewing. Prof. George Wolberg Dept. of Computer Science City College of New York

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Projection Lecture Series

Viewing with Computers (OpenGL)

Chap 3 Viewing Pipeline Reading: Angel s Interactive Computer Graphics, Sixth ed. Sections 4.1~4.7

So we have been talking about 3D viewing, the transformations pertaining to 3D viewing. Today we will continue on it. (Refer Slide Time: 1:15)

Computer Graphics Chapter 7 Three-Dimensional Viewing Viewing

CS 4204 Computer Graphics

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Introduction to Computer Graphics with WebGL

Lecture 4: Viewing. Topics:

Building Models. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Geometry: Outline. Projections. Orthographic Perspective

CS 418: Interactive Computer Graphics. Projection

COMP Computer Graphics and Image Processing. a6: Projections. In part 2 of our study of Viewing, we ll look at. COMP27112 Toby Howard

3.1 Viewing and Projection

Computer Viewing. CITS3003 Graphics & Animation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley

Viewing and Projection

Virtual Cameras & Their Matrices

CSC 470 Computer Graphics. Three Dimensional Viewing

Viewing. Reading: Angel Ch.5

COMP3421. Introduction to 3D Graphics

Viewing and Projection

CSC 470 Computer Graphics

3-Dimensional Viewing

Chapter 5-3D Camera & Optimizations, Rasterization

COMP3421. Introduction to 3D Graphics

Chapter 4-3D Camera & Optimizations, Rasterization

Viewing/Projections IV. Week 4, Fri Feb 1

Realtime 3D Computer Graphics & Virtual Reality. Viewing

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Viewing and Projection

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

CS452/552; EE465/505. Intro to Lighting

On the Midterm Exam. Monday, 10/17 in class. Closed book and closed notes. One-side and one page cheat sheet is allowed. A calculator is allowed

Viewing and Projection Transformations

Overview. By end of the week:

Computer Graphics. Ch 6. 3D Viewing

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

SE Mock Online Retest 2-CG * Required

OpenGL Transformations

3D Viewing. CS 4620 Lecture 8

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

Projections. Brian Curless CSE 457 Spring Reading. Shrinking the pinhole. The pinhole camera. Required:

COMP3421. Introduction to 3D Graphics

CSE528 Computer Graphics: Theory, Algorithms, and Applications

COMP30019 Graphics and Interaction Perspective Geometry

Computer Graphics 7: Viewing in 3-D

CSE328 Fundamentals of Computer Graphics

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

(Refer Slide Time: 00:01:26)

National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor

Introduction to Computer Graphics 7. Shading

MAE : Lecture #12 - Projection and Perspective. Lecture Overview:

Content. Coordinate systems Orthographic projection. (Engineering Drawings)

CSC 305 The Graphics Pipeline-1

Lecture 4. Viewing, Projection and Viewport Transformations

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

Three Main Themes of Computer Graphics

CS488. Implementation of projections. Luc RENAMBOT

Reminder: Affine Transformations. Viewing and Projection. Shear Transformations. Transformation Matrices in OpenGL. Specification via Ratios

Viewing. Cliff Lindsay, Ph.D. WPI

Computer Graphics. Lecture 04 3D Projection and Visualization. Edirlei Soares de Lima.

COMP30019 Graphics and Interaction Perspective & Polygonal Geometry

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Viewing Transformation

GEOMETRIC TRANSFORMATIONS AND VIEWING

COMS 4160: Problems on Transformations and OpenGL

Transcription:

Introduction to Computer Graphics 4. Viewing in 3D National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor Textbook: E.Angel, Interactive Computer Graphics, 5 th Ed., Addison Wesley Ref: Hearn and Baker, Computer Graphics, 3rd Ed., Prentice Hall

Outline Classical views Computer viewing Projection matrices

Classical Viewing Viewing requires three basic elements One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface Each object is assumed to constructed from flat principal faces Buildings, polyhedra, manufactured objects

Planar Geometric Projections Standard projections project onto a plane. Projectors are lines that either converge at a center of projection are parallel Such projections preserve lines but not necessarily angles When do we need non-planar projections?

Classical Projections

Perspective vs Parallel Classical viewing developed different techniques for drawing each type of projection Mathematically parallel viewing is the limit of perspective viewing Computer graphics treats all projections the same and implements them with a single pipeline

Taxonomy of Planar Geometric Projections planar geometric projections parallel perspective multiview orthographic axonometric 1 point 2 point 3 point oblique isometric dimetric trimetric

Perspective Projection

Parallel Projection

Orthographic Projection Projectors are orthogonal to projection surface

Multiview Orthographic Projection Projection plane parallel to principal faces Usually form front, top, side views isometric (not multiview orthographic view) front in CAD and architecture, we often display three multiviews plus isometric top side

Advantages and Disadvantages Preserves both distances and angles Shapes preserved Can be used for measurements Building plans Manuals Cannot see what object really looks like because many surfaces hidden from view Often we add the isometric

Axonometric Projections Allow projection plane to move relative to object classify by how many angles of a corner of a projected cube are the same none: trimetric two: dimetric three: isometric q 2 q 1 q 3

Types of Axonometric Projections

Advantages and Disadvantages Lines are scaled (foreshortened) but can find scaling factors Lines preserved but angles are not Projection of a circle in a plane not parallel to the projection plane is an ellipse Does not look real because far objects are scaled the same as near objects Used in CAD applications

Oblique Projection Arbitrary relationship between projectors and projection plane

Perspective Projection Projectors coverage at center of projection

Vanishing Points Parallel lines (not parallel to the projection plan): converge at a single point in the projection (the vanishing point) Drawing simple perspectives by hand uses these vanishing point(s) vanishing point

Three-Point Perspective No principal face parallel to projection plane Three vanishing points for cube

Two-Point Perspective On principal direction parallel to projection plane Two vanishing points for cube

One-Point Perspective One principal face parallel to projection plane One vanishing point for cube

Advantages and Disadvantages Diminution: Objects further from viewer are projected smaller (Looks realistic) Nonuniform foreshortening: Equal distances along a line are not projected into equal distances Angles preserved only in planes parallel to the projection plane More difficult to construct by hand than parallel projections

Projections and Normaliation The default projection in the eye (camera) frame is orthogonal For points within the default view volume x p = x y p = y p =

Homogeneous Coordinate Representation default orthographic projection x p = x y p = y p = w p = 1 M = p p = Mp 1 1 1 In practice, we can let M = I and set the term to ero later

Simple Perspective Center of projection at the origin Projection plane = d, d <

Perspective Equations Top view Side view x / d x p = x / d y p = y / d p = d

Homogeneous Coordinate Form M = 1/ 1 1 1 d consider q = Mp where 1 y x d y x / p = q =

Perspective Division However w 1, so we must divide by w to return from homogeneous coordinates This perspective division yields x p = x / d y p = y / d p = d the desired perspective equations

Computer Viewing

Pipeline View MC Modeling WC Viewing VC Transformation Transformation Projection Transformation Normaliation and clipping Viewport PC NC Transformation DC Let s skip the clipping details temporarily!

Computer Viewing Three aspects of the viewing process implemented in the pipeline: Positioning the camera Setting the model-view matrix Selecting a lens Setting the projection matrix Clipping Setting the view volume

The OpenGL Camera In OpenGL, initially the object and camera frames are the same Default model-view matrix is an identity The camera is located at origin and points in the negative direction OpenGL also specifies a default view volume that is a cube with sides of length 2 centered at the origin Default projection matrix is an identity

Moving the Camera Frame If we want to visualie object with both positive and negative values we can either Move the camera in the positive direction Translate the camera frame Move the objects in the negative direction Translate the world frame Both of these views are equivalent and are determined by the model-view matrix Want a translation (gltranslatef(.,.,- d);) d >

Moving Camera back from Origin default frames frames after translation by d d >

Moving the Camera We can move the camera to any desired position by a sequence of rotations and translations Example: side view Rotate the camera Move it away from origin Model-view matrix C = TR

glulookat gllookat(eyex, eyey, eye, atx, aty, at, upx, upy, up)

By Coordinate Transformations 1 1 1 vc vc vc y y y x x x wc wc wc y x w v u w v u w v u y x x (1,,) y (, 1, ) (,,1) u v w u (u x, u y, u ) optic axis v (v x, v y, v ) w (w x, w y, w ) c 1 1 1 1 1 1 vc vc vc y x vc vc vc y x c c c y x

Taking Clipping into Account After the view transformation, a simple projection and viewport transformation can generate screen coordinate. However, projecting all vertices are usually unnecessary. Clipping with 3D volume. Associating projection with clipping and normaliation. Why do we use normaliation?

Orthogonal Viewing Volume

Orthogonal Normaliation glortho(left,right,bottom,top,near,far) normaliation find transformation to convert specified clipping volume to default (x wmax, y wmax, far ) Y norm (1, 1, 1) Z norm x norm (x wmin, y wmin, near ) Z view Y view x view (-1, -1, -1)

Orthogonal Matrix Two steps T: Move center to origin S: Scale to have sides of length 2 P = ST = xw max 2 xw min yw max 2 yw min near 2 far xw xw yw yw max max max max near near xw xw yw yw 1 far far min min min min

Clipping for Perspective Views

Perspective Viewing Volume

Normaliation Rather than derive a different projection matrix for each type of projection, we can convert all projections to orthogonal projections with the default view volume This strategy allows us to use standard transformations in the pipeline and makes for efficient clipping

Normaliation

Perspective-Projection Trans. P= (x, y, ) y view (x p, y p, vp ) x view view (x prp, y prp, prp ) x y x y p p p p (1 u) x ux (1 u) y uy x prp y prp prp prp vp vp x y View plane prp prp prp prp vp prp u = ~ 1 vp prp Given x prp =y prp = prp =, vp = near x y p p x near y near

Perspective-Projection Trans. t s t s y y x x p near p near p 1 near near pers t s M After perspective division, the point (x,y,,1) goes to To make -1 p 1 far near far near far near far near t s 2

Perspective-Projection Trans. Distorted object far near xw min xw max xw min original clipping volume xw max original object new clipping volume

1 2 far near far near far near far near near near pers M Further Normaliation 1 2 2 2 min max min max far near far near far near far near near near normpers yw yw xw xw M original object -1 1 far near

Notes Normaliation let us clip against a simple cube regardless of type of projection Delay final projection until end Important for hidden-surface removal to retain depth information as long as possible

Normaliation and Hidden- Surface Removal if 1 > 2 in the original clipping volume then the for the transformed points 1 < 2 Hidden surface removal works if we first apply the normaliation transformation However, the formula = -(s +t /) implies that the distances are distorted by the normaliation which can cause numerical problems especially if the near distance is small

Why do we do it this way? Normaliation allows for a single pipeline for both perspective and orthogonal viewing We stay in four dimensional homogeneous coordinates as long as possible to retain threedimensional information needed for hiddensurface removal and shading Clipping is now easiler.

Viewport Transformation From the working coordinate to the coordinate of display device. (1,1) (,) (,) (-1,-1) By 2D scaling and translation (6,6) Next: clipping and normaliation!

APPENDIX

Using Field of View In addition to directly assigning the viewing frustum, assigning field of view may be more user-friendly. front plane aspect = w/h

Final Projection Set = Equivalent to the homogeneous coordinate transformation Hence, general orthogonal projection in 4D is 1 1 1 M orth = P = M orth ST

Oblique Parallel Projection

Oblique Parallel Projection Oblique Projection = Shear + Orthogonal Projection top view side view

Shear Matrix xy shear ( values unchanged) H(q,f) = 1 cot θ 1 cot φ 1 1 Projection matrix General case: P = M orth H(q,f) P = M orth STH(q,f)

More General Cases x p vp x V V px p y p vp y V V py p

More General Cases p py vp p p px vp p V V y y V V x x ) ( ) ( 1 1 1 1 p py vp p py p px vp p px oblique V V V V V V V V M oblique ortho norm norm oblique M M M,,

Equivalency

Effect on Clipping The projection matrix P = STH transforms the original clipping volume to the default clipping volume object top view = 1 DOP clipping volume near plane far plane x = -1 = -1 DOP x = 1 distorted object (projects correctly)