Line Drawing. Foundations of Computer Graphics Torsten Möller

Similar documents
Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

From Ver(ces to Fragments: Rasteriza(on

Rasterization: Geometric Primitives

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Rasterization, or What is glbegin(gl_lines) really doing?

COMP371 COMPUTER GRAPHICS

The Traditional Graphics Pipeline

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

The Traditional Graphics Pipeline

Computer Graphics. - Rasterization - Philipp Slusallek

Chapter 8: Implementation- Clipping and Rasterization

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

CS452/552; EE465/505. Clipping & Scan Conversion

The Traditional Graphics Pipeline

Einführung in Visual Computing

Rendering. A simple X program to illustrate rendering

CPSC / Scan Conversion

Line Drawing Week 6, Lecture 9

Realtime 3D Computer Graphics Virtual Reality

CS Rasterization. Junqiao Zhao 赵君峤

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Scan Conversion. Drawing Lines Drawing Circles

CS 130. Scan Conversion. Raster Graphics

1 Introduction to Graphics

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Computer Graphics D Graphics Algorithms

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

Computer Graphics D Graphics Algorithms

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

EF432. Introduction to spagetti and meatballs

Clipping and Scan Conversion

Rasterization. COMP 575/770 Spring 2013

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CS488 2D Graphics. Luc RENAMBOT

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

CS 543: Computer Graphics. Rasterization

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Painter s HSR Algorithm

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

Chapter - 2: Geometry and Line Generations

Rasterization. CS4620 Lecture 13

Rasteriza2on and Clipping

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Efficient Plotting Algorithm

Rendering. A simple X program to illustrate rendering

Pipeline and Rasterization. COMP770 Fall 2011

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

CS 130 Final. Fall 2015

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

CS 428: Fall Introduction to. Polygon rendering: additional topics. Andrew Nealen, Rutgers, /14/2009 1

Topic #1: Rasterization (Scan Conversion)

Display Technologies: CRTs Raster Displays

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

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

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Topics. From vertices to fragments

Points and lines. x x 1 + y 1. y = mx + b

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

EF432. Introduction to spagetti and meatballs

Models and Architectures

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Introduction to Computer Graphics with WebGL

Scan Conversion. Lines and Circles

Graphics (Output) Primitives. Chapters 3 & 4

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics?

UNIT -8 IMPLEMENTATION

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

COMP3421. Particle Systems, Rasterisation

Pipeline implementation II

Computer Graphics and Visualization. Graphics Systems and Models

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

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

CHAPTER 1 Graphics Systems and Models 3

Prof. Feng Liu. Fall /25/2018

CS2401 COMPUTER GRAPHICS ANNA UNIV QUESTION BANK

(Refer Slide Time: 00:03:51)

Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

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

RASTERIZING POLYGONS IN IMAGE SPACE

A New Line Drawing Algorithm Based on Sample Rate Conversion

(Refer Slide Time: 9:36)

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

OUTPUT PRIMITIVES. CEng 477 Introduction to Computer Graphics METU, 2007

CS4620/5620: Lecture 14 Pipeline

CSCI 4620/8626. Coordinate Reference Frames

CS 130 Exam I. Fall 2015

Transcription:

Line Drawing Foundations of Computer Graphics Torsten Möller

Rendering Pipeline Hardware Modelling Transform Visibility Illumination + Shading Perception, Interaction Color Texture/ Realism

Reading Angel Chapter 8.8-8.10

Today Recap - the graphics pipeline Rasterizing lines brute-force DDA Bresenham Rasterizing quadrics Anti-aliasing

The graphics pipeline From the modeling stage to image formation Pipelined approach helps increase system throughput Throughput: rate at which data flows through the system In a pipeline, data processing in subsequent blocks can be done in parallel Especially effective when the same sequence of operations are to be performed on large quantity of data true in graphics

Vertex processor Per-vertex operations (vertices define objects/primitives) Two main functionalities: Coordinate transformations Color computation at each vertex (shading models) Objects/geometry first defined in their own coordinate systems, then transformed into a world space modeling transformation Then objects are transformed from world space into the camera coordinate system viewing transformation and projection transformation

Clipping and primitive assembly Model a finite field of vision Remove objects outside a finite clipping volume Need to be done on a primi- tive by primitive basis, not on vertices Output is a set of primitives whose projections can appear in the image

Rasterizer The rasterizer converts a primitive into a set of fragments A fragment stores per pixel information for its associated primitive, later used to determine whether the fragment contributes to pixel color and to compute the pixel color Raster/pixel location (in the frame buffer) Depth, e.g., to determine whether this fragment survives Interpolated attributes, e.g., color and texture coordinate, from the previous stages Alpha value (for blending) Window ID, etc.

Fragment processing Performs per-fragment operations Main function is to compute the color at a pixel, using information stored in the fragments, e.g., depth, alpha, texture coordinates; can also add in fog and other effects A (programmable) fragment shader is a program that performs the processing which replaces the OpenGL fixed functionality, e.g., simply using interpolated attributes Similar to a vertex shader (per-vertex operations) Shader programs typically have limited instruction set

Where are we at now? Drawing or rasterization of primitives first. Consider lines and polygons.

Line drawing in OpenGL glcolor3f(1.0, 1.0, 1.0); gllinewidth(2.0); glbegin(gl_lines); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glvertex2f(0.5, -0.5); glend(); glbegin(gl_line_strip); glbegin(gl_line_loop); There is no GL_CIRCLE

Assumptions Transformation, clipping, projection already done Primitives to rasterize are actually inside the screen Work with 2D screen coordinates with square pixels (N, M) (0, 0)

Primitives Polygons explicit curves lines, quadrics (conic sections) parametric curves/surfaces Curves, Surfaces implicit description, e.g. x 2 +y 2-1=0 Misc particle systems/points, fractals

Explicit Descriptions Given - an explicit equation y = f(x) cannot get multiple values of y no infinite slope (vertical line) axis dependent (y depends on x) specify one variable and resolve for the other

Lines Given - an explicit line equation y = mx+n Which pixels to set? http://bert.stuy.edu/pbrooks/graphics/demos/bresenhamdemo.htm

Scan Converting Lines Compute the coordinates of pixels that lies on or near an ideal, infinitely thin line imposed on a 2D raster grid Assumptions line will be 1 pixel thick and will approximate an infinitely fine line pixels represented as disjoint circles, centred on a grid (unless specified otherwise) integer coordinates of endpoints pixel on or off (2 states)

Scan Converting Lines (2) Desirable properties: constant brightness (irrespective of length or orientation) 1 pixel per column (-1 <= slope <= 1), 1 pixel per row (slope > +/- 1) as close to the ideal/as straight as possible allow control of pen, line and endpoint styles drawn as smoothly as possible (anti-aliasing) drawn as rapidly as possible

Lines - solutions Brute force for each column x i compute the row y i =round(mx i +n) very costly incremental! (Newtons idea) we know y i - find y i+1 y i+1 = round(y i +m)

Basic Brute force Find slope m = rise/run or y = mx + b increment x by 1 (xi); calculate yi = mxi + b pixel (xi, round(yi)) turned on simple, but inefficient: floating point multiplication addition round

Incremental - DDA multiplication can be eliminated: called digital differential analyzer (DDA) - after mechanical device that solves differential equations by numerical methods Drawbacks: floating point values (m,y) round operation special cases could be done more quickly

Lines - Bresenham Special case of Midpoint Line Algorithm uses only integer arithmetic & no rounding idea is to provide the best-fit approximation to a true line by minimizing the error (distance) to the true line slope (rest is done with reflection)

Lines - Bresenham (2) Explicit line equation: Implicit line equation: Main idea - call on decision variable:

Lines - Bresenham (3) if di < 0, pick O, and: if di > 0, pick NO, and: if di = 0, pick either one, but consistently

Lines - Bresenham (4) dx=6 dy=3 Bresenham [Wikipedia]

Lines - Bresenham (5) Additional issues: - covers 0 <= m <= 1 case, other 7 octants: exchange x/y, mirror x and y Endpoint order: we want P0 to P1 to look exactly the same as P1 to P0 Starting at edge of a clip rectangle: we must use the midpoint test result rather than computing intersections analytically if we are to ensure the correct sequence of pixels

Lines - Bresenham (4)

Quadrics - Circles Circles, ellipsoids, etc. divide in 8 quadrants What is special about 8-fold symmetry?

Quadrics - Circles (2) Midpoint Circle Algorithm trace out arc in 2nd octant and draw the rest by symmetry choose between E and SE pixel at each stage

Quadrics - Circles (3) incremental - now have higher order higher order difference system

Quadrics - Ellipses Can a midpoint algorithm be developed for ellipses? What are the important differences from circles? The result is Da Silva's algorithm (the idea is illustrated below):

Lines - Anti-Aliasing A continuous (zero-width) line is invisible in a discrete grid. Give line thickness - How? Signal Processing Approach: line is high-frequency want to avoid aliasing what to do first?

Lines - Anti-Aliasing (2) Bandlimit signal - how? Convolve with smoothing filter - which?

Lines - Anti-Aliasing (3) Box filter not all that good convolve it again - why? Then resample!

Lines - Anti-Aliasing (4) Other alternatives? Can we improve this algorithm?

General Anti-Aliasing: super-sampling simple but expensive simply sample n times within a pixel and average!

remember

Aliasing example Machiraju/Möller

Point vs. supersampling Machiraju/Möller

Xiaolin Wu's line algorithm Multi-sample AA: https://www.youtube.com/watch?v=hqi0114mwty