Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();

Slides:



Advertisements
Similar presentations
Coordinate System.
Advertisements

COMPUTER GRAPHICS SOFTWARE.
OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
Lecture 3 Graphics Pipeline and Graphics Software
©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
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.
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
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
Lecture 5 Rendering lines 1.Steps of line rendering 2.Scan-conversion for line segments 3.A1 tutorial CP411 Computer Graphics Fall 2007 Wilfrid Laurier.
Chapter 2: Graphics Programming
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
Java ThreadsGraphics Programming Graphics Programming: Windows, Viewports & Clipping.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
Clipping Lines Lecture 7 Wed, Sep 10, The Graphics Pipeline From time to time we will discuss the graphics pipeline. The graphics pipeline is the.
1 Computer Graphics Chapter 4 2D Viewing Algorithms.
Mapping between Scene and Screen. Screen (0, W-1) (W-1, H-1) (W-1, 0)(0, 0) Projection Plane (Xmin, Ymin)(Xmax, Ymin) (Xmax, Ymax) (Xmin, Ymax) Screen.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
Surface Rendering With OpenGL CS460 Project by Rui Yu 11/30/03.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
2-Dimension Viewing and Clipping
INTRO TO COMPUTER GRAPHICS TEXT EDWARD ANGEL: EDITION 5 CS770/870
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
CSE 681 Introduction to 3D Graphics. CSE 681 Computer graphics is “the creation and manipulation of graphics images by means of computer.” (Marc Berger,
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Drawing and Coordinate Systems. Coordinate Systems Screen Coordinate system World Coordinate system World window Viewport Window to viewport mapping.
CS552: Computer Graphics Lecture 6: Viewing in 2D.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
The Graphics Pipeline Revisited Real Time Rendering Instructor: David Luebke.
Lecture 13: Raster Graphics and Scan Conversion
Objective – Students will be able to investigate graphs with different viewing windows or viewing screens. Therefore learning how important it is to choose.
Texture Mapping What is texture mapping? - a method for adding detail, surface texture (a bitmap or raster image), or color to a computer-generated graphic.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Spring 2006 G5BAGR – Advanced Computer Graphics
Draw a Simple Object.
The Graphic PipeLine
Computer Graphics Shading in OpenGL
Basic Raster Graphics Algorithms for Drawing 2D Primitives
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
2D Viewing Pipeline.
Lecture 18 Fasih ur Rehman
Implementation I Ed Angel
WINDOWING AND CLIPPING
WINDOWING AND CLIPPING
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Introduction to OpenGL
Visibility (hidden surface removal)
Rendering – Basic Concepts
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
Introduction to 3D Graphics
OpenGL-Rendering Pipeline
Presentation transcript:

Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity(); gluOrtho2D(-1,1,-1,1); glBegin(GL_QUADS); glColor3f(1,1,0); glVertex2i(-0.5,-0.5); glVertex2i(+0.5,0); glVertex2i(+0.5,+0.5); glVertex2i(-0.5,+0.5); glEnd(); }

2D Graphics Pipeline Object Local Coordinates Object World Coordinates Modeling transformation (next page) Graphics processing consists of many stages:

2D Graphics Pipeline (2) Object World Coordinates Object subset window to viewport mapping Object Screen coordinates RasterizationDisplay Applying world window Clipping Simple 2D Drawing Pipeline

Clipping and Rasterization OpenGL does these for you – no explicit OpenGL functions needed for doing clipping and rasterization Clipping – Remove objects that are outside the world window Rasterization (scan conversion) – Convert high level object descriptions to pixel colors in the frame buffer

2D Point Clipping Determine whether a point (x,y) is inside or outside of the world window? (xmin, ymin) (xmax, ymax) If (xmin <= x <= xmax) and (ymin <= y <= ymax) then the point (x,y) is inside else the point is outside

2D Line Clipping Determine whether a line is inside, outside, or partially inside If a line is partially inside, we need to display the inside segment (xmin, ymin) (xmax, ymax)

Trivial Accept Case Lines that are clearly inside the world window - what are they? (Xmin, Ymin) (Xmax, Ymax) p1 p2 Xmin <= P1.x, P2.x <=xmax Ymin <= P1.y, P2.y <= Ymax

Trivial Reject Case Lines that are clearly outside the world window – what are they? p1 p2  p1.x, p2.x <= Xmin OR  p1.x, p2.x >= Xmax OR  p1.y, p2.y <= ymin OR  p1.y, p2.y >= ymax

Non-Trivial Cases Lines that cannot be trivially rejected or accepted One point inside, one point outside Both points are outside, but not “trivially” outside Need to find the line segments that are inside p1 p2

Rasterization (Scan Conversion) Convert high-level geometry description to pixel colors in the frame buffer Viewport Transformation Rasterization

Rasterization Algorithms A fundamental computer graphics function Determine the pixels’ colors, illuminations, textures, etc. Implemented by graphics hardware Rasterization algorithms Lines Circles Triangles Polygons

Rasterize Lines Why learn this? Understand the discrete nature of computer graphics Write pure device independent graphics programs (Palm graphics) Become a graphics system developer

Line Drawing Algorithm (1) Line: (3,2) -> (9,6) ?

Line Drawing Algorithm (2) Slope-intercept line equation Y = mx + b Given two end points (x0,y0), (x1, y1), how to compute m and b? m = (y1-y0) / (x1 – x0) = dy / dx (x0,y0) (x1,y1) dx dy b = y1 – m * x1

Line Drawing Algorithm (3) (x0,y0) (x1,y1) dx dy Given the line equation y = mx + b, and end points (x0,y0) (x1, y1) Walk through the line: starting at (x0,y0) If we choose the next point in the line as X = x0 +  x Y = ? Y = y0 +  x * m = y0 +  x * (dy/dx)

Line Drawing Algorithm (4) (x0, y0) X = x0 + 1 Y = y0 + 1 * m Illuminate pixel (x, int(Y)) X = X + 1 Y = Y + 1 * m Illuminate pixel (x, int(Y)) … Until X == x1 (x1,y1) X = x0 Y = y0 Illuminate pixel (x, int(Y))

Line Drawing Algorithm (5) How about a line like this? Can we still increment X by 1 at each Step? The answer is No. Why? How to fix it ? Increment Y We don’t get enough samples

Line Drawing Algorihtm (6) Y = y0 + 1 X = x0 + 1 * 1/m Illuminate pixel (x, int(Y)) Y = Y + 1 X = X + 1 /m Illuminate pixel (x, int(Y)) … Until Y == y1 X = x0 Y = y0 Illuminate pixel (x, int(Y)) (x1,y1) (x0,y0)

Line Drawing Algorithm (7) The above is the simplest line drawing algorithm Not very efficient Optimized algorithms such integer DDA and Bresenhan algorithm are typically used Not the focus of this course

Triangle Rasterization Issues Sliver

Triangle Rasterization Issues Moving Slivers

Triangle Rasterization Issues Shared Edge Ordering

Edge Equations An edge equation is simply the equation of the line defining that edge Q: What is the implicit equation of a line? A: Ax + By + C = 0 Q: Given a point ( x,y ), what does plugging x & y into this equation tell us? A: Whether the point is: On the line: Ax + By + C = 0 “Above” the line: Ax + By + C > 0 “Below” the line: Ax + By + C < 0

Edge Equations Edge equations thus define two half- spaces:

Edge Equations And a triangle can be defined as the intersection of three positive half- spaces: A 1 x + B 1 y + C 1 < 0 A 2 x + B 2 y + C 2 < 0 A 3 x + B 3 y + C 3 < 0 A 1 x + B 1 y + C 1 > 0 A 3 x + B 3 y + C 3 > 0 A 2 x + B 2 y + C 2 > 0

Edge Equations So…simply turn on those pixels for which all edge equations evaluate to > 0: