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

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

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

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

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

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

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Introduction to Computer Graphics with WebGL

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

Chapter 8 Three-Dimensional Viewing Operations

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

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

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

Computer Viewing Computer Graphics I, Fall 2008

Viewing with Computers (OpenGL)

Viewing. Reading: Angel Ch.5

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

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

Introduction to Computer Graphics 4. Viewing in 3D

Chap 7, 2008 Spring Yeong Gil Shin

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

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

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

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

5.8.3 Oblique Projections

Introduction to Computer Graphics with WebGL

Chapter 5. Projections and Rendering

Chap 7, 2009 Spring Yeong Gil Shin

COMP30019 Graphics and Interaction Perspective Geometry

Fundamental Types of Viewing

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

CS 432 Interactive Computer Graphics

Three-Dimensional Viewing Hearn & Baker Chapter 7

Viewing. Part II (The Synthetic Camera) CS123 INTRODUCTION TO COMPUTER GRAPHICS. Andries van Dam 10/10/2017 1/31

CS452/552; EE465/505. Models & Viewing

COMP30019 Graphics and Interaction Perspective & Polygonal Geometry

Lecture 4: Viewing. Topics:

Viewing and Projection Transformations

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

Chapter 5-3D Camera & Optimizations, Rasterization

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)

CS354 Computer Graphics Viewing and Modeling

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

Models and The Viewing Pipeline. Jian Huang CS456

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

CS 4204 Computer Graphics

(Refer Slide Time: 00:01:26)

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS 563 Advanced Topics in Computer Graphics Camera Models. by Kevin Kardian

Specifying Complex Scenes

GEOMETRIC TRANSFORMATIONS AND VIEWING

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

Chapter 4-3D Camera & Optimizations, Rasterization

Viewing Transformation

CS452/552; EE465/505. Intro to Lighting

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

Lecture 4. Viewing, Projection and Viewport Transformations

CS 418: Interactive Computer Graphics. Projection

Overview. By end of the week:

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Models and Architectures

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

Geometry: Outline. Projections. Orthographic Perspective

Three Main Themes of Computer Graphics

Computer Graphics. Ch 6. 3D Viewing

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

CSE452 Computer Graphics

Introduction to Computer Graphics with WebGL

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

Prof. Feng Liu. Fall /19/2016

SE Mock Online Retest 2-CG * Required

2D and 3D Viewing Basics

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

Game Architecture. 2/19/16: Rasterization

CS452/552; EE465/505. Review & Examples

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

Computer Graphics Viewing

Projection Lecture Series

COMP3421. Introduction to 3D Graphics

Computer Graphics Chapter 7 Three-Dimensional Viewing Viewing

COMP3421. Introduction to 3D Graphics

Realtime 3D Computer Graphics & Virtual Reality. Viewing

3D Viewing. CS 4620 Lecture 8

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

Viewing. Announcements. A Note About Transformations. Orthographic and Perspective Projection Implementation Vanishing Points

CS 325 Computer Graphics

Last week. Machiraju/Zhang/Möller

Viewing/Projections IV. Week 4, Fri Feb 1

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

Viewing. Cliff Lindsay, Ph.D. WPI

Content. Coordinate systems Orthographic projection. (Engineering Drawings)

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS488. Implementation of projections. Luc RENAMBOT

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

Lecture 5: Transforms II. Computer Graphics and Imaging UC Berkeley CS184/284A

3D Viewing Episode 2

CSE328 Fundamentals of Computer Graphics

Last week. Machiraju/Zhang/Möller/Fuhrmann

Transforms 3: Projection Christian Miller CS Fall 2011

Virtual Cameras and The Transformation Pipeline

Transcription:

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

Reading Chapter 4 of Angel Chapter 13 of Hughes, van Dam, Chapter 7 of Shirley+Marschner Machiraju/Zhang/Möller 2

Objectives What kind of camera we use? (pinhole) What projections make sense Orthographic Perspective The viewing pipeline Viewing in WebGL Shadows Machiraju/Zhang/Möller 3

3D Viewing Popular analogy: virtual camera taking pictures in a virtual world The process of getting an image onto the computer screen is like that of taking a snapshot. Machiraju/Zhang/Möller 4

3D Viewing (2) With a camera, one: establishes the view opens the shutter and exposes the film Machiraju/Zhang/Möller 5

3D Viewing (3) With a camera, one: establishes the view opens the shutter and exposes the film With a computer, one: chooses a projection type (not necessarily perspective) establishes the view clips the scene according to the view projects the scene onto the computer display Machiraju/Zhang/Möller 6

The ideal pinhole camera Single ray of light gets through small pinhole Film placed on side of box opposite to pinhole Projection Machiraju/Zhang/Möller 7

The pinhole camera Angle of view (always fixed) Depth of field (DOF): infinite every point within the field of view is in focus (the image of a point is a point) Problem: just a single ray of light & fixed view angle Solution: pinhole lens, DOF no longer infinite Machiraju/Zhang/Möller 8

http://en.wikipedia.org/wiki/file:dof-shallowdepthoffield.jpg Machiraju/Zhang/Möller 9

The synthetic camera model Image formed in front of the camera Center of projection (COP): center of the lens (eye) Machiraju/Zhang/Möller 10

Types of projections Choose an appropriate type of projection (not necessarily perspective) Establishes the view: direction and orientation Machiraju/Zhang/Möller 11

3D viewing with a computer Clips scene with respect to a view volume Usually finite to avoid extraneous objects Projects the scene onto a projection plane In a similar way as for the synthetic camera model Everything in view volume is in focus Depth-of-field (blurring) effects may be generated Machiraju/Zhang/Möller 12

Where are we at? Clip against 3D view volume Project onto projection plane Machiraju/Zhang/Möller 13

Objectives What kind of camera we use? (pinhole) What projections make sense Orthographic Perspective The viewing pipeline Viewing in WebGL Shadows Machiraju/Zhang/Möller 14

Projection: 3D 2D We study planar geometric projections: projecting onto a flat 2D surface project using straight lines Projection rays, called projectors, are sent through each point in the scene from the centre of projection (COP) - our pinhole Intersection between projectors and projection plane form the projection Machiraju/Zhang/Möller 15

Perspective and parallel projections Perspective: - Determined by COP Parallel: COP at infinity By direction of projectors (DOP) Machiraju/Zhang/Möller 16

COP in homogeneous coordinates Perspective projection: COP is a finite point: (x, y, z, 1) Parallel projection Direction of projection is a vector: (x, y, z, 1) (x, y, z, 1) = (a, b, c, 0) Points at infinity and directions correspond in a natural way Machiraju/Zhang/Möller 17

Perspective vs. parallel Perspective projection: Realistic, mimicking our human visual system Foreshortening: size of perspective projection of object varies inversely with the distance of that object from the center of projection Distances, angles, parallel lines are not preserved Parallel projection: Less realistic but can be used for measurements Foreshortening uniform, i.e., not related to distance Parallel lines are preserved (length preserving?) Machiraju/Zhang/Möller 18

Machiraju/Zhang/Möller 19

Taxonomy of projections Angle between projectors and projection plane? Number of principal axes cut by projection plane Machiraju/Zhang/Möller 20

Parallel projections Used in engineering mostly, e.g., architecture Allow measurements Different uniform foreshortenings are possible, i.e., not related to distance to projection plane Parallel lines remain parallel Angles are preserved only on faces which are parallel to the projection plane same with perspective projection Machiraju/Zhang/Möller 21

Orthographic (parallel) projections Projectors are normal to the projection plane Commonly front, top (plan) and side elevations: projection plane perpendicular to z, y, and x axis Matrix representation (looking towards negative z along the z axis; projection plane at z = 0): Machiraju/Zhang/Möller 22

Orthographic projections Axonometric projection Projection plane not normal to any principal axis E.g., can see more faces of an axis-aligned cube Machiraju/Zhang/Möller 23

Orthographic projections Foreshortening: three scale factors, one each for x, y, and z axis Axonometric projection example: Machiraju/Zhang/Möller 24

Orthographic projection Axonometric projection Isometric Projection-plane normal makes same angle with each principal axis There are just eight normal directions of this kind All three principal axes are equally foreshortened, good for getting measurements Principal axes make same angle in projection plane Alternative: dimetric & trimetric (general case) Machiraju/Zhang/Möller 25

Parallel Projection (4) Axonometric Projection - Isometric Angles between the projection of the axes are equal i.e. 120º Alternative - dimetric & trimetric Machiraju/Zhang/Möller 26

Types of Axonometric Projections Machiraju/Zhang/Möller 27

Oblique (parallel) projections Projectors are not normal to projection plane Most drawings in the text use oblique projection Machiraju/Zhang/Möller 28

Oblique projections Two angles are of interest: Angle α between the projector and projection plane The angle φ in the projection plane Derive the projection matrix Machiraju/Zhang/Möller 29

Derivation of oblique projections Machiraju/Zhang/Möller 30

Common oblique projections Cavalier projections Angle α = 45 degrees Preserves the length of a line segment perpendicular to the projection plane Angle φ is typically 30 or 45 degrees Cabinet projections Angle α = 63.7 degrees or arctan(2) Halves the length of a line segment perpendicular to the projection plane more realistic than cavalier Machiraju/Zhang/Möller 31

Projections, continued Machiraju/Zhang/Möller 32

Perspective projections Mimics our human visual system or a camera Project in front of the center of projection Objects of equal size at different distances from the viewer will be projected at different sizes: nearer objects will appear bigger Machiraju/Zhang/Möller 33

Types of perspective projections Any set of parallel lines that are not parallel to the projection plane converges to a vanishing point, which corresponds to point at infinity in 3D One-, two-, three-point perspective views are based on how many principal axes are cut by projection plane Machiraju/Zhang/Möller 34

Vanishing points Machiraju/Zhang/Möller 35

Simple perspective projection COP at z = 0 Projection plane at z = d Transformation is not invertible or affine. Derive the projection matrix. Machiraju/Zhang/Möller 36

Simple perspective projection How to get a perspective projection matrix? Homogeneous coordinates come to the rescue Machiraju/Zhang/Möller 37

Summary of simple projections COP: origin of the coordinate system Look into positive z direction Projection plane perpendicular to z axis Machiraju/Zhang/Möller 38

Objectives What kind of camera we use? (pinhole) What projections make sense Orthographic Perspective The viewing pipeline Viewing in WebGL Shadows Machiraju/Zhang/Möller 39

General viewing and projections With scene specified in world coordinate system Position and orientation of camera Projection: perspective or parallel Clip objects against a view volume which one? Normalize the view volume (easier to do this way) The rest is orthographic projection Machiraju/Zhang/Möller 40

Perspective Projections Need to describe the viewing VRP - view reference point VRP Machiraju/Zhang/Möller 41

Perspective Projections Need to describe the viewing VRP - view reference point VN - view normal VN VRP Machiraju/Zhang/Möller 42

Perspective Projections Need to describe the viewing VRP - view reference point VN - view normal VUP - up vector VUP VN v VRP u Machiraju/Zhang/Möller 43

Perspective Projections Need to describe the viewing VRP - view reference point VN - view normal VUP - up vector COP - centre of projection VUP VN v COP VRP u Machiraju/Zhang/Möller 44

Clipping Projection defines a view volume add front and back clipping plane make view volume finite why is this useful for a perspective projection? Machiraju/Zhang/Möller 45

Clipping (2) How should we clip a scene against the view volume? We could clip against the actual coordinates, but is there an easier way? Machiraju/Zhang/Möller 46

Clipping (3) Canonical view volume Parallel: x = -1, x = 1, y = -1, y = 1, z = 0, z = -1 Perspective: x = z, x = -z, y = z, y = -z, z = -z_min, z = -1 Machiraju/Zhang/Möller 47

Viewing Process Machiraju/Zhang/Möller 48

Normalization - Parallel translate the VRP to the origin Machiraju/Zhang/Möller 49

Normalization - Parallel (2) rotate the view reference coordinates such that the VPN becomes the z axis, u becomes the x axis and v becomes the y axis Machiraju/Zhang/Möller 50

Normalization - Parallel (3) shear so that the direction of projection is parallel to the z axis Machiraju/Zhang/Möller 51

Normalization - Parallel (4) translate and scale into the canonical view volume Machiraju/Zhang/Möller 52

Normalization - Parallel (5) translates the VRP to the origin rotate the view reference coordinates such that the VPN becomes the z axis, u becomes the x axis and v becomes the y axis shear so that the direction of projection is parallel to the z axis translate and scale into the canonical view volume Machiraju/Zhang/Möller 53

Normalization - Parallel (6) Projection matrix: M = S T SH R T Machiraju/Zhang/Möller 54

Normalization - Perspective translates the VRP to the origin Machiraju/Zhang/Möller 55

Normalization - Perspective (2) rotate the view reference coordinates such that the VPN becomes the z axis, u becomes the x axis and v becomes the y axis. Machiraju/Zhang/Möller 56

Normalization - Perspective (3) Translate so that the center of projection is at the origin Machiraju/Zhang/Möller 57

Normalization - Perspective (4) shear so that the centre line of the view volume becomes the z axis Machiraju/Zhang/Möller 58

Normalization - Perspective (5) scale into the canonical view volume Machiraju/Zhang/Möller 59

Normalization - Perspective (6) translates the VRP to the origin rotate the view reference coordinates such that the VPN becomes the z axis, u becomes the x axis and v becomes the y axis. translate so that the center of projection is at the origin shear so that the centre line of the view volume becomes the z axis scale into the canonical view volume Machiraju/Zhang/Möller 60

Normalization - Perspective (7) Projection matrix (perspective): M = P pers S SH T R T Projection matrix (parallel): M = P parall S SH R T Machiraju/Zhang/Möller 61

Objectives What kind of camera we use? (pinhole) What projections make sense Orthographic Perspective The viewing pipeline Viewing in WebGL Shadows Machiraju/Zhang/Möller 62

Computer Viewing There are three aspects of the viewing process, all of which are implemented in a pipeline, Positioning the camera Setting the model-view matrix Selecting a lens Setting the projection matrix Clipping Setting the view volume Angel/Shreiner/Möller 63

The WebGL Camera In WebGL, 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 z direction WebGL 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 Angel/Shreiner/Möller 64

Default Projection Default projection is orthogonal 2 clipped out z=0 Angel/Shreiner/Möller 65

Moving the Camera Frame If we want to visualize an object with both positive and negative z values we can either Move the camera in the positive z direction Translate the camera frame Move the objects in the negative z direction Translate the world frame Both of these views are equivalent and are determined by the model-view matrix Want a translation Translate(0.0,0.0,-d); d > 0 Angel/Shreiner/Möller 66

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 Angel/Shreiner/Möller 67

The LookAt Function The GLU library contained the function glulookat to form the required modelview matrix through a simple interface Note the need for setting an up direction Replaced by LookAt() in mat.h Can concatenate with modeling transformations Example: isometric view of cube aligned with axes mat4 mv = LookAt(vec4 eye, vec4 at, vec4 up); Angel/Shreiner/Möller 68

glulookat LookAt(eye, at, up) Angel/Shreiner/Möller 69

Other Viewing APIs The LookAt function is only one possible API for positioning the camera Others include View reference point, view plane normal, view up (PHIGS, GKS-3D) Yaw, pitch, roll Elevation, azimuth, twist Direction angles Angel/Shreiner/Möller 70

WebGL Orthogonal Viewing Ortho(left,right,bottom,top,near,far) near and far measured from camera Angel/Shreiner/Möller 71

WebGL Perspective Frustum(left,right,bottom,top,near,far) Angel/Shreiner/Möller 72

Using Field of View With Frustum it is often difficult to get the desired view Perpective(fovy,aspect,near,far) often provides a better interface front plane aspect = w/h Angel/Shreiner/Möller 73

Objectives What kind of camera we use? (pinhole) What projections make sense Orthographic Perspective The viewing pipeline Viewing in WebGL Shadows Machiraju/Zhang/Möller 74

Application of projection: shadows Essential component for realistic rendering Naturally use projections Can produce hard shadows Only handles shadows on a plane To shadow on a polygonal face, need clipping More advanced shadow algorithms exist, e.g., soft shadows and penumbra (not easy to do) Blinn 74 Machiraju/Zhang/Möller 75

Shadow via projection A shadow polygon is obtained through projection where the center of projection is a light source Machiraju/Zhang/Möller 76

Shadow polygon: parallel projection Project shadow on z = 0 Light at (directional light) Derive the projection matrix (xp, yp, zp) (xs, ys, 0) Machiraju/Zhang/Möller 77

Shadows: parallel projection Light at infinity: hence projection: Now draw the object on the ground plane Machiraju/Zhang/Möller 78

Shadows: perspective projection Project on plane z = 0 Point light source Derive the matrix Machiraju/Zhang/Möller 79

Local Light: Shadows: perspective projection projection matrix: Machiraju/Zhang/Möller 80

Shadow of a teapot Machiraju/Zhang/Möller 81

Shadows requires no extra memory easily handles any number of light sources only shadows onto ground plane cannot handle objects which shadow other complex objects every polygon is rendered N+1 times, where N is number of light sources Machiraju/Zhang/Möller 82