Z-buffering

Z-buffer data

A depth buffer, also known as a z-buffer, is a type of data buffer used in computer graphics to represent depth information of objects in 3D space from a particular perspective. The depth is stored as a height map of the scene, the values representing a distance to camera, with 0 being the closest. The encoding scheme may be flipped with the highest number being the value closest to camera. Depth buffers are an aid to rendering a scene to ensure that the correct polygons properly occlude other polygons. Z-buffering was first described in 1974 by Wolfgang Straßer in his PhD thesis on fast algorithms for rendering occluded objects.[1] A similar solution to determining overlapping polygons is the painter's algorithm, which is capable of handling non-opaque scene elements, though at the cost of efficiency and incorrect results.

In a 3D-rendering pipeline, when an object is projected on the screen, the depth (z-value) of a generated fragment in the projected screen image is compared to the value already stored in the buffer (depth test), and replaces it if the new value is closer. It works in tandem with the rasterizer, which computes the colored values. The fragment output by the rasterizer is saved if it is not overlapped by another fragment.

When viewing an image containing partially or fully overlapping opaque objects or surfaces, it is not possible to fully see those objects that are farthest away from the viewer and behind other objects (i.e., some surfaces are hidden behind others). If there were no mechanism for managing overlapping surfaces, surfaces would render on top of each other, not caring if they are meant to be behind other objects. The identification and removal of these surfaces are called the hidden-surface problem. To check for overlap, the computer calculates the z-value of a pixel corresponding to the first object and compares it with the z-value at the same pixel location in the z-buffer. If the calculated z-value is smaller than the z-value already in the z-buffer (i.e., the new pixel is closer), then the current z-value in the z-buffer is replaced with the calculated value. This is repeated for all objects and surfaces in the scene (often in parallel). In the end, the z-buffer will allow correct reproduction of the usual depth perception: a close object hides one further away. This is called z-culling.

The z-buffer has the same internal data structure as an image, namely a 2D-array, with the only difference being that it stores a single value for each screen pixel instead of color images that use 3 values to create color. This makes the z-buffer appear black-and-white because it is not storing color information. The buffer has the same dimensions as the screen buffer for consistency.

Primary visibility tests (such as back-face culling) and secondary visibility tests (such as overlap checks and screen clipping) are usually performed on objects' polygons in order to skip specific polygons that are unnecessary to render. Z-buffer, by comparison, is comparatively expensive, so performing primary and secondary visibility tests relieve the z-buffer of some duty.

The granularity of a z-buffer has a great influence on the scene quality: the traditional 16-bit z-buffer can result in artifacts (called "z-fighting" or stitching) when two objects are very close to each other. A more modern 24-bit or 32-bit z-buffer behaves much better, although the problem cannot be eliminated without additional algorithms. An 8-bit z-buffer is almost never used since it has too little precision.

Uses

Z-buffering is a technique used in almost all contemporary computers, laptops, and mobile phones for generating 3D computer graphics. The primary use now is for video games, which require fast and accurate processing of 3D scenes. Z-buffers are often implemented in hardware within consumer graphics cards. Z-buffering is also used (implemented as software as opposed to hardware) for producing computer-generated special effects for films.[citation needed]

Furthermore, Z-buffer data obtained from rendering a surface from a light's point-of-view permits the creation of shadows by the shadow mapping technique.[2]

Developments

Even with small enough granularity, quality problems may arise when precision in the z-buffer's distance values are not spread evenly over distance. Nearer values are much more precise (and hence can display closer objects better) than values that are farther away. Generally, this is desirable, but sometimes it will cause artifacts to appear as objects become more distant. A variation on z-buffering which results in more evenly distributed precision is called w-buffering (see below).

At the start of a new scene, the z-buffer must be cleared to a defined value, usually 1.0, because this value is the upper limit (on a scale of 0 to 1) of depth, meaning that no object is present at this point through the viewing frustum.

The invention of the z-buffer concept is most often attributed to Edwin Catmull, although Wolfgang Straßer described this idea in his 1974 Ph.D. thesis months before Catmull's invention.[a]

On more recent PC graphics cards (1999–2005), z-buffer management uses a significant chunk of the available memory bandwidth. Various methods have been employed to reduce the performance cost of z-buffering, such as lossless compression (computer resources to compress/decompress are cheaper than bandwidth) and ultra-fast hardware z-clear that makes obsolete the "one frame positive, one frame negative" trick (skipping inter-frame clear altogether using signed numbers to cleverly check depths).

Some games, notably several games later in the N64's life cycle, decided to either minimize Z buffering (for example, rendering the background first without z buffering and only using Z buffering for the foreground objects) or to omit it entirely, to reduce memory bandwidth requirements and memory requirements respectively. Super Smash Bros. and F-Zero X are two N64 games that minimized Z buffering to increase framerates. Several Factor 5 games also minimized or omitted Z buffering. On the N64 Z Buffering can consume up to 4x as much bandwidth as opposed to not using Z buffering.[3]

Mechwarrior 2 on PC supported resolutions up to 800x600[4] on the original 4 MB 3DFX Voodoo due to not using Z Buffering.


Z-culling

In rendering, z-culling is early pixel elimination based on depth, a method that provides an increase in performance when rendering of hidden surfaces is costly. It is a direct consequence of z-buffering, where the depth of each pixel candidate is compared to the depth of the existing geometry behind which it might be hidden.

When using a z-buffer, a pixel can be culled (discarded) as soon as its depth is known, which makes it possible to skip the entire process of lighting and texturing a pixel that would not be visible anyway. Also, time-consuming pixel shaders will generally not be executed for the culled pixels. This makes z-culling a good optimization candidate in situations where fillrate, lighting, texturing, or pixel shaders are the main bottlenecks.

While z-buffering allows the geometry to be unsorted, sorting polygons by increasing depth (thus using a reverse painter's algorithm) allows each screen pixel to be rendered fewer times. This can increase performance in fillrate-limited scenes with large amounts of overdraw, but if not combined with z-buffering it suffers from severe problems such as:

  • polygons occluding one another in a cycle (e.g. triangle A occludes B, B occludes C, C occludes A), and
  • the lack of any canonical "closest" point on a triangle (i.e. no matter whether one sorts triangles by their centroid or closest point or furthest point, one can always find two triangles A and B such that A is "closer" but in reality B should be drawn first).

As such, a reverse painter's algorithm cannot be used as an alternative to Z-culling (without strenuous re-engineering), except as an optimization to Z-culling. For example, an optimization might be to keep polygons sorted according to x/y-location and z-depth to provide bounds, in an effort to quickly determine if two polygons might possibly have an occlusion interaction.

Mathematics

The range of depth values in camera space to be rendered is often defined between a and value of .

After a perspective transformation, the new value of , or , is defined by:

After an orthographic projection, the new value of , or , is defined by:

where is the old value of in camera space, and is sometimes called or .

The resulting values of are normalized between the values of -1 and 1, where the plane is at -1 and the plane is at 1. Values outside of this range correspond to points which are not in the viewing frustum, and shouldn't be rendered.

Fixed-point representation

Typically, these values are stored in the z-buffer of the hardware graphics accelerator in fixed point format. First they are normalized to a more common range which is [0, 1] by substituting the appropriate conversion into the previous formula:

Simplifying:

Second, the above formula is multiplied by where d is the depth of the z-buffer (usually 16, 24 or 32 bits) and rounding the result to an integer:[5]

This formula can be inverted and derived in order to calculate the z-buffer resolution (the 'granularity' mentioned earlier). The inverse of the above :

where

The z-buffer resolution in terms of camera space would be the incremental value resulted from the smallest change in the integer stored in the z-buffer, which is +1 or -1. Therefore, this resolution can be calculated from the derivative of as a function of :

Expressing it back in camera space terms, by substituting by the above :

This shows that the values of are grouped much more densely near the plane, and much more sparsely farther away, resulting in better precision closer to the camera. The smaller is, the less precision there is far away—having the plane set too closely is a common cause of undesirable rendering artifacts in more distant objects.[6]

To implement a z-buffer, the values of are linearly interpolated across screen space between the vertices of the current polygon, and these intermediate values are generally stored in the z-buffer in fixed point format.

W-buffer

To implement a w-buffer,[7] the old values of in camera space, or , are stored in the buffer, generally in floating point format. However, these values cannot be linearly interpolated across screen space from the vertices—they usually have to be inverted, interpolated, and then inverted again. The resulting values of , as opposed to , are spaced evenly between and . There are implementations of the w-buffer that avoid the inversions altogether.

Whether a z-buffer or w-buffer results in a better image depends on the application.

Algorithmics

The following pseudocode demonstrates the process of z-buffering:

// First of all, initialize the depth of each pixel.
d(i, j) = infinite // Max length

// Initialize the color value for each pixel to the background color
c(i, j) = background color

// For each polygon, do the following steps :
for (each pixel in polygon's projection)
{
    // Find depth i.e, z of polygon
    //   at (x, y) corresponding to pixel (i, j)   
    if (z < d(i, j))
    {
        d(i, j) = z;
        c(i, j) = color;
    }
}

See also

References

  1. ^ Straßer, Wolfgang (April 26, 1974). "Zukünftige Arbeiten". Schnelle Kurven- und Flächendarstellung auf grafischen Sichtgeräten [Fast curve and surface display on graphic display devices] (PDF) (in German). Berlin. 6-1.{{cite book}}: CS1 maint: location missing publisher (link)
  2. ^ Akenine-Möller, Tomas; Haines, Eric; Hoffman, Naty (2018-08-06). Real-Time Rendering, Fourth Edition. CRC Press. ISBN 978-1-351-81615-1.
  3. ^ How I implemented MegaTextures on real Nintendo 64 hardware, retrieved 2024-01-04
  4. ^ 3D Acceleration Comparison Ep11: Mechwarrior 2 - 3DFX / PowerVR / S3 Virge / ATI Rage / Matrox Mys, retrieved 2024-01-04
  5. ^ The OpenGL Organization. "Open GL / FAQ 2 - Depth Buffer Precision". Retrieved 2017-12-26.
  6. ^ Grégory Massal. "Depth buffer - the gritty details". Archived from the original on 15 October 2008. Retrieved 2008-08-03.
  7. ^ Steve Baker. "Learning to Love your Z-buffer". Retrieved 2018-01-03.

Notes

  1. ^ See Wolfgang K. Giloi [de], J. L. Encarnação, W. Straßer. "The Giloi’s School of Computer Graphics". Computer Graphics 35 4:12–16.

Read other articles:

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Februari 2023. SMPLB B-C Dian KahuripanSekolah Menengah Pertama Luar Biasa B-C Dian KahuripanInformasiJenisSwastaAlamatLokasiJl. Pisangan Lama Iii Gg. A1 No.4 Rt.003/06 Jaktim, Jakarta Timur, DKI Jakarta, IndonesiaSitus webLaman di Kementerian Pendidikan Nasion...

 

Dilwale Dulhania Le Jayenge Cover of the 2016 editionAuthorAnupama ChopraCountry United Kingdom India LanguageEnglishSubjectDilwale Dulhania Le JayengePublisher British Film Institute HarperCollins Publication dateDecember 2002Media typePrintPages95ISBN0-85170-957-5 Dilwale Dulhania Le Jayenge (known as Dilwale Dulhania Le Jayenge: The Making of a Blockbuster in India) is a 2002 Indian book written by the journalist and film critic Anupama Chopra. It details the production of and analysi...

 

Polícia Militar de Alagoas Brasão da PMAL País  Brasil Estado  Alagoas Subordinação Governador do Estado de Alagoas Missão Polícia Militar Sigla PMAL Criação 3 de fevereiro de 1832 (191 anos) Patrono Alferes Joaquim José da Silva Xavier - Tiradentes Marcha Somos Soldados Leais Lema Sua Segurança, nossa missão! Cores Azul, branco, vermelho, verde e amarelo História Guerras/batalhas Guerra do ParaguaiGuerra de CanudosCombate ao CangaçoRevolta Tenentista de 1922C...

Ciklet — Cinta Kelas AtasGenre Drama Roman PembuatMD EntertainmentDitulis olehZara ZettiraSkenarioZara ZettiraSutradaraLono Abdul HamidPemeran Desy Ratnasari Jeremy Thomas Verlita Evelyn Jonathan Frizzy William Alvin Silvana Herman Anggur Aulia Bemby Putuanda Sally Marcellina Penata musikIwang ModulusNegara asalIndonesiaBahasa asliBahasa IndonesiaJmlh. musim1Jmlh. episode13ProduksiProduser Dhamoo Punjabi Manoj Punjabi Pengaturan kameraMulti-kameraDurasi60 menitRumah produksiMD Enterta...

 

Босилово Општина Босилово Герб Прапор Адм. центр Босилово Країна Північна Македонія Офіційна мова македонська Населення  - повне 14 260  - густота 88,03 осіб/км² Площа  - повна 161,99 км² Висота  - максимальна 249 м  - мінімальна 249 м Вебсайт opstinabosilovo.gov.mk Код ISO 3166-2 MK-402 В...

 

This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help to improve this article by introducing more precise citations. (July 2015) (Learn how and when to remove this template message) A player exploring a randomly generated map in the roguelike game Nuclear Throne In video games, a random map is a map generated randomly by the computer, usually in strategy games. Random maps are often the cor...

Type of state-funded school A community school in England and Wales is a type of state-funded school in which the local education authority employs the school's staff, is responsible for the school's admissions and owns the school's estate.[1][2][3][4] The formal use of this name to describe a school derives from the School Standards and Framework Act 1998.[5] Board School Granby Street Board School, Toxteth, Liverpool In the mid-19th century, governmen...

 

Chinese mythological dragon This article is about the Torch Dragon creature from Chinese mythology. For the pig dragon artifacts (using a different Chinese homonym), see Pig dragon.Not to be confused with Zhurong.ZhulongZhulong in an edition of the Classic of Mountains and SeasTraditional Chinese燭龍Simplified Chinese烛龙Literal meaningTorch DragonTranscriptionsStandard MandarinHanyu PinyinZhúlóngWade–GilesChu-lungChoulongTraditional Chinese逴龍Simplified Chinese逴龙Lite...

 

Friedhofskapelle des Waldfriedhofs Bruneck Der Waldfriedhof (auch Heldenfriedhof) in Bruneck in Südtirol ist ein Soldatenfriedhof für Gefallene des Ersten und Zweiten Weltkrieges verschiedener Nationen und Konfessionen. Er befindet sich auf dem Kühbergl und steht unter Denkmalschutz. Inhaltsverzeichnis 1 Geschichte 2 Beschreibung 3 Literatur 4 Weblinks Geschichte Während des Ersten Weltkrieges befanden sich infolge der nahen Dolomitenfront zwei, zeitweise auch drei österreichisch-ungaris...

2009 manga Nodame CantabileCover art of the first tankōbon volume, featuring Megumi Nodaのだめカンタービレ(Nodame Kantābire)GenreMusical[1]Romantic comedy[2] MangaWritten byTomoko NinomiyaPublished byKodanshaEnglish publisherNA: Del Rey Manga (former)Kodansha USA (digital, current)[3]MagazineKissDemographicJoseiOriginal run10 July 2001 – 25 August 2010Volumes25 (List of volumes) Manga parts Nodame Cantable (10 July 2001–10 October 2009; 23 volu...

 

2008 single by Metro StationSeventeen ForeverSingle by Metro Stationfrom the album Metro Station B-sideKelseyReleasedDecember 13, 2008Recorded2007Genre Synthpop dance-punk neon pop[1] Length2:54LabelColumbiaSongwriter(s) Trace Cyrus Mason Musso Blake Healy Anthony Improgo Producer(s)S*A*M and SluggoMetro Station singles chronology Shake It (2008) Seventeen Forever (2008) Japanese Girl (2009) Music videoSeventeen Forever on YouTube Seventeen Forever is a song by the American pop band M...

 

Rumah kayu gelondongan di Heidal, Norwegia yang dibangun pada abad ke-17 Detail kayu gelondongan yang disusun Rumah kayu gelondongan, atau rumah kayu bundar, adalah struktur yang dibangun dengan menggunakan kayu gelondongan yang disusun horizontal yang saling bertautan di sudut-sudutnya dengan takik. Kayu gelondongan adalah kayu yang baru saja ditebang dan dengan bentuk penampang yang masih bundar sesuai dengan profil pohon. Mereka dapat digunakan dalam bentuk bulat, dipotong menjadi balok pa...

President of Argentina from 2003 to 2007 For other uses, see Néstor Kirchner (disambiguation). In this Spanish name, the first or paternal surname is Kirchner and the second or maternal family name is Ostoić. Néstor KirchnerKirchner in 2005President of ArgentinaIn office10 December 2003 – 10 December 2007[a]Acting: 25 May – 10 December 2003Vice PresidentDaniel ScioliPreceded byEduardo Duhalde (interim)Succeeded byCristina Fernández de KirchnerFirst Gentleman o...

 

Burmese politician Soe Lwinစိုးလွင် Regional AuditorIncumbentAssumed office 7 April 2016PresidentHtin Kyaw Personal detailsBornMyanmar Soe Lwin (Burmese: စိုးလွင်) is the incumbent Regional Auditor of Sagaing, Myanmar (Burma). He is a member of Sagaing Region Government. He serving as a Regional Auditor of Sagaing Region.[1][2][3] References ^ President Office Myanmar (in Burmese). ^ တိုင်းဒေသကြီး သ...

 

Cross Internacional Valle de LlodioDateLate NovemberLocationLlodio, SpainEvent typeCross countryDistance9.7 km for men 7.6 km for womenEstablished1985Official siteCross Valle de Llodio The Cross Internacional Valle de Llodio is an annual cross country running competition that takes place in Llodio in the Basque Country, Spain, around late November. The event was first held in February 1985 and changed to an end-of-year competition soon after, holding its second edition in December 1...

American physician Charles Huggins redirects here. For the politician, see Charlie Huggins. Charles Brenton HugginsHuggins in 1966Born(1901-09-22)September 22, 1901Halifax, Nova Scotia, CanadaDiedJanuary 12, 1997(1997-01-12) (aged 95)Chicago, Illinois, U.S.CitizenshipCanadian, AmericanAlma materAcadia UniversityHarvard UniversityKnown forprostate cancerhormonesAwardsNobel Prize for Physiology or Medicine (1966)Cameron Prize for Therapeutics of the University of Edinburgh (1956)...

 

Jim CarreyCarrey di Yes Man tayang perdana pada tahun 2008LahirJames Eugene Carrey17 Januari 1962 (umur 61)Newmarket, Ontario, KanadaWarga negaraKanadaAmerikaPekerjaanAktorkomedianpenulisprodusersenimanTahun aktif1978–sekarangSuami/istri Melissa Womer ​ ​(m. 1987; c. 1995)​ Lauren Holly ​ ​(m. 1996; c. 1997)​ PasanganJenny McCarthy (2005–2010)Karier komediMediakomedi tunggalfilmtelevi...

 

Islamic North American organization Islamic Circle of North AmericaLogo of the Islamic Circle of North AmericaAbbreviationICNAFormation1968 (1977–present form)TypeIslamic North American grassroots umbrella organizationPurposeTo seek the pleasure of Allah through the struggle of Iqamat-ud-Deen [establishment of the Islamic system of life] as spelled out in the Qur'an and the Sunnah of [Muhammad]Headquarters166-26 89th Avenue, Queens, New York, United StatesRegion served North AmericaPresiden...

Organizational theory Not to be confused with Organization theory (Castells). Part of a series onSociology History Outline Index Key themes Society Globalization Human behavior Human environmental impact Identity Industrial revolutions 3 / 4 / 5 Social complexity Social construct Social environment Social equality Social equity Social power Social stratification Social structure Perspectives Conflict theory Critical theory Structural functionalism Positivism Social constructionism Symbolic in...

 

2010 British filmZombie UndeadDirected byRhys DaviesWritten byKris TearseProduced byRhys DaviesStarringRuth KingKris TearseRod DuncanBarry ThomasSandra WildboreChristopher J. HerbertCinematographyNeill PhillipsMusic byDavid FellowsKris TearseProductioncompanyHive FilmsRelease date 15 January 2010 (2010-01-15) (UK)[1] Running time79 minutesCountryUnited KingdomLanguageEnglish Zombie Undead is a 2010 British horror film directed by Rhys Davies and starring Ruth King, ...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!