Clipping, in the context of
computer graphics
Computer graphics deals with generating images and art with the aid of computers. Computer graphics is a core technology in digital photography, film, video games, digital art, cell phone and computer displays, and many specialized applications. ...
, 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 graphics, raster image, or the smallest addressable element in a dot matrix display device. In most digital display devices, p ...
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, their ...
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."
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 ma ...
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 direct m ...
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.
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 for digital image processing and to accelerate computer graphics, being present either as a discrete video card or embedded on motherboards, mobile phones, personal ...
(GPU).
The concept of clipping can be extended to higher dimensionality using methods of abstract
algebraic geometry
Algebraic geometry is a branch of mathematics which uses abstract algebraic techniques, mainly from commutative algebra, to solve geometry, geometrical problems. Classically, it studies zero of a function, zeros of multivariate polynomials; th ...
.
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) 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
In geometry, a Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called ''coordinates'', which are the signed distances to the point from two fixed perpendicular o ...
system laid out on the user's screen or
viewport
A viewport is a polygon viewing region in computer graphics.
In computer graphics theory, there are two region-like notions of relevance when rendering some objects to an image. In textbook terminology, the ''world coordinate window'' is the area ...
. This viewport is defined by the geometry of the
viewing frustum, and parameterizes the
field of view
The field of view (FOV) is the angle, angular extent of the observable world that is visual perception, 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 elec ...
.
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
Medical imaging is the technique and process of imaging the interior of a body for clinical analysis and medical intervention, as well as visual representation of the function of some organs or tissues (physiology). Medical imaging seeks to revea ...
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 algorithms:
**
Cohen–Sutherland
**
Liang–Barsky
**
Fast-clipping
**
Cyrus–Beck
**
Nicholl–Lee–Nicholl
**
Skala
**
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 Hidden-surface determination#Visible surface determination, visible surface determination in 3D computer graphics that works on a polygon, polygon-by-polyg ...
See also
*
Boolean operations on polygons
*
Bounding volume
In computer graphics and computational geometry, a bounding volume (or bounding region) for a set of objects is a closed region that completely contains the union of the objects in the set. Bounding volumes are used to improve the efficiency ...
*
Clip space
*
Distance fog
*
Guard-band clipping
Guard band Clipping (computer graphics), 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 ...
*
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 Computer representat ...
*
Pruning (decision trees)
*
Visibility (geometry)
Further reading
* GPU Gems: Efficient Occlusion Culling
* Clipping in
Java AWTjava.awt.Graphics.clipRect
JavaDoc
* Clipping in UIKit for
iOS
Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...
(2D)
UIRectClip
* Clipping in SceneKit for iOS (3D)
* Clipping in
OpenGL
OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
:
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