The painter's algorithm , also known as filling priority , is one of the simplest solutions to the problem of visibility in 3D computer graphics. When projecting 3D scenes into a 2D field, at a certain point it is necessary to decide which polygons are visible, and which ones are hidden.
The name "painter algorithm" refers to a technique used by many painters to paint far-away parts of a scene before the closer portion so as to cover several areas of the distant parts. The painter's algorithm picks out all the polygons in a scene based on its depth and then paints them in this order, furthest to the nearest. It will paint sections that are typically invisible - thereby solving the visibility problem - at the cost of being painted invisible areas of distant objects. The sequence used by this algorithm is called ' depth sequence , and does not have to respect the numerical distance to parts of the scene: the essential nature of this order is, more precisely, if one object obscures part of another object then the first object is painted after the object is obscured.Thus, a valid order can be described as a topological ordering of a directed acyclic graph that represents the occlusion between objects.
This algorithm can fail in some cases, including cyclic overlap or polygon piercing. In the case of cyclic overlaps, as shown in the figure on the right, Polygons A, B, and C overlap in such a way that it is impossible to determine which polygon lies above the other. In this case, the offending polygon must be cut to allow sorting. The Newell algorithm, proposed in 1972, provides a method for cutting the polygon. Many methods have also been proposed in the field of computational geometry.
The polygon stab case appears when one polygon cuts the other. As cyclic overlaps, this problem can be solved by cutting off offensive polygons.
In basic implementations, the painter's algorithm can be inefficient. This forces the system to make every point on each polygon in the visible set, even if the polygon is stuck in the finished scene. This means that, for a detailed scene, the painter's algorithm can overload the computer hardware excessively.
A reversed artist algorithm is sometimes used, where objects closest to the audience are first painted - with the rule that the paint should not be applied to parts of the painted image (unless they are partially transparent). In a computer graphics system, this can be very efficient, since it does not have to count colors (using lighting, textures and such) for remote scene sections hidden by nearby objects. However, the opposite algorithm suffers from many of the same problems as the standard version.
These and other deficiencies with the algorithm lead to the development of Z-buffer techniques, which can be seen as the development of the painter's algorithm, by resolving deep-seated conflicts on a pixel-by-pixel basis, reducing the need for depth-based. render order. Even in such systems, variants of the painter's algorithm are sometimes used. Since the Z-buffer implementation is generally dependent on the fixed-precision depth buffer registers that are implemented in the hardware, there is scope for visibility problems due to rounding errors. This is an overlap or a gap in the connection between polygons. To avoid this, some "overrender" graphics engine implementations, drawing the affected edges of both polygons in the sequence provided by the painter algorithm. This means that some pixels are actually taken twice (as in the full artist algorithm) but this only happens on a small part of the image and has a negligible performance effect.
Video Painter's algorithm
Note
Maps Painter's algorithm
References
-
Foley, James; Feiner, Steven K.; Hughes, John F. (1990). Computer Graph: Principles and Practice . Reading, MA, USA: Addison-Wesley. p.Ã, 1174. ISBNÃ, 0-201-12110-7.
Source of the article : Wikipedia