polygon clipping

15

Upload: vikas-sharma

Post on 22-May-2015

2.993 views

Category:

Education


2 download

DESCRIPTION

Computer Graphics

TRANSCRIPT

Page 1: Polygon clipping
Page 2: Polygon clipping

•Clipping Any procedure which identifies that portion of a picture which is either inside or outside a picture is referred to as a clipping algorithm or clipping.In geometry a polygon is a flat shape consisting of straight lines that are joined to form a circuit. A polygon is traditionally a plane figure that is bounded by a closed path, composed of a finite sequence of straight line segments (i.e., by a closed polygonal chain). These segments are called its edges or sides, and the points where two edges meet are the polygon's vertices. The interior of the polygon is sometimes called its body.

Page 3: Polygon clipping

The region against which an object is to be clipped is called clipping window.Clipping is required to specify a localized view along with the convenience and the flexibility of using a window ,because objects in the scene may be completely inside the window, completely outside the window, or partially visible through the window. The Clipping operation eliminates objects or portions of objects that are not visible through the window to ensure the paper construction image.

Page 4: Polygon clipping

•Polygon ClippingA polygon boundary processed with a line clipper may be displayed as a series of unconnected line segments,depending on the orientation of the polygon to the clipping window. What we really want to display is a bounded area after clipping. For polygon clipping, we require an algorithm that will generate one or more closed areas that are then scan converted for the appropriate area fill. The output of a polygon clipper should be a sequence of vertices that defines the clipped polygon boundaries. In 2D graphics for example, if the user of an image editing program is modifying an image and has "zoomed in" the view to display only the top half of the image, there is no need for the program to spend any CPU time doing any of the calculations or memory moves needed to display the bottom half. By clipping the bottom half of the image and avoiding these calculations, the program runs faster.

Page 5: Polygon clipping
Page 6: Polygon clipping

•Sutherland–Hodgeman algorithmThe Sutherland–Hodgeman algorithm is used for clipping polygons. It works by extending each line of the convex clip polygon in turn and selecting only vertices from the subject polygon that are on the visible side

Input each edge (vertex pair) successively.Output is a new list of vertices.Each edge goes through 4 clippers.The rule for each edge for each clipper is:

If first input vertex is outside, and second is inside, output the intersection and the second vertexIf first both input vertices are inside, then just output second vertexIf first input vertex is inside, and second is outside, output is the intersectionIf both vertices are outside, output is nothing

Page 7: Polygon clipping

v1

v2v3

v1’

v2v3”

v1”

v3’

Note: Need to consider each of 4 edge boundaries

Page 8: Polygon clipping

outside inside

v1v1’

v2

outside inside

v1

v2

outside inside

v1v1’

v2

outside inside

v1

v2

Outside to inside:Output: v1’ and v2

Inside to inside:Output: v2

Inside to outside:Output: v1’

Outside to outside:Output: nothing

Page 9: Polygon clipping

v2

v1

v3

Right Clipper

Bottom Clipper

Top Clipper

Left Clipper

v1v2

v2v3

v3v1

v1’

v2

v2’

v2’

v3’v1

v2v2’

v2’v3’

v3’v1

v1v2

v2’

v3’

v1

v2 v2v2’

v2’v3’

v3’v1

v1v2

v3’

Figure 6-27, page 332

v2”

v1’v2

v2’ v2’v2”

v2”v1’

v1’v2

v2v2’

v1’

v2

v2’

v2”

Edges Output Edges Output Edges Output Edges Output

Final

Page 10: Polygon clipping

•Weiler- Atherton Polygon ClippingIn this algorithm,the vertex –processing procedures for window boundaries are modified so that concave polygons are displayed correctly. This clipping procedure was developed as a method for identifying visible surfaces,and so it can be applied with arbitrary polygon-clipping regions.The basic idea in this algorithm is that instead of always proceeding around the polygon edges as vertices are processed,we sometimes want to follow the window boundaries .Which path we follow depend on the polygon-processing direction(clockwise or counterclockwise)

Page 11: Polygon clipping
Page 12: Polygon clipping
Page 13: Polygon clipping

Sutherland-Hodgman

Weiler-Atherton

Page 14: Polygon clipping

•Importance of clipping in video gamesGood clipping strategy is important in the development of video games in order to maximize the game's frame rate and visual quality. Despite GPU chips that are faster every year, it remains computationally expensive to transform, texture, and shade polygons, especially with the multiple texture and shading passes common today To maximize the game's visual quality, developers prefer to establish the highest possible polygon budget; therefore, every optimization of the graphics pipeline benefits the polygon budget and therefore the game. In video games, then, clipping is a critically important optimization that speeds up the rendering of the current scene, and therefore allows the developer to increase the renderer's polygon budget.

Page 15: Polygon clipping