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

Similar documents
Clipping and Scan Conversion

lecture 16 Texture mapping Aliasing (and anti-aliasing)

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

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

Chapter 8: Implementation- Clipping and Rasterization

3D Rendering Pipeline (for direct illumination)

Set the Viewport. Set the Viewport Clipping. Set the Viewport. Set the Viewport. Set the Viewport. Resizing the Viewport W = H

CS488 2D Graphics. Luc RENAMBOT

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

Realtime 3D Computer Graphics Virtual Reality

From 3D World to 2D Screen. Hendrik Speleers

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

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

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

Topics. From vertices to fragments

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

Rasterization. COMP 575/770 Spring 2013

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

1 Introduction to Graphics

CS 543: Computer Graphics. Rasterization

Computer Graphics Geometry and Transform

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

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

Clipping Points Consider a clip window which is rectangular in shape. P(x, y) is a point to be displayed.

Examples. Clipping. The Rendering Pipeline. View Frustum. Normalization. How it is done. Types of operations. Removing what is not seen on the screen

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

Scan Converting Lines

CS4620/5620: Lecture 14 Pipeline

The Traditional Graphics Pipeline

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

UNIT -8 IMPLEMENTATION

2D Viewing. Viewing Pipeline: Window-Viewport Transf.

Line Drawing. Foundations of Computer Graphics Torsten Möller

The Traditional Graphics Pipeline

Lecture 7 of 41. Viewing 4 of 4: Culling and Clipping Lab 1b: Flash Intro

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

Computer Graphics and GPGPU Programming

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

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Sung-Eui Yoon ( 윤성의 )

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

Einführung in Visual Computing

The Traditional Graphics Pipeline

Topic #1: Rasterization (Scan Conversion)

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

COMP371 COMPUTER GRAPHICS

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

Rasterization: Geometric Primitives

Computer Graphics. - Rasterization - Philipp Slusallek

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

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

From Vertices To Fragments-1

CSE328 Fundamentals of Computer Graphics

Triangle Rasterization

From Ver(ces to Fragments: Rasteriza(on

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

Chapter - 2: Geometry and Line Generations

Computer Graphics Geometry and Transform

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

Clipping Lines. Dr. Scott Schaefer

Set the Viewport Clipping. Computer Graphics CSC470 1

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

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

Two-Dimensional Viewing. Chapter 6

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

Part IV. 2D Clipping

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

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

CS475m - Computer Graphics. Lecture 1 : Rasterization Basics

CS 325 Computer Graphics

E.Order of Operations

Rasterization. CS4620 Lecture 13

Computer Graphics Fundamentals. Jon Macey

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Scalar Field Visualization I

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

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

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

More on Coordinate Systems. Coordinate Systems (3) Coordinate Systems (2) Coordinate Systems (5) Coordinate Systems (4) 9/15/2011

Transformation Pipeline

Graphics Pipeline 2D Geometric Transformations

Pipeline and Rasterization. COMP770 Fall 2011

Clipping Algorithms; 8-5. Computer Graphics. Spring CS4815

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

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

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Pipeline Operations. CS 4620 Lecture 14

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

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

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

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

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

Pipeline Operations. CS 4620 Lecture 10

Transcription:

Lecture 6 Last class Last lecture (clip coordinates): A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization normalized view volume projective transform followed by normalization w > 0 - w <= w x <= w - w <= w y <= w - w <= w z <= w Terminology: clipping vs. culling 3D Line Clipping 2D Line Clipping (simpler to discuss) Any object that lies entirely outside the view volume doesn't need to be drawn. Such objects can "culled". Any object that lies partly outside the view volume needs to be "clipped". Today, "clipping" refers to both of these. Q: Given endpoints (x0, y0, z0), (x1, y1, z0), how to check if the line segment needs to be clipped? i.e. either discarded, or modified to lie in volume Q: Given endpoints (x0, y0), (x1, y1), how to check if the line segment needs to be clipped? Q: Given endpoints (x0, y0), (x1, y1), how to check if the line segment needs to be clipped? To check if a line segment intersects a boundary e.g. x=1, solve for t: t (x0, y0) + (1 - t) (x1, y1) = 1 and check if 0 <= t <= 1. 3 cases of interest: the line may be... - entirely outside of view volume - entirely in view volume - partly in view volume This line can be "trivially rejected" since the endpoint x values are both less than -1.

Cohen-Sutherland (1965) encoded the above rules : For each vertex, compute the outcode. This line can be "trivially accepted" since the endpoint x and y values are all between -1 and 1. x= -1 x= 1 y=1 y= -1 Trivially reject a line segment if bitwiseand (, ) contains a 1. Trivially accept a line segment if bitwiseor (, ) == 0000. In both cases below, we can neither trivially accept nor reject. Outcodes are the same in the two cases. What if we cannot trivially accept or reject? If we cannot trivially accept or reject, then the line must cross one of x=1, x=-1, y=1, or y = -1. clipping required (line modification) reject (non-trivial ) Q: what is the logic condition for this general case? A: bitwisexor(, ) is not 0000 Cohen-Sutherland: consider the bits b3, b2, b1, b0 such that XOR( b, b') = 1. Modify/clip the line segment to remove the offending part. Example: First clip line segment so that b3 = 0 for both outcodes. Then, clip line segment so that b2= 0 for both outcodes. Then, clip line segment so that b1= 0 for both outcodes.

Typically we don't need to do all four clips before trivially rejecting. Then, clip line segment so that b0 = 0 for both outcodes. And we're done... trivial accept! Cohen-Sutherland line clipping in 3D: (exactly the same idea but the outcodes have 6 bits) By the way... If we didn't do a projective transformation and map to normalized view volume, we could still compute outcodes and do line clipping, but it wouldn't be as easy. Algorithms for clipping polygons (SKIP!) reject (cull) clip accept Recall: OpenGL clips in (4D) 'clip coordinates' (w x, w y, w z, w) not in (3D) 'normalized device coordinates' (x, y, z ). We can compute outcodes in clip coordinates easily. But the line clipping is tricky in clip coordinates. Why? Exercise (surprising): Clipping based on 4D interpolation works! w x x=1 Recall from lecture 2: The above was an abuse of notation. It was meant to express that:

The issue for clipping is whether the following interpolation scheme can be used. The answer is yes, but it requires some thought to see why. Lecture 6 clipping windowing and viewport scan conversion / rasterization What is a "window"? Two meanings: - region of display screen (pixels) that you can drag and resize. Also known as "display window". - region of the near plane in camera coordinates. Also known as "viewing window". glutcreatewindow('comp557 A1') glutinitwindowsize(int width, int height) glutinitwindowposition(int x, int y) glutreshapewindow(int width, int height) glutpositionwindow(int x, int y) What is a "viewport"? glviewport(int x, int y, int width, int height) A viewport is a region within a display window. (The default viewport is the whole window.) display window two viewports normalized view volume (display) window "window to viewport" transformation (2D viewing) window to (2D) viewport We've finally arrived at pixels! How do we convert our floating point (continuous) primitives into integer locations (pixels)? Lecture 6 clipping windowing and viewport scan conversion / rasterization What is a pixel? Sometimes it is a point (intersection of grid lines). Sometimes it is a little square.

"Scan Conversion" ("Rasterization") e.g. Scan Converting a Line Segment? - convert a continuous representation of an object such as a point, line segment, curve, triangle, etc into a discrete (pixel) representation on a pixel grid - why "scan"? In this illustration, pixels are intersections of grid lines (not little squares). The endpoints of the line segment may be floats. Algorithm: scan convert a line segment from (x0, y0) to (x1, y1) What if slope m is greater than 1? Scan converting (filling) a Polygon m = (y1 - y0) / (x1 - x0) y = y0 // slope of line for x = round(x0) to round(x1) writepixel(x, Round(y), rgbvalue) y = y + m Iterating over x leaves gaps (bad) Iterating over y fills gaps (good) Scan converting (filling) a Polygon Scan converting a polygon (Sketch only) ymin = round( min of y values of vertices) ymax = round( max of y values of vertices) for y = ymin to ymax compute intersection of polygon edges with row y fill in pixels between adjacent pairs of edges i.e. (x, y) to (x', y), (x'', y) to (x''', y),... where x < x' < x'' < x''' <...