Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

Similar documents
Computer Graphics. Bing-Yu Chen National Taiwan University

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

CS 543: Computer Graphics. Rasterization

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

COMP371 COMPUTER GRAPHICS

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

CS 4731/543: Computer Graphics Lecture 7 (Part I): Raster Graphics: Polygons & Antialiasing. Emmanuel Agu

An Interactive Introduction to OpenGL Programming

28 SAMPLING. ALIASING AND ANTI-ALIASING

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

Computer Graphics CS 543 Lecture 11 (Part 1) Polygon Filling & Antialiasing

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

CS 5610 / Spring Depth Buffering and Hidden Surface Removal

Buffers, Textures, Compositing, and Blending. Overview. Buffers. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E.

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

8/5/2012. Introduction. Transparency. Anti-Aliasing. Applications. Conclusions. Introduction

? Which intermediate. Recall: Line drawing algorithm. Programmer specifies (x,y) of end pixels Need algorithm to determine pixels on line path

CS 325 Computer Graphics

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

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

E.Order of Operations

Real-Time Graphics Architecture

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

CHAPTER 1 Graphics Systems and Models 3

Previously... contour or image rendering in 2D

Pixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

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

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

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

CMT315 - Computer Graphics & Visual Computing

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

Computer Graphics Geometry and Transform

Rendering Grass Terrains in Real-Time with Dynamic Lighting. Kévin Boulanger, Sumanta Pattanaik, Kadi Bouatouch August 1st 2006

The Rasterization Pipeline

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

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

For this assignment, you are to implement three line drawers and a polygon drawer.

Rendering Grass with Instancing in DirectX* 10

Deferred Rendering Due: Wednesday November 15 at 10pm

Filtering theory: Battling Aliasing with Antialiasing. Department of Computer Engineering Chalmers University of Technology

Line Drawing. Foundations of Computer Graphics Torsten Möller

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Spring 2009 Prof. Hyesoon Kim

Pipeline Operations. CS 4620 Lecture 14

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Pipeline Operations. CS 4620 Lecture 10

High-Quality Surface Splatting on Today s GPUs

Scan Conversion- Polygons

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Interpolation using scanline algorithm

(Refer Slide Time: 00:02:00)

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

The Traditional Graphics Pipeline

Topics and things to know about them:

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Filtering theory: Battling Aliasing with Antialiasing. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Pipeline implementation II

CS4620/5620: Lecture 14 Pipeline

Aliasing and Antialiasing. ITCS 4120/ Aliasing and Antialiasing

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Advanced Deferred Rendering Techniques. NCCA, Thesis Portfolio Peter Smith

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CS 432 Interactive Computer Graphics

CS 248 Assignment 2 Polygon Scan Converter. CS248 Presented by Abe Davis Stanford University October 17, 2008

The simplest and most obvious method to go from a continuous to a discrete image is by point sampling,

Graphics Pipeline 2D Geometric Transformations

Improved Deep Image Compositing Using Subpixel Masks

Programming Graphics Hardware

Graphics Hardware and Display Devices

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

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

Programmable Shaders for Deformation Rendering

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

The Traditional Graphics Pipeline

From Ver(ces to Fragments: Rasteriza(on


The Traditional Graphics Pipeline

Computer Graphics. Rendering. by Brian Wyvill University of Calgary. cpsc/enel P 1

CSCI 4620/8626. Computer Graphics Attributes of Graphics Primitives (Chapter 5)

Visibility: Z Buffering

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

CS 563 Advanced Topics in Computer Graphics Lecture 2: Bare-Bones Raytracer. by Emmanuel Agu

Lecture 9: Deferred Shading. Visual Computing Systems CMU , Fall 2013

CS 4620 Program 3: Pipeline

the gamedesigninitiative at cornell university Lecture 17 Color and Textures

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Einführung in Visual Computing

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Aliasing. Can t draw smooth lines on discrete raster device get staircased lines ( jaggies ):

A NEW ANTI-ALIASING ALGORITHM FOR COMPUTER GRAPHICS IMAGES

Order Independent Transparency with Dual Depth Peeling. Louis Bavoil, Kevin Myers

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

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

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

1 Introduction to Graphics

Advanced Shading I: Shadow Rasterization Techniques

Transcription:

Scan line algorithm The scan line algorithm is an alternative to the seed fill algorithm. It does not require scan conversion of the edges before filling the polygons It can be applied simultaneously to a set of polygons rather than filling each polygon individually. 320322: Graphics and Visualization 272

Scan line algorithm Use a horizontal scan line that traverses the scene top-down. Stop at each pixel row For each pixel row Compute the intersections of the polygon edges with the scan line. Sort the intersections from left to right. Start filling at first intersection. Stop filling at second intersection Start filling again at third intersection. 320322: Graphics and Visualization 273

Scan line algorithn Horizontal scan lines scan scene top-down and stop at each row: (x k, y k ) Scan Line y k (x k+1, y k+1 ) Scan Line y k+1 320322: Graphics and Visualization 274

Scan line algorithm Filling pixels between intersections in an alternating fashion: 320322: Graphics and Visualization 275

Scan line algorithm Example: 320322: Graphics and Visualization 276

Scan line algorithm Example: 320322: Graphics and Visualization 277

Data structure for scan line algorithm The scan line algorithm is supported by a linked list data structure that stores all the edges that are intersected by the current position of the scan line in the correct order. Linked list exploits spatial coherence between successive scan line positions. The order of the edges stored in the linked list only changes at distinct points (event points). 320322: Graphics and Visualization 278

Data structure for scan line algorithm Event points are: start/end of edge: insert/remove edge into sorted list. edge crossings: flip order of successive edges in sorted list. (Only in case of multiple polygons!) Start/end points are known from the beginning. Edge crossings are checked only between neighboring edges in the sorted list. It is necessary whenever a new neighborhood emerges, i.e., at event points. 320322: Graphics and Visualization 279

Caveats Scan line crossing vertex of polygon Distinguish two cases Case 1: 2 edges start -> remove intersection points Case 2: 1 edge starts & 1 ends -> treat as 1 intersection 1 2 1 Scan Line y 1 1 2 1 1 Scan Line y Horizontal edges Eliminate horizontal edge and treat neighboring vertices as above. 320322: Graphics and Visualization 280

3.4 Anti-aliasing 320322: Graphics and Visualization 281

Aliasing Observation: Scan converted objects exhibit discretization artifacts such as jagged edges (staircase effect). These artifacts are called aliasing. 320322: Graphics and Visualization 282

Anti-aliasing Anti-aliasing is a technique to alleviate the aliasing problem. Idea: Replace binary fill/no-fill decision with saturationbased filling. 320322: Graphics and Visualization 283

Anti-aliasing for each fragment of the framebuffer Compute the percentage, by which the fragment is covered by the edge. Fill the fragment with a color, whose saturation reflects the coverage percentage. Remark: In order to compute the coverage, one must assign a certain thickness to the edge. 320322: Graphics and Visualization 284

Anti-aliasing Example: When scan converting a black edge in front of a white background, the black edge will be drawn using grayscale colors. When scan converting a blue edge in front of a red background, the edge will be drawn using a color palette that successively mixes red and blue. 320322: Graphics and Visualization 285

Aliasing and anti-aliasing 320322: Graphics and Visualization 286

Anti-aliasing of polygonal meshes 320322: Graphics and Visualization 287

Anti-aliasing of entire scenes 320322: Graphics and Visualization 288

Moiré effect and anti-aliasing 320322: Graphics and Visualization 289

Coverage computation How do we compute the coverage? Geometrically: precise expensive fragment edge coverage = edge area / fragment area 6-sided polygon Speed is more important than accuracy -> compute an approximate solution! 320322: Graphics and Visualization 290

Supersampling anti-aliasing Idea: Sample each fragment multiple times. Determine at each sample position, whether the sample lies inside or outside the object. The percentage of samples lying inside the object approximates the coverage of that fragment by the object. 320322: Graphics and Visualization 291

Subpixel supersampling Divide each fragment into a number of subpixels. Apply standard scan conversion to subpixel image. Determine coverage as percentage of colored subpixels of each fragment. Fill the fragment with the edge color using the respective percentage as saturation. fragment subpixels scan conversion fragment with 75% saturation 320322: Graphics and Visualization 292

Subpixel supersampling Remarks: 2x2 or 4x4 subpixel supersampling are common. Sometimes a rotated subpixel grid is used (rotation by 45 ) to eliminate artifacts occurring for regular patterns (cf. Moiré effect). 320322: Graphics and Visualization 293

Stochastic supersampling Select a number a sample locations (pseudo-)randomly within each fragment. Perform an inside-outside test for each sample. Determine coverage as percentage of samples detected as lying inside the object. Fill the fragment with the edge color using the respective percentage as saturation. fragment stochastic sampling scan conversion fragment with 60% saturation 320322: Graphics and Visualization 294

Stochastic supersampling Remarks: Stochastic supersampling further decreases the risk of artifacts due to regular pattern. Its performance depends on the computation time for the inside/outside test. It is suitable for implicit surfaces. Example: For spheres one would only have to compare the distance of the sample to the sphere s center with its radius. 320322: Graphics and Visualization 295

Supersampling on shaded objects Average of inside/outside property at samples to obtain coverage percentage (as before). Average color property at samples to obtain color for fragment filling. 320322: Graphics and Visualization 296

Supersampling hardware implementations Subpixel supersampling (GeForce 2): Increased memory requirements. Multisampling anti-aliasing (GeForce 3): Use a mask with 5 or 9 samples to compute coverage. The mask determines the sampling pattern. Use only 2 or 4 of these samples to compute shaded color. Coverage sampling anti-aliasing (GeForce 8): Introducing coverage samples to compute coverage. Decouple shaded color samples and coverage samples. 320322: Graphics and Visualization 297

Supersampling hardware implementations no anti-aliasing multisampling (4x) coverage sampling (16x) 320322: Graphics and Visualization 298

Postfiltering anti-aliasing Alternative to supersampling anti-aliasing. Idea: Signal processing uses low-pass filtering for smoothing, which corresponds to local averaging. Approach: Scan convert many projected scenes, which are subpixel transformations of the original scene, and average the resulting images. 320322: Graphics and Visualization 299

Postfiltering anti-aliasing Scan conversion after subpixel transformation: (5 x + 1 x + 1 x ) / 7 = original + further translated images shifted vertically shifted horizontically post-filtered anti-aliased image 320322: Graphics and Visualization 300

Supersampling vs. post-filtering Post-filtering is applied to the entire scene equally, while supersampling can be applied locally to certain fragments. For example, supersampling can be restricted to only the silhouettes of an object to not blur surface parts. Post-filtering can deal with any geometry, i.e., explicit or implicit object representation, while supersampling is typically targeted at polygonal mesh representation. 320322: Graphics and Visualization 301

Anti-aliasing in OpenGL Removing the Jaggies glenable( mode ) GL_POINT_SMOOTH GL_LINE_SMOOTH GL_POLYGON_SMOOTH coverage computed by computing supersampling (subpixel approach). coverage stored in alpha channel of RGBA representation. 320322: Graphics and Visualization 302

Full scene antialiasing Implementation of post-filtering anti-aliasing Each time we move the viewer, the image shifts Different aliasing artifacts in each image Averaging images using accumulation buffer averages out these artifacts 320322: Graphics and Visualization 303

Blending Combine pixels with what s already in the framebuffer glblendfunc( src, dst ) v C r = src v C f + dst v C p Fragment (src) Framebuffer Pixel (dst) Blending Equation Blended Pixel 320322: Graphics and Visualization 304

Multi-pass rendering Blending allows results from multiple drawing passes to be combined together enables more complex rendering algorithms Example of bump-mapping done with a multi-pass OpenGL algorithm 320322: Graphics and Visualization 305

Accumulation Buffer Problems of compositing into color buffers limited color resolution clamping loss of accuracy Accumulation buffer acts as a floating point color buffer accumulate into accumulation buffer transfer results to frame buffer 320322: Graphics and Visualization 306

Accumulation Buffer glaccum( op, value ) operations within the accumulation buffer: GL_ADD, GL_MULT from read buffer: GL_ACCUM, GL_LOAD transfer back to write buffer: GL_RETURN glaccum(gl_accum, 0.5) multiplies each value in read buffer (specified by glreadbuffer()) by 0.5 and adds to accumulation buffer 320322: Graphics and Visualization 307