Chi-Cheng Lin, Winona State University CS430 Computer Graphics Rendering Pipeline and Primitive Rasterization.

Slides:



Advertisements
Similar presentations
Coordinate System.
Advertisements

COMPUTER GRAPHICS SOFTWARE.
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
2006 by Jim X. Chen: 1.1. Review –Graphics commands specify straight lines or other geometric primitives that are scan-converted.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Scan Conversion A. Samal. Scan Conversion Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines – Polygons – Circles.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Java ThreadsGraphics Programming Graphics Programming: Windows, Viewports & Clipping.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
CMPE 466 COMPUTER GRAPHICS
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Cohen-Sutherland Line Clipping Algorithm.
H331: Computer Graphics Philip Dutré Department of Computer Science Wednesday, February 25.
CS 4731: Computer Graphics Lecture 4: 2D Graphic Systems
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
University of North Carolina at Greensboro
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 3 Additional Drawing Tools Ureerat Suksawatchon Department of Computer.
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
2003CS Hons RW778 Graphics1 Chapter 3: Windows, viewports World coordinates rather than screen coordinates. World coordinates rather than screen coordinates.
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Week 2 - Wednesday CS361.
GRAFIKA KOMPUTER ~ M. Ali Fauzi. Drawing 2 D Graphics.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Bing-Yu Chen National Taiwan University.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Windows, Viewports, and Clipping
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1.
2D Coordinate Systems and Drawing
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.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Drawing and Coordinate Systems. Coordinate Systems Screen Coordinate system World Coordinate system World window Viewport Window to viewport mapping.
The Graphics Pipeline Revisited Real Time Rendering Instructor: David Luebke.
Lecture 13: Raster Graphics and Scan Conversion
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 3 Additional Drawing Tools PART I.
Chapter #03 More Drawing Tools 1. Viewport 2 Do not have use the entire window for the image: glViewport(x,y,w,h) Values in pixels (screen coordinates)
OpenGL LAB III.
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
Midterm Review Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Visible Surface Detection
Rendering Pipeline Fall, 2015.
Scan Conversion of Polygons
Draw a Simple Object.
Summary of Properties of 3D Affine Transformations
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Chapter #03 More Drawing Tools.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Additional Drawing Tools
Drawing Issues Drawing Coordinate Systems Drawing with Pixels CS-321
Coordinate Systems and Transforming the Coordinates
Introduction to Computer Graphics
OpenGL program.
Computer Graphics 3Practical Lesson
Presentation transcript:

Chi-Cheng Lin, Winona State University CS430 Computer Graphics Rendering Pipeline and Primitive Rasterization

2 Topics l Introduction l Viewport Transformation l Primitive Rasterization l Primitive Clipping

3 Introduction l Scan conversion zConvert specification of a primitive into pixels in the frame buffer l Simple rendering pipeline Model Viewport Transformation Scan Conversion Pixels on display

4 Viewport Transformation l Problem zWhen we define a 2D model, we want to use whatever coordinate values and units convenient to use in the 2D Cartesian system. zBUT, the coordinate values on the display (or in the screen window) are always nonnegative measured in pixels. zALSO, we might want to show different parts of our model in different places on the display (or in the screen window) l Solution: viewport transformation

5 World Window and Viewport l World coordinate zSpace in which objects are described l World window zA rectangle area specifies which part of the “world” should be drawn l Viewport zA rectangle area specifies which part on the display (or in the window) the world window is mapped to

6 World Window and Viewport l Example

7 Window-to-Viewport Mapping l (x, y) in world window should be mapped to (sx, sy) in viewport proportionally  distortion is possible

8 Window-to-Viewport Mapping (x,y)(x,y) (sx,sy) x - W.l y - W.b sy - V.b sx - V.l l Every vertex used in window to define an object should be mapped to viewport

9 Window-to-Viewport Mapping

10 How does OpenGL do it? l Set up world window zglMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(left, right, bottom, top); zWe can write a function setWindow() ysetWindow(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(left, right, bottom, top); }

11 How does OpenGL do it? l Set up viewport zglViewport(left, bottom, width, height); or glViewport(left, bottom, right-left, top-bottom); zDefault viewport = screen window size l Parameters to set up a window are doubles while those to set up a viewport are ints. (Why?)

12 Example: Tiling with Motif setWindow(0,640.0,0,440.0); // set a fixed window for (int i=0; i<5; i++) // for each column for (int j=0; j<5; j++) { // for each row glViewport(i*64, j*44, 64, 44); // set the next viewport drawPolylineFile(“dino.dat ”); // draw it again }

13 Example: Tiling with Motif for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) { if ((i+j)%2 = 1) // if (i+j) is odd setWindow(0.0, 640.0, 0.0, 440.0); // right-side-up window else setWindow(0.0, 640.0, 440.0, 0.0); // upside-down window glViewport(i*64, j*44, 64, 44); // set the next viewport drawPolylineFile("dino.dat"); // draw it again }

14 Zooming and Panning l Zooming zScale the world window with respect to the center of the world window with viewport fixed l Panning zShift the world window with viewport fixed

15 Mapping without Distortion l To prevent from distortion, a viewport with the same aspect ratio of world window is required. zAspect ratio: width/height l How do you draw the largest undistorted picture in the screen window?

16 Mapping without Distortion l If aspect ratio of world window = R zTwo cases glViewport(0,0,W,W/R); glViewport(0,0,H*R,H);

17 Resize Screen Window l glutReshapeFunc(myReshape) l Prototype of myReshape zvoid myReshape(GLsizei W, Glsizei H); zW and H: new width and height l Making a matched viewport zvoid myReshape(GLsizei W,GLsizei H) { if (R >W/H) //use (global)window aspect ratio setViewport(0, W, 0, W/R); else setViewport(0, H*R, 0, H); }

18 Primitives Rasterization l Line zBrute force zDDA zMidpoint algorithm l Circle zBrute force zPolar coordinates zMidpoint algorithm l Polyline and polygon

19 Primitive Clipping l Problem zNot everything defined in the world will be included in the world window l Solution zClipping l Line clipping l Polygon clipping l OpenGL does clipping for you