Scan-line Algorithm
   HOME

TheInfoList



OR:

Scanline rendering (also scan line rendering and scan-line rendering) is an algorithm for visible surface determination, in
3D computer graphics 3D computer graphics, sometimes called Computer-generated imagery, CGI, 3D-CGI or three-dimensional Computer-generated imagery, computer graphics, are graphics that use a three-dimensional representation of geometric data (often Cartesian coor ...
, that works on a row-by-row basis rather than a
polygon In geometry, a polygon () is a plane figure made up of line segments connected to form a closed polygonal chain. The segments of a closed polygonal chain are called its '' edges'' or ''sides''. The points where two edges meet are the polygon ...
-by-polygon or
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 ...
-by-pixel basis. All of the polygons to be rendered are first sorted by the top y coordinate at which they first appear, then each row or
scan line A scan line (also scanline) is one line, or row, in a raster scanning pattern, such as a line of video on a cathode-ray tube (CRT) display of a television set or computer monitor. On CRT screens the horizontal scan lines are visually discernib ...
of the image is computed using the intersection of a scanline with the polygons on the front of the sorted list, while the sorted list is updated to discard no-longer-visible polygons as the active scan line is advanced down the picture. The main advantage of this method is that sorting vertices along the normal of the scanning plane reduces the number of comparisons between edges. Another advantage is that it is not necessary to translate the coordinates of all vertices from the main memory into the working memory—only vertices defining edges that intersect the current scan line need to be in active memory, and each vertex is read in only once. The main memory is often very slow compared to the link between the central processing unit and
cache memory In computing, a cache ( ) is a hardware or software component that stores data so that future requests for that data can be served faster; the data stored in a cache might be the result of an earlier computation or a copy of data stored elsew ...
, and thus avoiding re-accessing vertices in main memory can provide a substantial speedup. This kind of algorithm can be easily integrated with many other graphics techniques, such as the
Phong reflection model The Phong reflection model (also called Phong illumination or Phong lighting) is an empirical model of the local illumination of points on a surface designed by the computer graphics researcher Bui Tuong Phong. In 3D computer graphics, it is ...
or the
Z-buffer A z-buffer, also known as a depth buffer, is a type of data buffer used in computer graphics to store the depth information of Fragmentation (computing), fragments. The values stored represent the distance to the camera, with 0 being the closest ...
algorithm.


Algorithm

The usual method starts with edges of projected polygons inserted into buckets, one per scanline; the rasterizer maintains an active edge table (''AET''). Entries maintain sort links, X coordinates, gradients, and references to the polygons they bound. To rasterize the next scanline, the edges no longer relevant are removed; new edges from the current scanlines' Y-bucket are added, inserted sorted by X coordinate. The active edge table entries have X and other parameter information incremented. Active edge table entries are maintained in an X-sorted list, effecting a change when 2 edges cross. After updating edges, the active edge table is traversed in X order to emit only the visible spans, maintaining a Z-sorted active Span table, inserting and deleting the surfaces when edges are crossed.


Variants

A hybrid between this and
Z-buffering A z-buffer, also known as a depth buffer, is a type of data buffer used in computer graphics to store the depth information of fragments. The values stored represent the distance to the camera, with 0 being the closest. The encoding scheme may ...
does away with the active edge table sorting, and instead rasterizes one scanline at a time into a Z-buffer, maintaining active polygon spans from one scanline to the next. In another variant, an ID buffer is rasterized in an intermediate step, allowing
deferred shading In the field of 3D computer graphics, deferred shading is a screen-space shading technique that is performed on a second Rendering (computer graphics), rendering pass, after the vertex and pixel shaders are rendered. It was first suggested by ...
of the resulting visible pixels.


History

The first publication of the scanline rendering technique was probably by Wylie, Romney, Evans, and Erdahl in 1967. Other early developments of the scanline rendering method were by Bouknight in 1969, and Newell, Newell, and Sancha in 1972.Newell, M E, Newell R. G, and Sancha, T.L, "A New Approach to the Shaded Picture Problem," Proc ACM National Conf. 1972 Much of the early work on these methods was done in
Ivan Sutherland Ivan Edward Sutherland (born May 16, 1938) is an American computer scientist and Internet pioneer, widely regarded as a pioneer of computer graphics. His early work in computer graphics as well as his teaching with David C. Evans in that subje ...
's graphics group at the
University of Utah The University of Utah (the U, U of U, or simply Utah) is a public university, public research university in Salt Lake City, Utah, United States. It was established in 1850 as the University of Deseret (Book of Mormon), Deseret by the General A ...
, and at the
Evans & Sutherland Evans & Sutherland is an American computer graphics firm founded in 1968 by David C. Evans (computer scientist), David Evans and Ivan Sutherland. Its current products are used in digital projection environments like planetariums. Its simulation b ...
company in
Salt Lake City Salt Lake City, often shortened to Salt Lake or SLC, is the capital and most populous city of the U.S. state of Utah. It is the county seat of Salt Lake County, the most populous county in the state. The city is the core of the Salt Lake Ci ...
.


Use in realtime rendering

The early Evans & Sutherland ESIG line of image-generators (IGs) employed the technique in hardware 'on the fly', to generate images one raster-line at a time without a
framebuffer A framebuffer (frame buffer, or sometimes framestore) is a portion of random-access memory (RAM) containing a bitmap that drives a video display. It is a memory buffer containing data representing all the pixels in a complete video frame. Mode ...
, saving the need for then costly memory. Later variants used a hybrid approach. The
Nintendo DS The is a foldable handheld game console produced by Nintendo, released globally across 2004 and 2005. The DS, an initialism for "Developers' System" or "Dual Screen", introduced distinctive new features to handheld games: two LCD screens worki ...
is the latest hardware to render 3D scenes in this manner, with the option of caching the rasterized images into VRAM. The sprite hardware prevalent in 1980s games machines can be considered a simple 2D form of scanline rendering. The technique was used in the first Quake engine for software rendering of environments (but moving objects were Z-buffered over the top). Static scenery used BSP-derived sorting for priority. It proved better than
Z-buffer A z-buffer, also known as a depth buffer, is a type of data buffer used in computer graphics to store the depth information of Fragmentation (computing), fragments. The values stored represent the distance to the camera, with 0 being the closest ...
/ painter's type algorithms at handling scenes of high depth complexity with costly pixel operations (i.e. perspective-correct
texture mapping Texture mapping is a term used in computer graphics to describe how 2D images are projected onto 3D models. The most common variant is the UV unwrap, which can be described as an inverse paper cutout, where the surfaces of a 3D model are cut ap ...
without hardware assist). This use preceded the widespread adoption of Z-buffer-based GPUs now common in PCs. Sony experimented with software scanline renderers on a second
Cell Cell most often refers to: * Cell (biology), the functional basic unit of life * Cellphone, a phone connected to a cellular network * Clandestine cell, a penetration-resistant form of a secret or outlawed organization * Electrochemical cell, a de ...
processor during the development of the
PlayStation 3 The PlayStation 3 (PS3) is a home video game console developed and marketed by Sony Computer Entertainment (SCE). It is the successor to the PlayStation 2, and both are part of the PlayStation brand of consoles. The PS3 was first released on ...
, before settling on a conventional CPU/GPU arrangement.


Similar techniques

A similar principle is employed in
tiled rendering Tiled rendering is the process of subdividing a computer graphics image by a regular grid in optical space and rendering each section of the grid, or ''tile'', separately. The advantage to this design is that the amount of memory and bandwidth is ...
(most famously the
PowerVR PowerVR is a division of Imagination Technologies (formerly VideoLogic) that develops hardware and software for 2D and 3D rendering, and for video encoding, video decoding, decoding, associated image processing and DirectX, OpenGL ES, OpenVG, and ...
3D chip); that is, primitives are sorted into screen space, then rendered in fast on-chip memory, one tile at a time. The
Dreamcast The is the final home video game console manufactured by Sega. It was released in Japan on November 27, 1998, in North America on September 9, 1999 and in Europe on October 14, 1999. It was the first sixth-generation video game console, prec ...
provided a mode for rasterizing one row of tiles at a time for direct raster scanout, saving the need for a complete framebuffer, somewhat in the spirit of hardware scanline rendering. Some software rasterizers use 'span buffering' (or 'coverage buffering'), in which a list of sorted, clipped spans are stored in scanline buckets. Primitives would be successively added to this datastructure, before rasterizing only the visible pixels in a final stage.


Comparison with Z-buffer algorithm

The main advantage of scanline rendering over
Z-buffering A z-buffer, also known as a depth buffer, is a type of data buffer used in computer graphics to store the depth information of fragments. The values stored represent the distance to the camera, with 0 being the closest. The encoding scheme may ...
is that the number of times visible pixels are processed is kept to the absolute minimum which is always one time if no transparency effects are used—a benefit for the case of high resolution or expensive shading computations. In modern Z-buffer systems, similar benefits can be gained through rough front-to-back sorting (approaching the 'reverse painters algorithm'), early Z-reject (in conjunction with hierarchical Z), and less common deferred rendering techniques possible on programmable GPUs. Scanline techniques working on the raster have the drawback that overload is not handled gracefully. The technique is not considered to scale well as the number of primitives increases. This is because of the size of the intermediate datastructures required during rendering—which can exceed the size of a Z-buffer for a complex scene. Consequently, in contemporary interactive graphics applications, the Z-buffer has become ubiquitous. The Z-buffer allows larger volumes of primitives to be traversed linearly, in parallel, in a manner friendly to modern hardware. Transformed coordinates, attribute gradients, etc., need never leave the graphics chip; only the visible pixels and depth values are stored.


See also

*
Raster scan A raster scan, or raster scanning, is the rectangular pattern of image capture and reconstruction in television. By analogy, the term is used for raster graphics, the pattern of image storage and transmission used in most computer bitmap image s ...
* Ray tracing *
Z-buffering A z-buffer, also known as a depth buffer, is a type of data buffer used in computer graphics to store the depth information of fragments. The values stored represent the distance to the camera, with 0 being the closest. The encoding scheme may ...


References


External links


University of Utah Graphics Group History
{{Computer graphics 3D rendering Computer graphics algorithms