Transformation Pipeline

Similar documents
Computer Graphics. Chapter 7 2D Geometric Transformations

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

3D Viewing Episode 2

Drawing and Coordinate Systems

Viewing and Projection

CS 591B Lecture 9: The OpenGL Rendering Pipeline

Computer Graphics. Chapter 10 Three-Dimensional Viewing

3.1 Viewing and Projection

Drawing and Coordinate Systems

Viewing and Projection

CS 4204 Computer Graphics

OpenGL Transformations

Fundamental Types of Viewing

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

Precept 2 Aleksey Boyko February 18, 2011

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

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

Computer graphics MN1

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

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

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

CSE328 Fundamentals of Computer Graphics

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

1 (Practice 1) Introduction to OpenGL

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

Lecture 4 of 41. Lab 1a: OpenGL Basics

3D computer graphics: geometric modeling of objects in the computer and rendering them

Graphics Programming

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

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

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Viewing with Computers (OpenGL)

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

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

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

Windows and Viewports. Windows and Viewports. Windows and Viewports. Windows and Viewports. CSC 706 Computer Graphics

Viewing and Projection

Prof. Feng Liu. Fall /19/2016

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

Viewing COMPSCI 464. Image Credits: Encarta and

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

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

CSCI E-74. Simulation and Gaming

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

Fachhochschule Regensburg, Germany, February 15, 2017

Graphics Hardware and OpenGL

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

3D Viewing Episode 2

OpenGL: Setup 3D World

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

Programming using OpenGL: A first Introduction

CSC 470 Computer Graphics

Interaction. CSCI 480 Computer Graphics Lecture 3

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3

Advanced Computer Graphics (CS & SE )

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

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

Transformations (Rotations with Quaternions) October 24, 2005

Interaction. CSCI 420 Computer Graphics Lecture 3

Computer Viewing Computer Graphics I, Fall 2008

Lecture 4. Viewing, Projection and Viewport Transformations

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

Introduction to 3D Graphics with OpenGL. Z-Buffer Hidden Surface Removal. Binghamton University. EngiNet. Thomas J. Watson

CS354 Computer Graphics Viewing and Modeling

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Geometry: Outline. Projections. Orthographic Perspective

Computer Graphics (Basic OpenGL)

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

C OMPUTER G RAPHICS Thursday

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Order of Transformations

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

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

UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1

Rasterization Overview

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

GL_MODELVIEW transformation

Exercise Max. Points Total 90

OpenGL refresher. Advanced Computer Graphics 2012

CSC 470 Computer Graphics. Three Dimensional Viewing

CSCI 4620/8626. The 2D Viewing Pipeline

CSC 470 Computer Graphics

Basic Graphics Programming

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

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

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

Graphics Pipeline & APIs

window World space (Object space)

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

Interaction Computer Graphics I Lecture 3

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

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

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

CS 543: Computer Graphics Lecture 6 (Part I): 3D Viewing and Camera Control. Emmanuel Agu

Transcription:

Transformation Pipeline Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space

Coordinate system A coordinate system is used to unambiguously represent a point It contains a reference point (the origin) and three linearly independent vectors (the basis) v3 v2 O v1

Screen Coordinate System Glut OpenGL (0,0) 0)

Screen Coordinate System - 2D Regular Cartesian Grid - Origin (0,0) at lower left corner (OpenGL convention) - Horizontal axis x Vertical axis y - Pixels are defined at the grid intersections (0,0) - This coordinate system is defined relative to the display window origin (OpenGL: the lower left corner of the window) (2,2) y x

Local Coordinate System Screen coordinate system is not very useful for displaying 3D objects You also do not necessarily know where the object is going to be placed in the end in the 3D world Solution: define the positions of the vertices relative to its own center Local coordinate system z y z y x x

Simple OpenGL code OpenGL 1.1 convention, the goal here is to show you the idea void display() { glclearcolor(0,0,1,1);,, glclear(gl_color_buffer_bit); glcolor4f(1,1,0,1); //glcolor* have been deprecated in OpenGL 3 glbegin(gl_triangles); //glbegin/end have been deprecated in OpenGL 3 glcolor4f(1,1,0,1); l 4f(1101) glvertex4f(vertices[0], vertices[1], vertices[2], vertices[3]); glvertex4f(vertices[4], vertices[5], vertices[6], vertices[7]); glvertex4f(vertices[8], vertices[9], vertices[10], vertices[11]); glcolor4f(1,0,0,1); glvertex4f(vertices[12], vertices[13], vertices[14], vertices[15]); glvertex4f(vertices[16], vertices[17], vertices[18], vertices[19]); glvertex4f(vertices[20], vertices[21], vertices[22], vertices[23]); glend(); float vertices[] = {-0.5, -0.5, 0.0, 1.0, // first triangle -0.5, 0.5, 0.0, 1.0, 05 0.5, 0.5, 05 0.0, 00 1.0, 10 0.5, 0.5, 0.0, 1.0, // second triangle 0.5, -0.5, 0.0, 1.0, -0.5, -0.5, 0.0, 1.0}; glutswapbuffers(); }

World Coordinate System Local coordinates along do not allow you to specify where the object will be placed position, size, orientation Transformations need to be performed to position the object in the world coordinate system This is done through an arbitrary number of affine s (translation, rotation, scaling) applied to each vertex or =

Modeling Transformation The from local to world coordinates The matrix used is called modeling matrix A modeling is a sequence of translations, rotations, scalings (in arbitrary order) matrices multiplied together More detail to come in the next lecture

Transformation Pipeline Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space

Simple OpenGL code void display() { glclearcolor(0,0,1,1); OpenGL 1.1 convention, the goal here is to show you the idea glclear(gl_color_buffer_bit); glcolor4f(1,1,0,1); //glcolor* have been deprecated in OpenGL 3 glmatrixmode(gl_modelview); glloadidentity(); glrotatef(45, 0,0,1); float vertices[] = {-0.5, -0.5, 0.0, 1.0, // first triangle -0.5, 0.5, 0.0, 1.0, 05 0.5, 0.5, 05 0.0, 00 1.0, 10 0.5, 0.5, 0.0, 1.0, // second triangle 0.5, -0.5, 0.0, 1.0, -0.5, -0.5, 0.0, 1.0}; More detail about what happens behind the scene will be explained glbegin(gl_triangles); //glbegin/end have been deprecated in OpenGL 3 glcolor4f(1,1,0,1); glvertex4f(vertices[0], vertices[1], vertices[2], vertices[3]); glvertex4f(vertices[4], e ti e vertices[5], e vertices[6], e vertices[7]); e glvertex4f(vertices[8], vertices[9], vertices[10], vertices[11]); glcolor4f(1,0,0,1); glvertex4f(vertices[12], vertices[13], vertices[14], vertices[15]); glvertex4f(vertices[16], vertices[17], vertices[18], vertices[19]); glvertex4f(vertices[20], vertices[21], vertices[22], vertices[23]); glend(); glutswapbuffers(); }

Viewing Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space

Viewing Transformation Convert from the world coordinate system to the camera (eye) coordinate system The camera position is the origin i Derive the basis from the direction and orientation of fthe camera This makes the later s easier y world z v coi x u n Eye coordinate frame

Viewing Transformation Head tilt: Rotate your head by Just rotate the object about the eye space z axis - Mw2e = y v u n (ex,ey,ez) ey ez) x z

ModelView Transformation Modeling and Viewing s concatenated together M L2E (or, GL_MODELVIEW matrix) = void display() { glclear(gl_color_buffer_bit); glmatrixmode(gl_modelview); glloadidentity(); glulookat(0,0,1,0,0,0,0,1,0); display_all(); // your display routine } = M glloadidentity(); L2E fixed function pipeline OpenGL

Viewing Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space

Projection Transformation Projection map the object from 3D space to 2D screen z y z y x x Perspective: gluperspective() Parallel: glortho()

Projection Transformation Maps (projects) everything in the visible volume into a canonical view volume (xmax, ymax, -far) (1, 1, -1) (xmin, ymin, -near) glortho(xmin, xmax, ymin, ymax, near, far) (-1, -1, 1) Canonical View Volume

Projection Transformation Maps (projects) everything in the visible volume into a canonical view volume (1, 1, -1) y z x (-1, -1, 1) (-1, -1) Z=1 z= -1 Canonical View Volume gluperspective(fovy, aspect, near, far)

Projection Transformation Projection Matrix glfrustum(xmin, xmax, ymin, ymax, N, F) N = near plane, F = far plane

Viewing Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space

Viewport The rectangular region in the screen for displaying the graphical objects defined in the world window Defined in the screen coordinate system V_T glviewport(int left, int bottom, int (right-left), int (top-bottom)); V_B call this function before drawing V_L V_R (calling glbegin() and glend() )