CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Similar documents
CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

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

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

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Rasterization Overview

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

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

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Rendering Objects. Need to transform all geometry then

Lecture 4. Viewing, Projection and Viewport Transformations

Game Architecture. 2/19/16: Rasterization

Prof. Feng Liu. Fall /19/2016

Geometry: Outline. Projections. Orthographic Perspective

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

CSE328 Fundamentals of Computer Graphics

CSE 167: Introduction to Computer Graphics Lecture #3: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CS451Real-time Rendering Pipeline

The Graphics Pipeline and OpenGL I: Transformations!

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

CSE 167: Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Overview. By end of the week:

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

CSE 167: Introduction to Computer Graphics Lecture #3: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

To Do. Motivation. Demo (Projection Tutorial) What we ve seen so far. Computer Graphics. Summary: The Whole Viewing Pipeline

CS 4731/543: Computer Graphics Lecture 5 (Part I): Projection. Emmanuel Agu

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

The Graphics Pipeline and OpenGL I: Transformations!

Viewing COMPSCI 464. Image Credits: Encarta and

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Computer Graphics. Chapter 10 Three-Dimensional Viewing

CSE 167: Introduction to Computer Graphics Lecture #7: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2015

CS 591B Lecture 9: The OpenGL Rendering Pipeline

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

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2014

To Do. Demo (Projection Tutorial) Motivation. What we ve seen so far. Outline. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 5: Viewing

Transforms 3: Projection Christian Miller CS Fall 2011

Culling. Computer Graphics CSE 167 Lecture 12

CS 543: Computer Graphics. Projection

CSE 167: Lecture 11: Textures 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CSE 167: Introduction to Computer Graphics Lecture #3: Coordinate Systems

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

Exercise Max. Points Total 90

Computer graphics 2: Graduate seminar in computational aesthetics

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

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

Transformation Pipeline

Lecture 2. Shaders, GLSL and GPGPU

CSE 167: Introduction to Computer Graphics Lecture #9: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Graphics Programming

CS4620/5620: Lecture 14 Pipeline

CSE 167: Introduction to Computer Graphics Lecture #4: Coordinate Systems

CSE 167: Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Lecture 4 of 41. Lab 1a: OpenGL Basics

Viewing with Computers (OpenGL)

CS 4620 Program 3: Pipeline

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

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

For each question, indicate whether the statement is true or false by circling T or F, respectively.

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

OpenGL Transformations

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

CS 130 Final. Fall 2015

CSE 167: Lecture #17: Procedural Modeling. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

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

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

COMP3421. Introduction to 3D Graphics

Computer Graphics Shadow Algorithms

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

OpenGL. Toolkits.

CSE 167: Introduction to Computer Graphics Lecture #7: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Motivation. What we ve seen so far. Demo (Projection Tutorial) Outline. Projections. Foundations of Computer Graphics

The View Frustum. Lecture 9 Sections 2.6, 5.1, 5.2. Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2011

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

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Texture mapping. Computer Graphics CSE 167 Lecture 9

CSE 167: Introduction to Computer Graphics Lecture #8: Scene Graph. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Pipeline Operations. CS 4620 Lecture 14

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Models and The Viewing Pipeline. Jian Huang CS456

Computer Graphics 7: Viewing in 3-D

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

E.Order of Operations

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

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

1 OpenGL - column vectors (column-major ordering)

Graphics 2009/2010, period 1. Lecture 6: perspective projection

Models and Architectures

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Transcription:

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Announcements Project 2 due Friday, October 12 Remaining homework grades should go on-line today or tomorrow Compare to your notes and let us know if they don t match To get graded early, please see the TA Sid during his office hours 2

Lecture Overview View Volumes Vertex Transformation Rendering Pipeline 3

View Volumes View volume = 3D volume seen by camera Orthographic view volume Camera coordinates Perspective view volume Camera coordinates World coordinates World coordinates 4

Orthographic View Volume Specified by 6 parameters: Right, left, top, bottom, near, far Or, if symmetrical: Width, height, near, far 5

Perspective View Volume General view volume Camera coordinates Defined by 6 parameters, in camera coordinates Left, right, top, bottom boundaries Near, far clipping planes Clipping planes to avoid numerical problems Divide by zero Low precision for distant objects Usually symmetric, i.e., left=-right, top=-bottom 6

Perspective View Volume Symmetrical view volume y y=top FOV -z z=-near Only 4 parameters Vertical field of view (FOV) Image aspect ratio (width/height) Near, far clipping planes z=-far aspect ratio= tan(fov / 2) = top near right left top bottom = right top 7

Canonical View Volume Goal: create projection matrix so that User defined view volume is transformed into canonical view volume: cube [-1,1]x[-1,1]x[-1,1] Multiplying corner vertices of view volume by projection matrix and performing homogeneous divide yields corners of canonical view volume Perspective and orthographic projection are treated the same way Canonical view volume is last stage in which coordinates are in 3D Next step is projection to 2D frame buffer 8

Lecture Overview View Volumes Vertex Transformation Rendering Pipeline 9

Projection Matrix Camera coordinates Projection matrix Canonical view volume 10

Orthographic Projection Matrix In OpenGL: glortho(left, right, bottom, top, near, far) 11 2 right + left 0 0 right left right left 2 top + bottom 0 0 P ortho (right,left,top,bottom,near, far) = top bottom top bottom 2 far + near 0 0 far near far near 0 0 0 1 2 0 0 0 width 2 0 0 0 P ortho (width,height,near, far) = height 2 far + near 0 0 far near far near 0 0 0 1

Perspective Projection Matrix General view frustum with 6 parameters Camera coordinates In OpenGL: glfrustum(left, right, bottom, top, near, far) 12

Perspective Projection Matrix Symmetrical view frustum with field of view, aspect ratio, near and far clip planes Camera coordinates y y=top FOV z=-near -z 1 0 0 0 aspect tan(fov / 2) 1 0 0 0 P persp (FOV,aspect,near, far) = tan(fov / 2) near + far 0 0 near far 0 0 1 0 In OpenGL: gluperspective(fov, aspect, near, far) 13 z=-far 2 near far near far

Viewport Transformation After applying projection matrix, scene points are in normalized viewing coordinates Per definition within range [-1..1] x [-1..1] x [-1..1] Next is projection from 3D to 2D (not reversible) Normalized viewing coordinates can be mapped to image (=pixel=frame buffer) coordinates Range depends on window (view port) size: [x0 x1] x [y0 y1] Scale and translation required: 14 D( x 0, x 1, y 0, y 1 )= ( x 1 x 0 ) 2 0 0 x 0 + x 1 0 ( y 1 y 0 ) 2 0 y 0 + y 1 0 0 1 2 1 2 0 0 0 1 ( ) 2 ( ) 2

Complete Vertex Transformation Mapping a 3D point in object coordinates to pixel coordinates: Object space M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix 15

Complete Vertex Transformation Mapping a 3D point in object coordinates to pixel coordinates: Object space World space M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix 16

Complete Vertex Transformation Mapping a 3D point in object coordinates to pixel coordinates: M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix Object space World space Camera space 17

Complete Vertex Transformation Mapping a 3D point in object coordinates to pixel coordinates: M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix Object space World space Camera space Canonical view volume 18

Complete Vertex Transformation Mapping a 3D point in object coordinates to pixel coordinates: Object space World space Camera space Image space M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix Canonical view volume 19

Complete Vertex Transformation Mapping a 3D point in object coordinates to pixel coordinates: Pixel coordinates: M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix 20

The Complete Vertex Transformation Object Coordinates Model Matrix World Coordinates Camera Matrix Camera Coordinates Canonical View Volume Coordinates Window Coordinates Projection Matrix Viewport Matrix 21

Complete Vertex Transformation in OpenGL Mapping a 3D point in object coordinates to pixel coordinates: OpenGL GL_MODELVIEW matrix M: Object-to-world matrix C: camera matrix P: projection matrix D: viewport matrix OpenGL GL_PROJECTION matrix 22

Complete Vertex Transformation in OpenGL GL_MODELVIEW, C -1 M Defined by programmer GL_PROJECTION, P Utility routines to set it by specifying view volume: glfrustum(), glperspective(), glortho() Do not use utility functions in homework project 2 Viewport, D Specify implicitly via glviewport() No direct access with equivalent to GL_MODELVIEW or GL_PROJECTION 23

Lecture Overview View Volumes Vertex Transformation Rendering Pipeline 24

Rendering Pipeline Scene data Rendering pipeline Hardware and software which draws 3D scenes on the screen Consists of several stages Simplified version here Most operations performed by specialized hardware (GPU) Access to hardware through low-level 3D API (OpenGL, DirectX) All scene data flows through the pipeline at least once for each frame 25 Image

Rendering Pipeline Scene data Modeling and viewing transformation Shading Textures, lights, etc. Geometry Vertices and how they are connected Triangles, lines, points, triangle strips Attributes such as color Projection 26 Rasterization, visibility Image Specified in object coordinates Processed by the rendering pipeline one-by-one

Rendering Pipeline Scene data Modeling and viewing transformation Shading Projection Transform object to camera coordinates Specified by GL_MODELVIEW matrix in OpenGL User computes GL_MODELVIEW matrix as discussed Rasterization, visibility MODELVIEW matrix 27 Image

Rendering Pipeline Scene data Modeling and viewing transformation Shading Projection Look up light sources Compute color for each vertex Covered later in the course Rasterization, visibility 28 Image

Rendering Pipeline Scene data Modeling and viewing transformation Shading Projection Rasterization, visibility Project 3D vertices to 2D image positions GL_PROJECTION matrix 29 Image

Rendering Pipeline Scene data Modeling and viewing transformation Shading Projection Draw primitives (triangles, lines, etc.) Determine what is visible Rasterization, visibility 30 Image

Rendering Pipeline Scene data Modeling and viewing transformation Shading Projection Rasterization, visibility 31 Image Pixel colors

Rendering Engine Scene data Rendering pipeline Additional software layer encapsulating low-level API Higher level functionality than OpenGL Platform independent Layered software architecture common in industry Game engines Graphics middleware 32 Image