Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.

Slides:



Advertisements
Similar presentations
5.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 5 – Drawing A Line.
Advertisements

ENGINEERING GRAPHICS 1E7
Computer Graphics- SCC 342
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Let Maths take you Further…
Classes of Polygons Planar polygons Non-planar polygons Simple
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Higher Outcome 1 Higher Unit 1 Distance Formula The Midpoint Formula Gradients Collinearity Gradients of Perpendicular.
TEKS 8.6 (A,B) & 8.7 (A,D) This slide is meant to be a title page for the whole presentation and not an actual slide. 8.6 (A) Generate similar shapes using.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Chapter 4 Digital Multimedia, 2nd edition Vector Graphics.
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
Content Subdivision First some basics (control point polygon, mesh)
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
Geometry Formulas in Three Dimensions
Mathematical Fundamentals
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
COMP 175: Computer Graphics March 24, 2015
Higher Unit 1 Distance Formula The Midpoint Formula Gradients
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
Computer Graphics Texture Mapping
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
1 Line Drawing Version B: Semi-Formal Methods Derivation ©Anthony Steed
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
CAP4730: Computational Structures in Computer Graphics
Games Development 1 Camera Projection / Picking CO3301 Week 8.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
CS 376 Introduction to Computer Graphics 02 / 23 / 2007 Instructor: Michael Eckmann.
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
Higher Outcome 1 Higher Unit 1 Distance Formula The Midpoint Formula Gradients Collinearity Gradients of Perpendicular Lines The Equation of a Straight.
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
COMP135/COMP535 Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 4 Lecture 4 - Vector Graphics.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
Interactive Graphics Lecture 10: Slide 1 Interactive Computer Graphics Lecture 10 Introduction to Surface Construction.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
Computer Graphics Matrices
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Descriptive Geometry. Introduction  What is Descriptive Geometry? →It is the study of points, lines, and planes in space to determine their locations.
Lecture 13: Raster Graphics and Scan Conversion
SKETCHING LINEAR GRAPHS (3A). THE METHODS  There are many methods for sketching linear graphs:  plotting  x and y intercept method  gradient intercept.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Main characteristics of Vector graphics  Vector graphics provide an elegant way of constructing digital images (diagrams, technical illustration and.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
Visible Surface Detection
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Digital Media Dr. Jim Rowan ITEC 2110.
Transformations for GCSE Maths
Lecture 13 Clipping & Scan Conversion
Transformations for GCSE Maths
Chapter 3 Graphics Output Primitives
Transformations for GCSE Maths
Presentation transcript:

Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2

Today’s Lecture 1.2D Geometry 2.Coordinate Systems & Viewports 3.Rendering Points and Lines 4.Polygons and Circles 5.Anti-Aliasing

2D Geometry Basics Will look at 2D geometry represented by points and lines in two dimensional Cartesian space Represented on a graph with two axes, usually X (horizontal) and Y (vertical) Origin of the graph and of the 2D space is where the axes cross (X = Y = 0)

2D Geometry Definitions I will often use informal English to describe 2D geometry. However, here are a couple of specific definitions that will be used: A vertex: a single point (plural = vertices) defined by coordinates on the axes An edge: a straight line joining two vertices A polygon: a single closed loop of edges

Specifying 2D Geometry Example vertices: A(10, 20), B(30, 30), C(35, 15) Edges: AB, BC, AC Edges with direction (a form of vector, see later lectures),, Polygons: ABCA, or ABC (implies the final edge to A)

Coordinate Systems / Spaces Define a coordinate system as a particular choices for: –The location of the origin –Orientation and scale of the axes This is also known as a space Can view the same geometry in different spaces: –World space: an overview of all the geometry –Viewport space: where the geometry is relative to the viewing window (see next slide) –Will see more spaces later, an important concept

Viewports A viewport (or window) is a rectangle of pixels representing a view into the world space A viewport has its own coordinate system, which may not match that of the geometry it shows –The axes will usually be X horizontal & Y vertical But don’t have to be – rotated viewports –The scale of the axes may be different –The direction of the Y axis may differ. E.g. the geometry may be stored with +ve Y up, but the viewport has +ve Y down. –The origin (usually in the corners or centre of the viewport) may not match the geometry origin.

Viewport Example Example of changing coordinate system from world space to viewport space: P = (20,15) in world space. Where is P’ in viewport space?

Rendering Points Rendering is the process of converting 2D or 3D geometry into pixels To render a vertex (a point): –Convert vertex coordinates into viewport space –Set the colour of the pixel at those coordinates –The colour might be stored with the geometry, or we can use a fixed colour (e.g. black) In the previous diagram the vertex P would be rendered by setting the colour of the pixel at coordinates (266, 450) in the viewport

Rendering Lines: 1 st Attempt A possible method to render an edge (a line): –Convert the start and end vertex into viewport space –Trace along this converted edge –Colour each pixel traced over Unfortunately, this method creates thick lines. We need to colour fewer pixels to get a cleaner result.

Rendering Lines: 2 nd Attempt Consider drawing a horizontal line with previous method: –Trace along horizontally adjacent pixels, setting the colour of each –Result is fine Adapt this for a diagonal line: –Start at the left end of the line –Move rightwards, colouring each pixel –Periodically move up or down one pixel to create ‘steps’ of the correct gradient –Use variations of above for lines in different directions To go from start to end need to move right 9 pixels and down 4 pixels. So move down one pixel about every 9/4 pixels right

Rendering Lines: Algorithms We will use a basic version of this algorithm to render lines in the lab –Using floating point calculations A widely used method is Bresenham’s Line Algorithm –Wikipedia versionWikipedia version –Highly efficient - only uses integer calculations –We won’t cover this, or other efficient 2D algorithms in this module as we will concentrate on higher level graphics work –Many 2D algorithms like this are implemented in hardware now

A polygon is a sequence of edges, so we render a polygon outline by simply rendering each edge –We only need the set of vertices defining the polygon Axis-aligned squares and rectangles are special cases of a polygon and can be rendered more efficiently. –Horizontal / vertical lines are simple cases But how to render a filled polygon? Rendering Polygons

Case of a triangle: –Simultaneously render the two polygon edges starting from the top corner –Each time we move down a pixel connect left & right edges Horizontal line is quick to render –Partway down the triangle one edge changes direction Left edge in this example –Process is relatively simple extension of the line algorithm This is called Rasterisation Filling Polygons

Split more complex polygons into triangles –Always possible Need to identify whether dealing with a convex or concave polygon –A concave polygon has “indentations” What are the algorithms used here? Filling Polygons

Rendering Circles? The coordinates of a circle can be written as: X = A + R sin(α), Y = B + R cos(α), for 0 ≤ α < 360º where (A, B) is the circle centre and R the radius We could use this to render a circle: –Step α from 0 to 360 and calculate X & Y –Convert to viewport space and colour the pixels Not ideal though – why not? Try it in the lab Again there is a better integer-based method Called the midpoint circle algorithm (derived from Bresenham’s line algorithm, but not by him) –(Wikipedia article)Wikipedia article

Regular Polygons Can use the circle equations to create regular polygons A regular polygon has all its points on a circle –Can calculate the polygon vertices using the circle equations Conversely - can we use regular polygons to draw a circle?

Anti-Aliasing Returning to the naive line algorithm: –Again we colour every pixel passed through –This time consider how close the centre of the pixel is to the line we are drawing –The colour used is more intense for pixels that lie nearer the line This is an anti-aliased line –Aliasing is the ‘jagged’ look of pixel edges –This method smoothes these effects – hence the name: anti- aliasing –Note: one example of anti-aliasing, there are several other approaches