Clipping, in the context of
computer graphics
Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great deal ...
, is a method to selectively enable or disable
rendering operations within a defined
region of interest. Mathematically, clipping can be described using the terminology of
constructive geometry. A
rendering algorithm only draws
pixel
In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a raster image, or the smallest point in an all points addressable display device.
In most digital display devices, pixels are the s ...
s in the
intersection
In mathematics, the intersection of two or more objects is another object consisting of everything that is contained in all of the objects simultaneously. For example, in Euclidean geometry, when two lines in a plane are not parallel, thei ...
between the clip region and the scene model. Lines and surfaces outside the
view volume (aka. frustum) are removed.
Clip regions are commonly specified to improve render performance. A well-chosen clip allows the renderer to save time and energy by skipping calculations related to pixels that the user cannot see. Pixels that will be drawn are said to be within the clip region. Pixels that will not be drawn are outside the clip region. More informally, pixels that will not be drawn are said to be "clipped."
Clipping in 2D graphics
In two-dimensional graphics, a clip region may be defined so that pixels are only drawn within the boundaries of a
window
A window is an opening in a wall, door, roof, or vehicle that allows the exchange of light and may also allow the passage of sound and sometimes air. Modern windows are usually glazed or covered in some other transparent or translucent mate ...
or frame. Clip regions can also be used to selectively control pixel rendering for aesthetic or artistic purposes. In many implementations, the final clip region is the composite (or intersection) of one or more application-defined shapes, as well as any system hardware constraints
In one example application, consider an image editing program. A user application may render the image into a viewport. As the user zooms and scrolls to view a smaller portion of the image, the application can set a clip boundary so that pixels outside the viewport are not rendered. In addition,
GUI widget
A graphical widget (also graphical control element or control) in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through di ...
s, overlays, and other
windows or frames may obscure some pixels from the original image. In this sense, the clip region is the composite of the application-defined "user clip" and the "device clip" enforced by the system's software and hardware implementation.
Application software can take advantage of this clip information to save computation time, energy, and memory, avoiding work related to pixels that aren't visible.
Clipping in 3D graphics
In three-dimensional graphics, the terminology of clipping can be used to describe many related features. Typically, "clipping" refers to operations in the plane that work with rectangular shapes, and "culling" refers to more general methods to selectively process scene model elements. This terminology is not rigid, and exact usage varies among many sources.
Scene model elements include geometric primitives: points or vertices; line segments or edges; polygons or faces; and more abstract model objects such as curves, splines, surfaces, and even text. In complicated scene models, individual elements may be selectively disabled (clipped) for reasons including visibility within the viewport (
frustum culling); orientation (
backface culling), obscuration by other scene or model elements (
occlusion culling, depth- or "z" clipping). Sophisticated algorithms exist to efficiently detect and perform such clipping. Many optimized clipping methods rely on specific hardware acceleration logic provided by a
graphics processing unit
A graphics processing unit (GPU) is a specialized electronic circuit designed to manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device. GPUs are used in embedded systems, mo ...
(GPU).
The concept of clipping can be extended to higher dimensionality using methods of abstract
algebraic geometry.
Near clipping
Beyond projection of vertices & 2D clipping, near clipping is required to correctly rasterise 3D primitives; this is because vertices may have been projected behind the eye. Near clipping ensures that all the vertices used have valid 2D coordinates. Together with far-clipping it also helps prevent overflow of depth-buffer values. Some early
texture mapping hardware (using
forward texture mapping
Texture mapping is a method for mapping a texture on a computer-generated graphic. Texture here can be high frequency detail, surface texture, or color.
History
The original technique was pioneered by Edwin Catmull in 1974.
Texture mapping ...
) in video games suffered from complications associated with near clipping and
UV coordinates.
Occlusion clipping (Z- or depth clipping)
In 3D computer graphics, "Z" often refers to the depth axis in the system of coordinates centered at the viewport origin: "Z" is used interchangeably with "depth", and conceptually corresponds to the distance "into the virtual screen." In this coordinate system, "X" and "Y" therefore refer to a conventional
cartesian coordinate
A Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of numerical coordinates, which are the signed distances to the point from two fixed perpendicular oriented lines, measured i ...
system laid out on the user's screen or
viewport
A viewport is a polygon viewing region in computer graphics.
In computer graphics
Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video game ...
. This viewport is defined by the geometry of the
viewing frustum
In 3D computer graphics, the view frustum (also called viewing frustum) is the region of space in the modeled world that may appear on the screen; it is the field of view of a perspective virtual camera system.
The view frustum is typically ...
, and parameterizes the
field of view
The field of view (FoV) is the extent of the observable world that is seen at any given moment. In the case of optical instruments or sensors it is a solid angle through which a detector is sensitive to electromagnetic radiation.
Humans a ...
.
Z-clipping, or depth clipping, refers to techniques that selectively render certain scene objects based on their depth relative to the screen. Most graphics toolkits allow the programmer to specify a "near" and "far" clip depth, and only portions of objects between those two planes are displayed. A creative application programmer can use this method to render visualizations of the interior of a 3D object in the scene. For example, a
medical imaging application could use this technique to render the organs inside a human body. A video game programmer can use clipping information to accelerate game logic.
For example, a tall wall or building that occludes other game entities can save GPU time that would otherwise be spent transforming and texturing items in the rear areas of the scene; and a tightly integrated software program can use this same information to save CPU time by optimizing out game logic for objects that aren't seen by the player.
Algorithms
*
Line clipping
In computer graphics, line clipping is the process of removing ( clipping) lines or portions of lines outside an area of interest (a viewport or view volume). Typically, any part of a line which is outside of the viewing area is removed.
There ...
algorithms:
**
Cohen–Sutherland
**
Liang–Barsky
**
Fast-clipping
**
Cyrus–Beck
**
Nicholl–Lee–Nicholl
**
Skala
Skala may refer to:
Places Greece
* Skala, Patmos, the main port on the island of Patmos in Greece
* Skala, Laconia, a municipality in southern Greece
* Skala, Xanthi, a settlement in north-eastern Greece
* Skala, Cephalonia, a resort in the ...
**
O(lg ''N'') algorithm
* Polygon clipping algorithms:
**
Greiner–Hormann
**
Sutherland–Hodgman
**
Weiler–Atherton
**
Vatti
*Rendering methodologies
**
Painter's algorithm
The painter’s algorithm (also depth-sort algorithm and priority fill) is an algorithm for visible surface determination in 3D computer graphics that works on a polygon-by-polygon basis rather than a pixel-by-pixel, row by row, or area by are ...
See also
*
Boolean operations on polygons Boolean operations on polygons are a set of Boolean operations (AND, OR, NOT, XOR, ...) operating on one or more sets of polygons in computer graphics. These sets of operations are widely used in computer graphics, CAD, and in EDA (in integrated ...
*
Bounding volume
In computer graphics and computational geometry, a bounding volume for a set of objects is a closed volume that completely contains the union of the objects in the set. Bounding volumes are used to improve the efficiency of geometrical operat ...
*
Clip space
The clip coordinate system is a homogeneous coordinate system in the graphics pipeline that is used for clipping (computer graphics), clipping.
Objects' coordinates are transformed via a 3D projection, projection transformation into clip coordinat ...
*
Distance fog
Distance fog is a technique used in 3D computer graphics to enhance the perception of distance by shading distant objects differently.
Because many of the shapes in graphical environments are relatively simple, and complex shadows are difficult ...
*
Guard-band clipping
Guard band clipping is a technique used by digital rendering hardware and software designed to minimize the amount of clipping performed. Instead of clipping polygons that extend out of the viewport, polygons are only clipped if they extend pas ...
*
Hidden surface determination
In 3D computer graphics, hidden-surface determination (also known as shown-surface determination, hidden-surface removal (HSR), occlusion culling (OC) or visible-surface determination (VSD)) is the process of identifying what surfaces and parts o ...
*
Pruning (decision trees)
*
Visibility (geometry)
Further reading
* GPU Gems: Efficient Occlusion Culling
* Clipping in
Java AWT
The Abstract Window Toolkit (AWT) is Java's original platform-dependent windowing, graphics, and user-interface widget toolkit, preceding Swing. The AWT is part of the Java Foundation Classes (JFC) — the standard API for providing a graphica ...
java.awt.Graphics.clipRect
JavaDoc
* Clipping in UIKit for
iOS
iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also include ...
(2D)
UIRectClip
* Clipping in SceneKit for iOS (3D)
* Clipping in
OpenGL
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
:
ttps://www.opengl.org/archives/resources/faq/technical/clipping.htm OpenGL Technical FAQs: ''Clipping, Culling, and Visibility Testing''ref name="OpenGL-tech-faq-10">
References
{{Computer graphics
Computer graphics
Computer graphic artifacts