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

Similar documents
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

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

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

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

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

Three-Dimensional Viewing Hearn & Baker Chapter 7

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE328 Fundamentals of Computer Graphics

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

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

Lecture 4. Viewing, Projection and Viewport Transformations

Overview. By end of the week:

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

INTRODUCTION TO COMPUTER GRAPHICS. cs123. It looks like a matrix Sort of. Viewing III. Projection in Practice 1 / 52

Game Architecture. 2/19/16: Rasterization

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

Geometry: Outline. Projections. Orthographic Perspective

COMP30019 Graphics and Interaction Perspective Geometry

Viewing with Computers (OpenGL)

Shadows in the graphics pipeline

Models and The Viewing Pipeline. Jian Huang CS456

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

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

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

Chapter 5. Projections and Rendering

DD2423 Image Analysis and Computer Vision IMAGE FORMATION. Computational Vision and Active Perception School of Computer Science and Communication

3D Viewing. CS 4620 Lecture 8

Reading on the Accumulation Buffer: Motion Blur, Anti-Aliasing, and Depth of Field

CS 4204 Computer Graphics

CS 325 Computer Graphics

Chapter 8 Three-Dimensional Viewing Operations

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

Raycasting. Chapter Raycasting foundations. When you look at an object, like the ball in the picture to the left, what do

Prof. Feng Liu. Fall /19/2016

(Refer Slide Time: 00:01:26)

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

Drawing in 3D (viewing, projection, and the rest of the pipeline)

ECE-161C Cameras. Nuno Vasconcelos ECE Department, UCSD

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

Computer Graphics 7: Viewing in 3-D

Introduction to 3D Concepts

CHAPTER 3. Single-view Geometry. 1. Consequences of Projection

CSE452 Computer Graphics

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

COMP30019 Graphics and Interaction Perspective & Polygonal Geometry

Rigid Body Motion and Image Formation. Jana Kosecka, CS 482

CS230 : Computer Graphics Lecture 6: Viewing Transformations. Tamar Shinar Computer Science & Engineering UC Riverside

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Computer Graphics. Chapter 1 (Related to Introduction to Computer Graphics Using Java 2D and 3D)

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

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)

Evening s Goals. Mathematical Transformations. Discuss the mathematical transformations that are utilized for computer graphics

Drawing in 3D (viewing, projection, and the rest of the pipeline)

The Graphics Pipeline and OpenGL I: Transformations!

Viewing. Reading: Angel Ch.5

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

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Homogeneous Coordinates. Lecture18: Camera Models. Representation of Line and Point in 2D. Cross Product. Overall scaling is NOT important.

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

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

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

CS 418: Interactive Computer Graphics. Projection

1 OpenGL - column vectors (column-major ordering)

CS 428: Fall Introduction to. Viewing and projective transformations. Andrew Nealen, Rutgers, /23/2009 1

COSC579: Scene Geometry. Jeremy Bolton, PhD Assistant Teaching Professor

CIS 580, Machine Perception, Spring 2016 Homework 2 Due: :59AM

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

Advanced Computer Graphics (CS & SE )

Rasterization Overview

AP Physics: Curved Mirrors and Lenses

CS451Real-time Rendering Pipeline

CS4670: Computer Vision

COMP3421. Introduction to 3D Graphics

Chapter 12 Notes: Optics

Computer Vision Project-1

Projection Lecture Series

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

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

Perspective projection. A. Mantegna, Martyrdom of St. Christopher, c. 1450

Introduction to Homogeneous coordinates

Camera model and multiple view geometry

CSE 252B: Computer Vision II

MAN-522: COMPUTER VISION SET-2 Projections and Camera Calibration

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

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

SUMMARY. CS380: Introduction to Computer Graphics Projection Chapter 10. Min H. Kim KAIST School of Computing 18/04/12. Smooth Interpolation

Transforms 3: Projection Christian Miller CS Fall 2011

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Perspective Mappings. Contents

5.8.3 Oblique Projections

GEOMETRIC TRANSFORMATIONS AND VIEWING

Introduction to Computer Graphics 4. Viewing in 3D

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

How to print a Hypercube

COMP3421. Introduction to 3D Graphics

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Transcription:

Viewing Part II (The Synthetic Camera) Brownie camera courtesy of http://www.geh.org/fm/brownie2/htmlsrc/me13000034_ful.html 1/31

The Camera and the Scene } What does a camera do? } Takes in a 3D scene } Places (i.e., projects) the scene onto a 2D medium such as a roll of film or a digital pixel array } The synthetic camera is a programmer s model for specifying how a 3D scene is projected onto the screen Contour map courtesy of http://www.princeton.edu/~oa/manual/mapcompass.shtml 2/31

3D Viewing: The Synthetic Camera } General synthetic camera: each package has its own but they are all (nearly) equivalent, with the following parameters/degrees of freedom: } Camera position } Orientation } Field of view (angle of view, e.g., wide, narrow/telephoto, normal...) } Depth of field/focal distance (near distance, far distance) } Tilt of view/ film plane (if not perpendicular to viewing direction, produces oblique projections) } Perspective or parallel projection (camera in scene with objects or infinite distance away, resp.) } CS123 uses a simpler, slightly less powerful model than the one used in the book } Omit tilt of view/film plane (i.e., no oblique projections), focal distance (blurring) 3/31

Cameras in Rendering Process } We will detail coordinate systems for camera, i.e., view volume specification, projecting onto film plane, and transforming into viewport } To refresh our idea of a view volume, recall the pinhole camera/camera Obscura 4/31

Pinhole Model for Perspective Projection geometric optics } Pinhole camera optically projects a volume of space (the scene) in front of it. Rays of light reflect off objects and those visible from the camera s Point of View (i.e., those (parts of objects) that lie inside its view volume and are visible from the PoV) converge to the pinhole and then project the scene on a film plane or wall behind the pinhole. The scene will be inverted. Pinhole Camera } Pinhole is our camera position Object ( center of projection ), and view volume is what we see } In our camera, projectors intersect a plane, image Pinhole usually in between scene and pinhole, projecting the scene onto that plane (no inversion) Synthetic Camera } Lastly, in our camera, projection Object is mapped to some form of viewing medium Pinhole (e.g., screen) } For practical rendering, add front and back clipping planes Image 5/31

View Volumes (focus of today s lecture) } A view volume contains everything the camera sees } Conical Approximates what eyes see, expensive math when clipping objects against cone s surface (simultaneous linear (for projector) and quadratics (for cone) equations) } Frustum Can approximate conical view volume with rectangular pyramid } Simultaneous linear equations for easy clipping of objects against sides (stay tuned for clipping lecture) } Parallel Doesn t simulate eye or camera (e.g., for orthographic projections). eye synthetic camera Conical perspective view volume (eye s is much wider, e.g., 180 degrees, esp. for motion!) Frustum: approximation to conical view volume View volume (Parallel view) 6/31

View Volumes and Projectors } Given our view volume, need to start thinking about how to project scene contained in volume to film plane } Projectors: Lines that essentially map points in scene to points on film plane } Parallel Volumes: Parallel projectors, no matter how far away an object is, as long as it is in the view volume it will appear as same size (using our simple camera model, these projectors are also parallel to the look vector, the direction in which the camera is looking) } Perspective Volumes: Projectors emanate from eye point = center of projection, inverse of rays of light converging to your eye (see Dürer woodcut) Parallel volume projectors Perspective volume projectors 7/31

The Film Plane } Film plane is in world space 3D scene is projected onto a rectangle (the film) on that plane using some projection transformation and from there onto the viewport on screen via window -> viewport mapping (Transformations lecture) } Film for our camera model will be perpendicular to and centered around the camera s look vector and will match dimensions of our view volume Look Vector Look Vector Film Plane Film Plane } Actual location of film plane along look vector doesn t matter as long as it is between eye / center of projection and scene (identical projection for parallel, proportions preserved for perspective) 8/31

The Viewport } Viewport is the rectangular area of screen where a scene is rendered } Corresponds to Window Manager s client area (the non-chrome part of the window) } Note: window (aka Imaging Rectangle) in computer graphics means a 2D clip rectangle on a 2D world coordinate drawing or 2D projection of the 3D scene on the film plane, and viewport is a 2D integer coordinate region of screen space to which clipped window contents are mapped, typically either the whole screen or the client area of a WM s window } Pixel coordinates for viewport are most commonly referred to using a (u,v) coordinate system } Unfortunately, that (u,v) nomenclature is also used for texture coordinates -- context disambiguates Footnote: The graphics use of window predates Window Manager s use. We are only concerned with viewports that are either whole screen or a client area of a Window Manager s window. 9/31

Constructing the View Volume (1/2) } We need to know six parameters about our synthetic camera model in order to take a picture using our perspective view frustum: 1) Position of the camera it is the center of projection, behind the film plane 2) Look vector specifying direction camera is pointing. Note: look is not explicitly named or specified in OpenGL, but is derived using eye and center camera parameters (as in glm::lookat()), which are the camera s position and the point it s looking at, respectively 3)Camera s orientation determined by look and angle by which the camera is rotated about that vector, i.e., the direction of the up vector in World Coordinate System (WCS). It will be specified by an Up vector that needn t be perpendicular to Look, i.e., lie in the plane defined by Look as its normal (S13) 10/31

Constructing the View Volume (2/2) 3) Aspect ratio of the electronic film : ratio of width to height 4) Height angle: determines how much of the scene we will fit into our view volume; larger height angles fit more of the scene into the view volume (width angle determined by height angle and aspect ratio) } the greater the angle, the greater the amount of perspective distortion 6) Front and back clipping planes: limit extent of camera s view by rendering (parts of) objects lying between them and clipping everything outside of them avoids problem of having far-away details map onto same pixel, another kind of alisiasing, i.e.,, sampling error 6) And why spend resources computing a rendering of details too small to resolve?!? Front clipping plane Width angle Height angle Back clipping plane (Optional) Focal length: objects at focal length are sharp, objects closer/farther are blurry 11/31

1) Position (1/1) } Where is the camera located with respect to the origin, in the world coordinate system? } For our camera in 3D space we use a right-handed coordinate system } Open your right hand, align your palm and thumb with the +x axis, point index finger up along the +y axis, and point your middle finger towards the +z axis } If you re looking at a screen, the z axis will be positive coming towards you Courtesy of http://viz.aset.psu.edu/gho/sem_notes/3d_fundamentals/gifs/left_right_hand.gif 12/31

2 & 3) Orientation: Look and Up vectors (1/2) } Orientation is specified by a direction to look in (equivalently, a point in 3D space to look at) and a non-collinear vector Up from which we derive the rotation of the camera about Look } Note: glm::lookat() sets up our viewing space by taking three values: vectors of an eye position, a point to look at, and an arbitrary non-colinfear Up vector } In diagram below, camera is positioned at origin of WCS, but that isn t typical y x -z Up vector camera Position Look vector z point to look at (x, y, z ) 13/31

2 & 3) Orientation: Look and Up vectors (2/2) } Look Vector } Direction the camera is pointing } Three degrees of freedom; can be any vector in 3- space } Up Vector } Determines how camera is rotated about look } For example, holding camera in portrait or landscape mode } up must not be co-linear to look but it doesn t have to be perpendicular actual orientation will be defined by the unit vector v perpendicular to look in the plane defined by look and up } easier to spec an arbitrary (non-collinear) vector than one perpendicular to look Up vector Projection of Up vector Position Look vector Any of v, v 1, v 2, v 3 could be the Up vector, with corresponding projections, which then must be normalized Andries van Dam 10/10/2017 14/31

The Camera Coordinate Space (1/2) } The equivalent of x, y and z WCS axes in camera space are unit vectors u, v, w ( u, v, not to be confused with texture axes, w is the homogenous coordinate,) } Also a right handed coordinate system } w is a unit vector in the opposite direction of look (i.e. look lies along the -w axis) } v is the component of the up vector perpendicular to look, normalized to unit length } u is the unit vector perpendicular to both v and w 15/31

The Camera Coordinate Space (2/2) } Three common rotation transformations that use camera space axes, with camera in same position } Roll: } Rotating your camera around w } Yaw: } Rotating your camera around v } Pitch: } Rotating your camera around u } To do these, send camera to WCS origin and rotate to align its axes with the WCS axes, then use our rotation matrices to perform specified transformations, then un-rotate, and un-translate Roll, Yaw, Pitch image courtesy of http://3.bp.blogspot.com/_dbbuwcxzzce/tquhlbalxji/aaaaaaaaaao/ov8d5b4yij Q/s1600/pry.png 16/31

Aside: The Camera as a Model } There are different ways we can model a camera } In the generalized model we have a camera and a scene where both the camera and objects in the scene are free to be transformed independently } In a more restricted model we have a camera that remains fixed in one position and orientation } To transform the camera we actually apply inverse transformation to objects in scene } This is the model OpenGL uses; note however that this concept is abstracted away from the programmer with glm::lookat(), in which a viewing matrix is created from up, camera position, and point it s looking at Field of view in OpenGL can be thought of as the view from the camera looking down z axis at the origin Translate camera to the right Object moves to left to simulate a camera moving to right 17/31

4) Aspect Ratio (1/1) } Analogous to dimensions of film in camera } Ratio of width to height of viewing window } Viewport s aspect ratio usually defined by screen being used, or by common ratio s, e.g., 16:9 } Square viewing window has a ratio of 1:1 } NTSC TV is 4:3, HDTV is 16:9 or 16:10 } Aspect ratio of viewing window defines dimensions of the image that gets projected to film plane, after which it is mapped to viewport } Typically it s a good idea to have same aspect ratio for both viewing window and viewport, to avoid distortions/stretching } Note: the black strips on the 16:9 image is a technique called letter boxing. It preserves the aspect ratio of the image when the screen can t accommodate it. This is in contrast to simply stretching the image which distorts the images (most notably, faces) 4:3 1:1 Courtesy of http://www3.flickr.com/photos/z erogrizzly/4037144257/ Courtesy of http://en.wikipedia.org/ wiki/file:aspect_ratio_4_ 3_example.jpg Courtesy of http://forum.vi deohelp.com/t hreads/23653 6-720-vs-704 18/31 16:9

5) View Angle (1/2) } Determines amount of perspective distortion in picture, from none (parallel projection) to a lot (wide-angle lens) } In a frustum, two viewing angles: width and height angles } Usually width angle is specified using height angle and aspect ratio } Choosing view angle is analogous to photographer choosing a specific type of lens (e.g., a wide-angle or telephoto lens) Width angle Height angle 19/31

5) Viewing Angle (2/2) } Telephoto lenses made for distance shots often have a nearly parallel viewing angle and cause little perspective distortion, though they foreshorten depth } Wide-angle lenses cause a lot of perspective distortion Resulting picture 20/31

6) Near and Far Clipping Planes (1/3) } With what we have so far we can define four rays extending to infinity. These define the edges of our current view volume. } Now we need to bound front and back to make a finite volume can do this using the near and far clipping planes, defined by distances along look (also note that look and clipping planes are perpendicular) } This volume (the frustum) defines what we can see in the scene } Objects outside are discarded } Objects intersecting faces of the volume are clipped 21/31

6) Near and Far Clipping Planes (2/3) } Reasons for front (near) clipping plane: } Usually don t want to draw things too close to camera } Would block view of rest of scene } Objects would be quite distorted } Don t want to draw things behind camera } Wouldn t expect to see things behind camera } In the case of perspective camera, if we were to draw things behind camera, they would appear upside-down and inside-out because of perspective transformation 22/31

6) Near and Far Clipping Planes (3/3) } Reasons for back (far) clipping plane: } Don t want to draw objects too far away from camera } Distant objects may appear too small to be visually significant, but still take long time to render; different parts of an object may map onto same pixel (sampling error) } By discarding them we lose a small amount of detail but reclaim a lot of rendering time } Helps to declutter a scene } These planes need to be properly placed, not too close to the camera, not too far (mathematical justification in Viewing III) 23/31

Games and Clipping Planes (1/2) } Sometimes in a game you can position the camera in the right spot that the front of an object gets clipped, letting you see inside of it. } Video games use various techniques to avoid this glitch. One technique is to have objects that are very close to the near clip plane fade out before they get cut off, as can be seen below Fence is opaque Fence is partially transparent Screenshots from the game, Okami } This technique gives a clean look while solving the near clipping problem (the wooden fence fades out as the camera gets too close to it, allowing you to see the wolf behind it). 24/31

Games and Clipping Planes (2/2) } Ever played a video game and all of a sudden some object pops up in the background (e.g., a tree in a racing game)? That s an object coming inside the far clip plane. } Old solution: add fog in the distance. A classic example, Turok: Dinosaur Hunter } Modern solution (e.g. Stone Giant), dynamic level of detail: mesh detail increases when you get closer to it in the game Courtesy of http://www.ato micgamer.com/s creenshots/gam e-1552/10965-800.jpg Courtesy of http://image s.tweaktown. com/news/1 /4/14981_07.jpg } Thanks to fast hardware and level of detail algorithms, we can push the far plane back now and fog is much less prevalent 25/31

Focal Length } Some camera models take a focal length } Focal length is a measure of ideal focusing range; approximates behavior of real camera lens } Objects at distance equal to focal length from camera are rendered in focus; objects closer or farther away than focal length get blurred } Focal length used in conjunction with clipping planes } Only objects within view volume are rendered, whether blurred or not. Objects outside of view volume still get discarded Courtesy of http://3d-pic.3ddl.net/uploads/allimg/110617/13-11061g05j20-l.jpg 26/31

The Parallel View Volume (1/2) } Up until now the specifications for a perspective view volume } Also need parallel view volumes (e.g., for measurement in CAD, architecture) } What do we need to know this time? } Everything we wanted for a perspective view volume except for width and height angles, replaced by just a width and height (also the width and height of our film on our film plane) } A parallel view volume is a parallelepiped/cuboid (all opposite edges parallel) Rectangular parallelepiped Andries van Dam 10/610/10/2017 27/31

The Parallel View Volume (2/2) } Objects appear same size no matter how far away since projectors are all parallel: uniform foreshortening based on angle of film plane to projectors, not depth-dependent perspective (non-uniform) foreshortening } Benefits of parallel view volume } Easier clipping because of simpler plane equations } Easier depth comparison for Visible Surface Determination (solving the obscuration problem) } Easy to project a 3D scene to 2D projection/film plane because no perspective foreshortening Andries van Dam 10/6/10/10/2017 28/31

Capabilities of the Generalized Camera (1/2) } In a more generalized camera the viewing window doesn t have to be centered about the position of the camera and look (look direction is d in diagram) } Nor does it have to be perpendicular to look } This allows us to use a more flexible view as well as enable the use of more view types } Using an uncentered film we can essentially choose which part of our original perspective projection to view 29/31

Capabilities of the Generalized Camera (2/2) } We can do oblique projections (cavalier, cabinet parallel; perspective oblique) where look/projectors and film plane aren t perpendicular: Non-oblique view volume: look is perpendicular to film plane } Our model of a camera is not all-encompassing } There are some capabilities that we have omitted for the sake of simplicity, e.g., focus, oblique projections } Our film is centered around the camera position and always perpendicular to look Oblique view volume: view camera: look vector (tilt of lens) is at an angle to the film plane, which remains parallel to face of interest, preserving its proportions 30/31

Next Task } We have now seen how to construct a perspective and parallel view volume and we mentioned how a scene is projected in these volumes onto the film plane } But these view volumes can be located anywhere and oriented in any way depending on how our camera is specified } How can we transition from knowing what the view volume looks like to actually rendering an image to the screen? } Next, describe canonical view volume and how we can use it for rendering 31/31