Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.

Similar presentations


Presentation on theme: "Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal."— Presentation transcript:

1 Lecture 9 From Vertices to Fragments

2 Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal

3 Basic implementation strategies In computer graphics, we start with an application program, and we end with an image. We can consider this process as a black box whose inputs are the vertices and states de fi ned in the program—geometric objects, attributes, camera speci fi cations—and whose output is an array of colored pixels in the frame buffer.

4 Required Tasks There are four major tasks that any graphics system must perform to render a geometric entity, such as a three- dimensional polygon, as that entity passes from de fi nition in a user program to possible display on an output device: 1. Modeling 2. Geometry processing 3. Rasterization 4. Fragment processing

5 . Figure 6.3 shows how these tasks might be organized in a pipeline implementation. Regardless of the approach, all four tasks must be carried out.

6 Modeling The usual results of the modeling process are sets of vertices that specify a group of geometric objects supported by the rest of the system. We can look at the modeler as a black box that produces geometric objects and is usually a user program.

7 . There are other tasks that the modeler might perform, for example, clipping: the process of eliminating parts of objects that cannot appear on the display because they lie outside the viewing volume.

8 Geometry processing Geometry processing works with vertices. The goals of the geometry processor are to determine which geometric objects can appear on the display and to assign shades or colors to the vertices of these objects. Four processes are required: projection, primitive assembly, clipping, and shading.

9 Geometry processing The fi rst step in geometry processing is to change representations from object coordinates to camera or eye coordinates using the model-view transformation. The second step is to transform vertices using the projection transformation from VCS (View Coordinates System) to a NDCS (Normalized Device Coordinates System ) in which objects that might be visible are contained in a cube centered at the origin. Vertices are now represented in clip coordinates

10 Geometry processing Geometric objects are transformed by a sequence of transformations that may reshape and move them (modeling) or may change their representations (viewing).

11 front-end processing View volume primitives that fi t within a speci fi ed volume, and can appear on the display after rasterization. primitive assembly The process of grouping vertices into objects before clipping can take place.

12 front-end processing hidden-surface removal Note that even though an object lies inside the view volume, it will not be visible if it is obscured by other objects. Algorithms for hidden-surface removal or visible-surface determination are based on the three- dimensional spatial relationships among objects. This step is normally carried out as part of fragment processing.

13 Rasterisation Rasterisation is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (pixels or dots) for output on a video display or printer, or for storage in a bitmap file format. It the transformation of geometric primitives (line segments, circles, polygons) into a raster image representation, i. e. pixel positions the estimation of an appropriate set of pixel positions to represent a geometric primitive.

14 Clipping The process of determining which primitives, or parts of primitives, fi t within the clipping or view volume de fi ned by the application program. We shall concentrate on clipping of line segments and polygons because they are the most common primitives to pass down the pipeline.

15 Line-segment clipping A clipper decides which primitives, or parts of primitives, can possibly appear on the display and be passed on to the rasterizer. Primitives that fi t within the speci fi ed view volume pass through the clipper, or are accepted. Primitives that cannot appear on the display are eliminated, or rejected or culled. Primitives that are only partially within the view volume must be clipped such that any part lying outside the volume is removed.

16 Clipping Easy for line segments and polygons Hard for curves and text Convert to lines and polygons first

17 Clipping 2D Line Segments Brute force approach: compute intersections with all sides of clipping window Inefficient: one division per intersection

18 Line Clipping Line clipping operations should comprise the following cases: Totally plotted. Partially plotted. Not plotted at all

19 Line Clipping Note that even though neither of two vertices is within the window, certain part of the line segment may be still within. There are many different techniques for clipping line in 2D: The fundamental are : 1-Line equation 2-Intersection computation Next we will discuss Cohen-Sutherland Algorithm.

20 Cohen-Sutherland Algorithm It is not the most efficient algorithm. It is the most commonly used. The key technique is 4 bit code TBRL where: T is set (to 1 ) if y > top B is set (to 1 ) if y < Bottom R is set (to 1 ) if x > right L is set (to 1 ) if x < left

21 Cohen-Sutherland Algorithm 21 Idea: eliminate as many cases as possible without computing intersections Start with four lines that determine the sides of the clipping window x = x max x = x min y = y max y = y min

22 The Cases 22 Case 1: both endpoints of line segment inside all four lines Draw (accept) line segment as is Case 2: both endpoints outside all lines and on same side of a line Discard (reject) the line segment x = x max x = x min y = y max y = y min

23 The Cases 23 Case 3: One endpoint inside, one outside Must do at least one intersection Case 4: Both outside May have part inside Must do at least one intersection x = x max x = x min y = y max

24 Defining Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 24 The first bit is set to 1 if the point is above the viewport eg 1001 The Second bit is set to 1 if the point is under the viewport eg 0101 The third bit is set to 1 if the point is right the viewport eg 0010 The forth bit is set to 1 if the point is left the viewport eg 0001

25 Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 25 Consider the 5 cases below AB: outcode(A) = outcode(B) = 0 Accept line segment

26 Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 26 CD: outcode (C) = 0, outcode(D)  0 Compute intersection Location of 1 in outcode(D) determines which edge to intersect with Note if there were a segment from A to a point in a region with 2 ones in outcode, we might have to do two interesections

27 Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 27 EF: outcode(E) logically ANDed with outcode(F) (bitwise)  0 Both outcodes have a 1 bit in the same place Line segment is outside of corresponding side of clipping window reject

28 Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 28 GH and IJ: same outcodes, neither zero but logical AND yields zero Shorten line segment by intersecting with one of sides of window Compute outcode of intersection (new endpoint of shortened line segment) Re-execute algorithm

29 Efficiency Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 29 In many applications, the clipping window is small relative to the size of the entire data base Most line segments are outside one or more sides of the window and can be eliminated based on their outcodes Inefficiency when code has to be re-executed for line segments that must be shortened in more than one step

30 Cohen Sutherland in 3D Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 30 Use 6-bit outcodes When needed, clip line segment against planes

31 Polygon Clipping Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 31 Not as simple as line segment clipping Clipping a line segment yields at most one line segment Clipping a polygon can yield multiple polygons However, clipping a convex polygon can yield at most one other polygon

32 Pipeline Clipping of Polygons Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 32 Three dimensions: add front and back clippers Strategy used in SGI( Silicon Graphics International) Geometry Engine. Small increase in latency

33 Bounding Boxes Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 33 Rather than doing clipping on a complex polygon, we can use an axis-aligned bounding box or extent Smallest rectangle aligned with axes that encloses the polygon Simple to compute: max and min of x and y

34 Bounding Boxes 34 Can usually determine accept/reject based only on bounding box reject accept requires detailed clipping


Download ppt "Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal."

Similar presentations


Ads by Google