Computer Graphics Camera Projection / Picking CO2409 Week 8 - Optional Advanced Material Not on Exam.

Slides:



Advertisements
Similar presentations
Computer Graphics1 Geometry Area of polygons & Volume Of Polygonal surfaces.
Advertisements

Exploration of bump, parallax, relief and displacement mapping
Graphics Pipeline.
Ray Tracing Part I References /rtrace0.htm A. Watt & M. Watt. Advanced Animation & Rendering.
Projection Matrix Tricks Eric Lengyel Outline  Projection Matrix Internals  Infinite Projection Matrix  Depth Modification  Oblique Near Clipping.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
CS485/685 Computer Vision Prof. George Bebis
COMP322/S2000/L221 Relationship between part, camera, and robot (cont’d) the inverse perspective transformation which is dependent on the focal length.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
COMP 175: Computer Graphics March 24, 2015
Viewing and Projections
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
01/28/05© 2005 University of Wisconsin Last Time Improving Monte Carlo Efficiency.
Sky Rendering The actual physics is very complicated and costly to calculate. Several cheap approaches for very distant skies: –Constant backdrop –Skybox.
Week 2 - Wednesday CS361.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Geometric Models & Camera Calibration
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
CS-378: Game Technology Lecture #2.1: Projection Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS The Geometry Pipeline.
Foundations of Computer Graphics (Fall 2012) CS 184, Lectures 13,14: Reviews Transforms, OpenGL
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
CS 4731: Computer Graphics Lecture 13: Projection Emmanuel Agu.
SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
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.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
Mark Nelson 3d projections Fall 2013
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Three-Dimensional Viewing
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
12-Perspective Depth Assoc.Dr. Ahmet Zafer Şenalp Mechanical Engineering Department Gebze Technical.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Chapter III Rasterization
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Computer Graphics Matrices
Honours Graphics 2008 Session 2. Today’s focus Vectors, matrices and associated math Transformations and concatenation 3D space.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
OpenGL and You I Cast, Therefore I Am. Ray Casting Idea is simple, implementation takes some work –Cast rays as if you were the camera –Determine intersection.
Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
3D GRAPHICS RENDERING PIPELINE CS / TECHNICAL BACKGROUND PAGE 11.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Midterm Review Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Introduction to Computer Graphics
- Introduction - Graphics Pipeline
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
Intro to 3D Graphics.
3D Computer Graphics (3080/GV10) Week 5-6 Tutorial 3
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
CS451Real-time Rendering Pipeline
Computer Graphics Lecture 20
Computer Graphics (Spring 2003)
Projection in 3-D Glenn G. Chappell
컴퓨터 그래픽스를 위한 기하학적 기초 (Line Geometry for Computer Graphics)
Presentation transcript:

Computer Graphics Camera Projection / Picking CO2409 Week 8 - Optional Advanced Material Not on Exam

Contents 1.World / View Matrices Recap 2.Projection Maths 3.Pixel from World-Space Vertex 4.World Space Ray from Pixel These notes are presented as additional material and are not examinable

Model Space An model’s mesh is defined in its own local coordinate system - model space Each model is positioned with a matrix –Transforming it from model space into world space This matrix is called the World Matrix

World to Camera Space Next consider how the models are positioned and oriented relative to the camera Convert the models from world space into camera space –The scene as viewed from camera’s position This transformation is done with the view matrix

Camera to Viewport Space Finally project the camera space models into 2D The 3D vertices are projected to camera position Assume the viewport is an actual rectangle in the scene Calculate where the rays hit the viewport = 2D geometry This is done with the projection matrix

Projection Details Cameras have two settings: –Field of View (FOV) –Viewport distance (D) Viewport distance is same as the near clipping plane –Where geometry “slices” through the viewport FOV works as a wide angle or zoom lens –FOV can be different for width and height – FOV X & FOV Y

Projecting a Vertex Consider the projection of a single 3D vertex to 2D Want 2D coordinates (X V, Y V ) –Y V not shown in diagram Calculate using similar triangles: X / Z = X V / D, so X V = D * X / Z In a similar way, Y V = D * Y / Z This is the perspective divide Now have 2D coords, but still in camera space units –Need to convert to pixels

Converting to Pixels Calculate the actual viewport dimensions (camera space): tan(FOV X / 2) = (W V / 2) / D so W V = 2 * D * tan(FOV X / 2) similarly, H V = 2 * D * tan(FOV Y / 2) Then calculate: X N = 2 * X V / W V Y N = 2 * Y V / H V This 2D coordinate(X N, Y N ) is in the range –1 to 1 –Ready to convert to pixel position

Converting to Pixels If the viewport width & height (in pixels) are W P and H P : then X P = (X N + 1) W P / 2 and Y P = (1 - Y N ) H P / 2 –The second formula flips the Y axis (viewport Y is down) (X P, Y P ) are the coordinates of the final pixel we want

Picking Sometimes we need to manually perform the projection process: –To find the pixel for a particular 3D point –E.g. To draw text/sprites in same place as a 3D model Or perform the process in reverse: –Each 2D pixel corresponds to a ray in 3D space (refer to the projection diagram) –Finding and working with this ray is called picking –E.g. to find the 3D object under the mouse The algorithms for both follow – they are derived from the previous slides

Pixel from World-Space Vertex Start with world space vertex P Transform this vertex by combined view / projection matrix to give Q If Q.z < 0 then the vertex is behind us, discard Otherwise do perspective divide: Q.x /= Q.z and Q.y /= Q.z Finally, scale to pixel coordinates X,Y: X = (Q.x + 1) * (ViewportWidth / 2) Y = (1 - Q.y) * (ViewportHeight / 2) Use to draw text/sprites in same place as 3D entity

World-Space Ray From Pixel 1 Initial pixel (X,Y), first convert to point Q in the range -1 -> 1: Q.x = (2 * X / ViewportWidth) - 1 Q.y = 1 – (2 * Y / ViewportHeight) Set Q.z = D (viewport / near clip distance) –The result vertex will be exactly on the clip plane Calculate viewport size in camera space: W V = 2 * D * tan(FOV X / 2) H V = 2 * D * tan(FOV Y / 2) If FOV Y not available: H V = W V * ViewportHeight / ViewportWidth

World-Space Ray From Pixel 2 Convert Q into camera space: Q.x *= W V / 2 Q.y *= H V / 2 Finally transform by the inverse of the view matrix to get a point in world space Then cast a ray from camera to this point –Use this 3D ray to detect the entity at the pixel