Lecture 2: Digital Drawing. Computer Graphics and Imaging UC Berkeley CS184/284

Similar documents
Drawing a Triangle (and an introduction to sampling)

Drawing a Triangle (and an Intro to Sampling)

Parallel Triangle Rendering on a Modern GPU

Pipeline Operations. CS 4620 Lecture 10

Pipeline Operations. CS 4620 Lecture 14

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

Intro to Ray-Tracing & Ray-Surface Acceleration

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

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

Lecture 4: Visibility. (coverage and occlusion using rasterization and the Z-buffer) Visual Computing Systems CMU , Fall 2014

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

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

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

CS 130 Final. Fall 2015

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

CS 4300 Computer Graphics. Prof. Harriet Fell Fall 2012 Lecture 5 September 13, 2012

EF432. Introduction to spagetti and meatballs

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

CS4620/5620: Lecture 14 Pipeline

EF432. Introduction to spagetti and meatballs

The Rasterization Pipeline

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

Computer Graphics. - Rasterization - Philipp Slusallek

CS 130 Exam I. Fall 2015

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

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

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

The Traditional Graphics Pipeline

Rasterization. CS4620 Lecture 13

CS 130 Exam I. Fall 2015

The Traditional Graphics Pipeline

CS Rasterization. Junqiao Zhao 赵君峤

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

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

The Traditional Graphics Pipeline

Graphics Hardware and Display Devices

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Chapter 8: Implementation- Clipping and Rasterization

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Graphics Systems and Models

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

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

CPSC GLOBAL ILLUMINATION

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

Head Mounted Display Optics I!

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

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

lecture 16 Texture mapping Aliasing (and anti-aliasing)

CS 543: Computer Graphics. Rasterization

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

Fundamentals of Computer Graphics. Lecture 3 Generate a simple shape using OpenGL. Yong-Jin Liu

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

Graphics Pipeline 2D Geometric Transformations

Topic #1: Rasterization (Scan Conversion)

History of computer graphics

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

Triangle Rasterization

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

CS488 2D Graphics. Luc RENAMBOT

1. (10 pts) Order the following three images by how much memory they occupy:

Hidden surface removal. Computer Graphics

Computer Graphics 1 Instructor Information. Books. Graphics? Course Goals and Outcomes. Where are computer graphics? Where are computer graphics?

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

(Refer Slide Time: 0:32)

Pipeline and Rasterization. COMP770 Fall 2011

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

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

CS5620 Intro to Computer Graphics

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

The Rasterization Pipeline

Lecture 9: Hough Transform and Thresholding base Segmentation

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

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

Lecture 10: Shading Languages. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

Scan Conversion. Drawing Lines Drawing Circles

CS 431/636 Advanced Rendering Techniques

Line Drawing. Foundations of Computer Graphics Torsten Möller

RASTERIZING POLYGONS IN IMAGE SPACE

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Scan Conversion- Polygons

Direct Rendering of Trimmed NURBS Surfaces

Raytracing CS148 AS3. Due :59pm PDT

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

U.C. Berkeley, EECS, Computer Science TAKE HOME EXAM. Your Class Computer Account: DO NOT OPEN THIS INSIDE SODA HALL -- WAIT UNTIL YOU ARE ALONE!

Chapter - 2: Geometry and Line Generations

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

Mattan Erez. The University of Texas at Austin

1 Introduction to Graphics

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

Intro to OpenGL II. Don Fussell Computer Science Department The University of Texas at Austin

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

N-Views (1) Homographies and Projection

From 3D World to 2D Screen. Hendrik Speleers

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

Real-Time Graphics Architecture

CS602- Computer Graphics Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring 2013 CS602- Computer Graphics

Transcription:

Lecture 2: Digital Drawing Computer Graphics and Imaging UC Berkeley CS184/284

Today: Rasterizing Triangles into Pixels Life of Pi (2012)

Drawing Machines

CNC Sharpie Drawing Machine Aaron Panone with Matt W. Moore http://44rn.com/projects/numerically-controlled-poster-series-with-matt-w-moore/

Laser Cutters

Oscilloscope

Cathode Ray Tube

Oscilloscope Art Jerobeam Fenderson https://www.youtube.com/watch?v=rtr63-ecuno

Television - Raster Display CRT Cathode Ray Tube Raster Scan (modulate intensity)

Frame Buffer: Memory for a Raster Display

A Sampling of Different Raster Displays

Flat Panel Displays Low-Res LCD Display Color LCD, OLED, B.Woods, Android Pit

LCD (Liquid Crystal Display) Pixel Principle: block or transmit light by twisting polarization Illumination from backlight (e.g. fluorescent or LED) [H&B fig. 2-16] Intermediate intensity levels by partial twist

LED Array Display Light emitting diode array

DMD Projection Display [Y.K. Rabinowitz; EKB Technologies

DMD Projection Display [Texas Instruments] Array of micro-mirror pixels DMD = Digital Micromirror Device

Electrophoretic (Electronic Ink) Display [Wikimedia Commons Senarclens]

Drawing to Raster Displays

Polygon Meshes Life of Pi (2012)

Triangle Meshes

Triangle Meshes

Shape Primitives 3dgep.com Example shape primitives (OpenGL)

Graphics Pipeline = Abstract Drawing Machine

Triangles - Fundamental Area Primitive Why triangles? Most basic polygon Break up other polygons Optimize one implementation Triangles have unique properties Guaranteed to be planar Well-defined interior Well-defined method for interpolating values at vertices over triangle (barycentric interpolation)

Drawing a Triangle To The Framebuffer ( Rasterization )

What Pixel Values Approximate a Triangle? (2.2, 1.3) (4.4, 11.0) (15.3, 8.6)? Input: position of triangle vertices projected on screen Output: set of pixel values approximating triangle

Today, Let s Start With A Simple Approach: Sampling

Sampling a Function Evaluating a function at a point is sampling. We can discretize a function by periodic sampling. for( int x = 0; x < xmax; x++ ) output[x] = f(x); Sampling is a core idea in graphics. We ll sample time (1D), area (2D), angle (2D), volume (3D) We ll sample N-dimensional functions, even infinite dimensional functions.

Let s Try Rasterization As 2D Sampling

Sample If Each Pixel Center Is Inside Triangle

Sample If Each Pixel Center Is Inside Triangle

Define Binary Function: inside(tri,x,y) 1 (x,y) in triangle t inside(t,x,y) = 0 otherwise

Rasterization = Sampling A 2D Indicator Function for( int x = 0; x < xmax; x++ ) for( int y = 0; y < ymax; y++ ) Image[x][y] = f(x + 0.5, y + 0.5); Rasterize triangle tri by sampling the function f(x,y) = inside(tri,x,y)

Implementation Detail: Sample Locations (0,0) (w,0) (x+1/2,y+1/2) (0,h) (w,h) Sample location for pixel (x,y)

Evaluating inside(tri,x,y)

Triangle = Intersection of Three Half Planes P 2 P 1 P 0

Each Line Defines Two Half-Planes Implicit line equation L(x,y) = Ax + By + C On line: L(x,y) = 0 Above line: L(x,y) > 0 Below line: L(x,y) < 0 > 0 = 0 < 0

Line Equation Derivation Line Tangent Vector P 1 T P 0 T = P 1 P 0 =(x 1 x 0,y 1 y 0 )

Line Equation Derivation (-y,x) General Perpendicular Vector in 2D (x,y) Perp(x, y) =( y, x)

Line Equation Derivation N Line Normal Vector P 1 T P 0 N =Perp(T )=( (y 1 y 0 ),x 1 x 0 )

Line Equation Derivation N P = (x, y) V P 1 P 0 V = P P 0 =(x x 0,y y 0 )

Line Equation N P = (x, y) V P 1 P 0 L(x, y) =V N = (x x 0 )(y 1 y 0 )+(y y 0 )(x 1 x 0 )

Line Equation Tests N P V P 1 P 0 L(x, y) =V N>0

Line Equation Tests N P P 1 V P 0 L(x, y) =V N =0

Line Equation Tests N P 1 V P 0 P L(x, y) =V N<0

Point-in-Triangle Test: Three Line Tests Pi = (Xi, Yi) P 2 dxi = Xi+1 - Xi dyi = Yi+1 - Yi Li (x, y) = (x - Xi) dyi + (y - Yi) dxi = Ai x + Bi y + Ci Li (x, y) = 0 : point on edge < 0 : outside edge > 0 : inside edge P 1 Compute line equations from pairs of vertices P 0

Point-in-Triangle Test: Three Line Tests Pi = (Xi, Yi) P 2 dxi = Xi+1 - Xi dyi = Yi+1 - Yi Li (x, y) = (x - Xi) dyi + (y - Yi) dxi = Ai x + Bi y + Ci Li (x, y) = 0 : point on edge < 0 : outside edge > 0 : inside edge P 1 P 0 L0(x, y) > 0

Point-in-Triangle Test: Three Line Tests Pi = (Xi, Yi) P 2 dxi = Xi+1 - Xi dyi = Yi+1 - Yi Li (x, y) = (x - Xi) dyi + (y - Yi) dxi = Ai x + Bi y + Ci Li (x, y) = 0 : point on edge < 0 : outside edge > 0 : inside edge P 1 P 0 L1(x, y) > 0

Point-in-Triangle Test: Three Line Tests Pi = (Xi, Yi) P 2 dxi = Xi+1 - Xi dyi = Yi+1 - Yi Li (x, y) = (x - Xi) dyi + (y - Yi) dxi = Ai x + Bi y + Ci Li (x, y) = 0 : point on edge < 0 : outside edge > 0 : inside edge P 1 P 0 L2(x, y) > 0

Point-in-Triangle Test: Three Line Tests Sample point s = (sx, sy) is inside the triangle if it is inside all three lines. P 2 inside(sx, sy) = L0 (sx, sy) > 0 && L1 (sx, sy) > 0 && L2 (sx, sy) > 0; Note: actual implementation of inside(sx,sy) involves checks based on edge rules P 0 P 1

Edge Cases (Literally) Is this sample point covered by triangle 1, triangle 2, or both? 2 1

OpenGL/Direct3D Edge Rules When sample point falls on an edge, the sample is classified as within triangle if the edge is a top edge or left edge Top edge: horizontal edge that is above all other edges Left edge: an edge that is not exactly horizontal and is on the left side of the triangle. (triangle can have one or two left edges) Source: Direct3D Programming Guide, Microsoft

Incremental Triangle Traversal (Faster?) P2 P1 P0

Modern Approach: Tiled Triangle Traversal Traverse triangle in blocks P2 Test all samples in block in parallel Advantages: - Simplicity of wide parallel execution overcomes cost of extra point-in-triangle tests (most triangles cover many samples, especially when super-sampling) - Can skip sample testing work: entire block not in triangle ( early out ), entire block entirely within triangle ( early in ) P1 All modern GPUs have special-purpose hardware for efficient point-in-triangle tests P0

Signal Reconstruction on Real Displays

Real LCD Screen Pixels (Closeup) iphonearena.com iphonearena.com iphone 6S Galaxy S5 Notice R,G,B pixel geometry! But in this class, we will assume a colored square full-color pixel.

Aside: What About Other Display Methods? Color print: observe half-tone pattern

Assume Display Pixels Emit Square of Light Each image sample sent to the display is converted into a little square of light of the appropriate color: (a pixel = picture element) LCD pixel on laptop * LCD pixels do not actually emit light in a square of uniform color, but this approximation suffices for our current discussion

So, If We Send The Display This Sampled Signal

The Display Physically Emits This Signal

Compare: The Continuous Triangle Function

What s Wrong With This Picture? Jaggies!

Jaggies (Staircase Pattern) Is this the best we can do?

Discussion: What Value Should a Pixel Have? Potential topics for your pair discussion: Ideas for higher quality pixel formula? What are all the relevant factors? What s right/wrong about point sampling? Why do jaggies look wrong?

Things to Remember Drawing machines Many possibilities Why framebuffers and raster displays? Why triangles? We posed rasterization as a 2D sampling process Test a binary function inside(triangle,x,y) Evaluate triangle coverage by 3 point-in-edge tests Finite sampling rate causes jaggies artifact (next time we will analyze in more detail)

Acknowledgments Thanks to Kayvon Fatahalian, Pat Hanrahan, Mark Pauly and Steve Marschner for slide resources.