CS 248 Assignment 2 Polygon Scan Conversion. CS248 Presented by Michael Green Stanford University October 20, 2004

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

Triangle Rasterization

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Chapter 8: Implementation- Clipping and Rasterization

(Refer Slide Time: 00:02:00)

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

CS 4621 PPA3: Animation

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

Art-based Rendering with Graftals

CSC Computer Graphics

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

The Application Stage. The Game Loop, Resource Management and Renderer Design

CS 4620 Program 3: Pipeline

EF432. Introduction to spagetti and meatballs

Using Flash Animation Basics

Chapter 3. Sukhwinder Singh

4.5 VISIBLE SURFACE DETECTION METHODES

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Sign up for crits! Announcments

Graphics Hardware and Display Devices

Drawing Fast The Graphics Pipeline

CS 112 The Rendering Pipeline. Slide 1

COMP371 COMPUTER GRAPHICS

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

CS 283: Assignment 1 Geometric Modeling and Mesh Simplification

CS602 MCQ,s for midterm paper with reference solved by Shahid

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

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Principles of Computer Graphics. Lecture 3 1

CSC 418/2504 Computer Graphics, Winter 2012 Assignment 1 (10% of course grade)

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

CS 543: Computer Graphics. Rasterization

Scan Conversion of Polygons. Dr. Scott Schaefer

Graphics Pipeline 2D Geometric Transformations

CS 325 Computer Graphics

Scan Conversion. Drawing Lines Drawing Circles

Drawing Fast The Graphics Pipeline

CS488 2D Graphics. Luc RENAMBOT

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

Graphics (Output) Primitives. Chapters 3 & 4

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

Topic #1: Rasterization (Scan Conversion)

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

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

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

Max scene used to generate the image from the second pdf in this tutorial.

Adobe Flash CS3 Reference Flash CS3 Application Window

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

Hidden surface removal. Computer Graphics

CHAPTER 1 Graphics Systems and Models 3

Computer Graphics. - Rasterization - Philipp Slusallek

Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book

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

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

Computer Graphics Geometry and Transform

Open GL Framework For A Computer Graphics Course

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

Photoshop / Editing paths

CIS 441/541: Intro to Computer Graphics Lecture 6: transparency

Chapter 7 - Light, Materials, Appearance

Texture Mapping. Texture (images) lecture 16. Texture mapping Aliasing (and anti-aliasing) Adding texture improves realism.

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Rasterizing triangles

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

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.

CS 465 Program 5: Ray II

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

POWERVR MBX. Technology Overview

EF432. Introduction to spagetti and meatballs

Shadows in the graphics pipeline

This group is dedicated to Modeler tools for Layout s FiberFX hair and fur system. For the Layout interface and controls see FiberFX

CS 248 Assignment 1 Paint Program

CS 352: Computer Graphics. Hierarchical Graphics, Modeling, And Animation

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics 1/15

Intersecting Frame (Photoshop)

Drawing Fast The Graphics Pipeline

1 Preview. Dr. Scott Gordon Computer Science Dept. CSUS. Virtual Cameras, Viewing Transformations: CSc-155 Advanced Computer Graphics

Graphics and Interaction Rendering pipeline & object modelling

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

Let s see the use of each option available under create feature line window:

3D Rendering Pipeline (for direct illumination)

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

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

Computer Graphics I Lecture 11

CS1114 Assignment 5, Part 1

Using LightWave s Motion Blur to Achieve a Hand Drawn Line Effect:

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

Bforartists Reference Manual - Copyright - This page is under Public Domain. Editors

Bonus Ch. 1. Subdivisional Modeling. Understanding Sub-Ds

Maya 2014 NURBS Modeling Tutorial Airship

Shading Techniques Denbigh Starkey

lecture 16 Texture mapping Aliasing (and anti-aliasing)

Computer Graphics. Shadows

Direct Rendering of Trimmed NURBS Surfaces

How to draw and create shapes

About this document. Introduction. Where does Life Forms fit? Prev Menu Next Back p. 2

Transcription:

CS 248 Assignment 2 Polygon Scan Conversion CS248 Presented by Michael Green Stanford University October 20, 2004

Announcements First thing: read README.animgui.. It should tell you everything you need to know about the GUI. PLEASE post all questions to the PLEASE post all questions to the newsgroup 2

Getting Started Read the project handout carefully! http://graphics.stanford.edu/courses/cs248-04/proj2.html Get the assignment from /usr/class/cs248/assignments/assignment2/ README.files goes over details on building the project, what different source files do, and where to find examples. README.animgui explains what to do once the program is running. How to create polygons, load/save object files, and create animations (we ll go over most of this today too). 3

Development The interface is built using a cross platform library called GLUI. You won t need to change the interface unless you add features (extra credit). In that case, see the GLUI manual in /usr/class/cs248/assignments/assignment2/arc. You can develop and test this program on Windows or Mac, just make sure it works on the Linux machines in Sweet Hall! When we give you the sample images, don t worry about matching them exactly. Use the images to get an idea of correct behavior. 4

The Interface (The interface is described in detail in README.animgui) A few key points: (Shift + Left click) : add vertices. (Left click) : completes the polygon you re editing, or allows you to select and drag vertices. (Right click) : drag the whole polygon The program we give you already handles all the editing functionality, you just need to work on the rendering. When you re ready to see the scene, hit the Render button. (demo: editing) 5

Scan Conversion (Rasterization) The Algorithm (page 98 in Computer Graphics FvDFH second ed.) Create an Edge Table for the polygon being rendered, sorted on y. Don t include horizontal edges, they are handled by the edges they connect to (see page 95 in text). Note: xmin is the x at the minimum y for the edge, not necessarily the minimum x of the edge. Hence xmin = 7 for edge AB. (FvDFH, pages 92, 98) 6

Scan Conversion (cont.) Once you have your Edge Table (ET) for the polygon, you re ready to step through y coordinates and render scan lines: 1. Set y to the first non-empty bucket in the ET. This is bucket 1 in the example. 2. Initialize the Active Edge Table (AET) to be empty. The AET keeps track of which edges cross the current y scan line. 3. Repeat the following until the AET and ET are empty: 3.1 Add to the AET the ET entries for the current y.. (edges AB, BC in example) 3.2 Remove from the AET entries where y = ymax.. (none at first in example) Then sort the AET on x. (order: {AB, BC}) 3.3 Fill in pixel values on the y scan line using the x coordinates from the AET. Be wary of parity use the even/odd test to determine whether to fill (see next slide). 3.4 Increment y by 1 (to the next scan line). 3.5 For every non-vertical edge in the AET update x for the new y (calculate the next intersection of the edge with the scan line). Note: the algorithm in the book (presented here and in course lecture notes) attempts to fix the problems that occur when polygons share an edge, by not rasterizing the topt op-most row of pixels along an edge. 7

Active Edge Table Example Example of an AET containing edges {FA, EF, DE, CD} on scan line 8: 3.1: (y( = 8) Get edges from ET bucket y (none in this case, y = 8 has no entry) 3.2: Remove from the AET any entries where ymax = y (none here) 3.3: Draw scan line. To handle multiple edges, group in pairs: {FA,EF},{ {DE,CD} 3.4: y = y+1 (y( = 8+1 = 9) 3.5: Update x for non-vertical edges, as in simple line drawing. Y val Current X Slope (FvDFH pages 92, 99) 8

Active Edge Table Example (cont.) 3.1: (y = 9) Get edges from ET bucket y (none in this case, y = 9 has no entry in ET) Scan line 9 shown in fig 3.28 below 3.2: Remove from the AET any entries with ymax = y (remove FA, EF) 3.3: Draw scan line between {DE, CD} 3.4: y = y+1 y = 10 3.5: Update x in {DE, CD} 3.1: (y( y = 10) (Scan line 10 shown in fig 3.28 below) And so on Y val Current X Slope (FvDFH pages 92, 99) 9

Test Images Some cases you should test: (vertices added for illustration) Self-intersecting polygons, to test parity. Horizontal and Vertical edges. Edges that cross. (demo: rendering) 10

Antialiasing Scan conversion with super-sampling. sampling. How can we achieve this? Two possibilities: 1. Scan convert once to a super-sampled sampled grid, then average down. Cost: 1 scan conversion s 2 x p 2 storage, where there are (s x s) samples per pixel, (p x p) image s 2 x p 2 pixel writes 2. Perform many normal scan conversions at super-sampled sampled locations, and additively combine them. You will implement this method using an accumulation buffer (coming up). Cost: s 2 scan conversions 2p 2 storage s 2 x p 2 pixel writes (demo: overheads, program) 11

Motion Blur Synthesize the illusion that objects in our scene are moving quickly by blurring the image along the path of motion. Accomplished by interpolating between keyframes, meaning you define certain positions at certain times, and for times in between you calculate the position and direction of motion. Multiple images at different sample times are blurred (using the accumulation buffer), creating the illusion of motion. (demo: creating keyframes) (demo: motion blur.fli) 12

Accumulation Buffer Algorithm Allows us to successively render multiple scenes and have them additively blend as we go. Each image ends up with an equal weighting of 1/n, where n is the number of samples taken. (Appendix A in project 2 handout) Let "canvas" and "temp" be 24-bit pixel arrays. Let "polygon color" be a 24-bit color unique to each polygon. 1 clear canvas to black; 2 n = 0 (number of samples taken so far) 3 for (i=1; i<=s; i++) (for s subpixel positions) 4 for (j=1; j<=t; j++) (for t fractional frame times) 5 clear temp to black 6 n = n + 1 7 for each polygon 8 translate vertices for this subpixel position and fractional frame time 9 for each pixel in polygon (using your scan converter) r) 10 temp color <--< polygon color 11 for each pixel in canvas 12 canvas color <--< canvas color + temp color 13 canvas color <--< canvas color / n 14 convert canvas to 8x3 bits and display on screen (by exiting from your rasterizer) 13

Accumulation Buffer (cont.) Example (with overlap): 14

Accumulation Buffer (cont.) Question: Why should we render all polygons at once per frame (lines 7-10), 7 why not antialias the objects separately and then blend their images together? Answer: Polygons on a perfect mesh over a colored background will show some of the background color. Rendering the polygons together prevents any unwanted blending. 15

Extra Credit (Extra Credit is fun!!!) 1. Extend the interface to allow interactive scaling and rotations of polygons around a chosen point. Using matrices is one way 2. Extend the interface to allow insertion and deletion of vertices in an already-defined defined polygon. Not hard mathematically, but think of usability as well. 3. Allow the number of vertices in a polygon to be different at any keyframe. Example: square to house. 16

Extra Credit (cont.) 4. Extend the interface to allow the input of polygons with curved boundaries. Curve is approximated by lots of closely spaced vertices that are a still linearly connected. Not too tough, add vertices along mouse e path while mouse button is down. 5. Combine #3 and #4 to allow different curved boundaries for each keyframe. Calculate approximate locations for vertices when the number changes. For example, going from a curve with 10 vertices to one with 4, calculate points along the 4-vertex 4 curve at 1/10 intervals. Or come up with a better scheme. 6. Replace linear interpolation with splined interpolation to create smoother transitions between keyframes. Refer to section 21.1.3 in text for more info. Consider cubic B-splinesB (section 11.2.3). 17

Extra Credit (cont.) 7. Define a skeleton of connected line segments, and replace (x,y( x,y) coordinates of vertices with (u,v( u,v) ) offsets from skeleton. Interpolate the skeleton, then use the offsets to calculate vertex positions. (draw sketch) 8. Implement polygon clipping. Scissoring means not sending pixel values to the canvas when they would be out of bounds (this is the required functionality). Full clipping means trimming the edge of the polygon so it fits within the screen, which can greatly reduce the time spent performing rasterization. scissoring clipping 18

Extra Credit (cont.) 9. Implement unweighted area sampling (section 3.17.2 and earlier slide) as a user selectable alternative to accumulation buffer antialiasing (you must still implement accumulation buffer). For even more fun, implement weighted area sampling (section 3.17.3). 10. Create a cool animation and show it at the demo! 19

Development Tips Your canvas has (0,0) at the top left, with (canvaswidth-1, canvasheight-1) at bottom right. Examples in book have (0,0) at bottom left. Doesn t change too much, just be aware. If you are comfortable using them, you might find the C++ standard templates useful (especially sorted lists) for handling lists in your edge table. Alternatively, you might want to write your own class or functions ns to handle this. 20

Questions? 21