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.
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.
Polygon Clipping
A 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
SutherlandHodgeman algorithm
The SutherlandHodgeman 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 vertex
If first both input vertices are inside, then just output second vertex
If first input vertex is inside, and second is outside, output is the
intersection
If both vertices are outside, output is nothing
v1
v1
v1
v3
v2
v3
v2
Note: Need to consider each of 4 edge boundaries
v3
outside
inside
v2
v1
outside
inside
v2
v1
Outside to inside:
Output: v1 and v2
outside
inside
v2
outside
inside
v2
v1
v1
v1
Inside to inside:
Output: v2
Inside to outside:
Output: v1
v1
Outside to outside:
Output: nothing
v2
v3
Figure 6-27, page 332
v2
v1
v3
Left
Clipper
v1
Right
Clipper
Bottom
Clipper
v1v2
v2
v2v2
v2
v2v3
v2v3
v2
v2v3
v3
v3v1
v3v1
v3v1
v1v2
v1
v2
Edges
Output
Edges
Output
v2
Top
Clipper
v2v1
v1
v3v1
v1v2
v2
v1v2
v1v2 v2v2
v2v2
v2
v2v2
Edges
Output
Edges
v2
v2
Output
Final
Weiler- Atherton Polygon Clipping
In 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 polygonprocessing direction(clockwise or counterclockwise)
Sutherland-Hodgman
Weiler-Atherton
Importance of clipping in video games
Good 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.