Painter algorithm
The painter algorithm ( Engl. Painter's algorithm ) is a simple solution to the visibility problem in 3D computer graphics . When displaying a three-dimensional scene on a two-dimensional one, it is often necessary to decide which polygons are visible and which are hidden.
The name painter algorithm is an allusion to a painter who first draws the distant objects in a scene and then paints over them with the closer ones. According to the algorithm, in the implementation of a computer graphics application are used: First, all polygons their depth sorted ( depth sorting , engl. Depth sort and then the order they are drawn by). The visibility problem is solved by overdrawing the parts of the image that are normally not visible.
This approach creates a number of problems. What happens if polygon A partially intersects polygon B, B partially C and C partially intersect A? It can no longer be decided which polygon is in front of which. A similar case occurs when two polygons intersect each other in three-dimensional space. In such cases, at least one of the affected polygons must be subdivided so that the sorting is possible and the painter algorithm delivers a correct result.
Another problem is that the painter's algorithm is inefficient because the computer has to calculate the intensities of all points on a polygon, even if the polygon is not visible in the final scene.
These and other problems with the painter algorithm led to the development of the Z-buffer , which can be viewed as a logical further development of the painter algorithm. By using a z-buffer, the objects no longer need to be rendered in the order of their depth.