CS 591B Lecture 9: The OpenGL Rendering Pipeline

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

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

3D Rendering Pipeline (for direct illumination)

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

Computer Graphics. Chapter 7 2D Geometric Transformations

OpenGL Transformations

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

Transformation Pipeline

CSCI E-74. Simulation and Gaming

Lecture 4 of 41. Lab 1a: OpenGL Basics

Computer Graphics. Chapter 10 Three-Dimensional Viewing

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

Models and Architectures

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

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

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

OpenGL. Toolkits.

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

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

Introduction to Computer Graphics with WebGL

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

CS 4204 Computer Graphics

CSC 470 Computer Graphics

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Precept 2 Aleksey Boyko February 18, 2011

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

Advanced Computer Graphics (CS & SE )

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

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

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Rasterization Overview

window World space (Object space)

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Computer Graphics and Visualization. Graphics Systems and Models

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

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

OpenGL/GLUT Intro. Week 1, Fri Jan 12

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

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

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

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

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

CSE4030 Introduction to Computer Graphics

OpenGL: Setup 3D World

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

Computer graphics MN1

Computer Graphics. Bing-Yu Chen National Taiwan University

C OMPUTER G RAPHICS Thursday

Introduction to OpenGL

Graphics Pipeline & APIs

CS488. Implementation of projections. Luc RENAMBOT

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

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

Graphics Programming

Matrix-Rechnung I ' z =... Universität Frankfurt

CS 112 The Rendering Pipeline. Slide 1

Sung-Eui Yoon ( 윤성의 )

E.Order of Operations

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

Computer Graphics Viewing Objective

Fachhochschule Regensburg, Germany, February 15, 2017

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

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

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

CS602- Computer Graphics Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring 2013 CS602- Computer Graphics

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

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

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

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

Fundamental Types of Viewing

The Traditional Graphics Pipeline

Graphics Pipeline & APIs

OXFORD ENGINEERING COLLEGE (NAAC Accredited with B Grade) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS

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

Rendering Pipeline and Coordinates Transforms

CS 4204 Computer Graphics

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

The OpenGL Mathematics (GLM) Library

Transformations. CSCI 420 Computer Graphics Lecture 4

3D Viewing Episode 2

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

12. Selection. - The objects selected are specified by hit records in the selection buffer. E.R. Bachmann & P.L. McDowell MV 4202 Page 1 of 13

Basic Graphics Programming

Computer graphic -- Programming with OpenGL I

CS Computer Graphics: Hidden Surface Removal

Pipeline Operations. CS 4620 Lecture 14

The Traditional Graphics Pipeline

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

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

Computer graphics MN1

Lecture 4. Viewing, Projection and Viewport Transformations

Basic Graphics Programming

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

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

Transcription:

CS 591B Lecture 9: The OpenGL Rendering Pipeline 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination Spring 2007 Rui Wang 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination Quake II (Id Software) 3D Rendering Pipeline (direct illumination) Example: OpenGL This is a pipelined sequence of operations to draw a 3D primitive into a 2D image glbegin(gl_polygon); glvertex3f(0.0, 0.0, 0.0); glvertex3f(1.0, 0.0, 0.0); glvertex3f(1.0, 1.0, 1.0); glvertex3f(0.0, 1.0, 1.0); glend(); OpenGL executes steps of 3D rendering pipeline for each polygon 1

Transform into 2D screen coordinate system Transform into 2D screen coordinate system Transform into 2D screen coordinate system Clip primitives outside camera s view Clip primitives outside camera s view Draw pixels (includes texturing, hidden surface,...) 2

Rasterization s p(x,y,z) 3D Object Coordinates 3D Camera Coordinates } s -to- 2D Coordinates p (x,y ) in OpenGL OpenGL has multiple matrix stacks - transformation functions right-multiply the top of the stack Two most important stacks: GL_MODELVIEW and GL_PROJECTION Points get multiplied by the modelview matrix first, and then the projection matrix GL_MODELVIEW: Object->Camera GL_PROJECTION: Camera->Screen gl(0,0,w,h): Screen->Device OpenGL Example void SetUp() { // The viewport isn t a matrix, it s just state... gl( 0, 0, window_width, window_height ); // Set up camera->screen transformation first glmatrixmode( GL_PROJECTION ); glloadidentity(); float asp = (float)window_width/ (float)window_height; gluperspective( 60, asp, 1, 1000 ); // fov, aspect, near, far } // Set up the model->camera transformation glmatrixmode( GL_MODELVIEW ); glulookat( 3, 3, 2, // eye point 0, 0, 0, // look at point 0, 0, 1 ); // up vector glrotatef( theta, 0, 0, 1 ); // rotate the model glscalef( zoom, zoom, zoom ); // scale the model What s next? 2D Rendering Pipeline 2D Primitives Clip portions of geometric primitives residing outside the window Transform into 2D camera coordinate system Transform the clipped primitives from screen to image coordinates Clip primitives outside camera s view Draw pixels (includes texturing, hidden surface, etc.) Fill pixels representing primitives in screen coordinates 3

2D Rendering Pipeline 2D Primitives Avoid drawing parts of primitives outside window defines part of scene being viewed Must draw geometric primitives only inside window Clip portions of geometric primitives residing outside the window Transform the clipped primitives from screen to image coordinates Fill pixels representing primitives in screen coordinates Screen Coordinates Avoid drawing parts of primitives outside window defines part of scene being viewed Must draw geometric primitives only inside window Avoid drawing parts of primitives outside window Points Lines Polygons Circles etc. Point Is point (x,y) inside the clip window? Line Find the part of a line inside the clip window wy2 (x,y) inside = (x >= wx1) && (x <= wx2) && (y >= wy1) && (y <= wy2); P 7 P 8 wy1 wx1 wx2 P 9 0 Before 4

Line Find the part of a line inside the clip window Cohen Sutherland Line Use simple tests to classify easy cases first P 7 P 7 P 8 P 8 P 5 0 After P 9 Cohen Sutherland Line Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) Line Find the part of a line inside the clip window 1001 P 7 0001 0101 P 7 1000 P 8 0000 0100 Bit 4 P 8 1010 Bit 3 0010 P 9 0110 Bit 1 Bit 2 0 P 5 After Avoid drawing parts of primitives outside window Points Lines Polygons Circles etc. Polygon Find the part of a polygon inside the clip window? Before 5

Polygon Find the part of a polygon inside the clip window? Sutherland Hodgeman After Sutherland Hodgeman Sutherland Hodgeman Sutherland Hodgeman Sutherland Hodgeman 6

to a to a to a to a to a to a P P 7

to a to a P P P to a Summary 2D Primitives P P Clip portions of geometric primitives residing outside the window Transform the clipped primitives from screen to image coordinates Fill pixels representing primitives in screen coordinates What s Next Some Other Stuffs 3D Coordinates 3D Coordinates.Occlusion Culling.Backface Culling 3D Camera Coordinates 3D Camera Coordinates 2D Coordinates 2D Coordinates! 2D Coordinates 2D Coordinates 8