Computer Graphics1 The A-buffer an Antialiased Hidden Surface Method
Computer Graphics2 Introduction n The A-buffer: u Anti-aliased, area-averaged, accumulation buffer u A general hidden surface mechanism suited to medium scale virtual memory computers u Resolves visibility among an arbitrary collection of opaque, transparent, and intersecting objects. u Uses an easy to compute Fourier window (box filter) to increase the effective image resolution many times over the Z-buffer, with a moderate increase in cost. u Is incorporated into the REYES 3-D rendering system at Lucasfilm. u Was used successfully in the “Genesis Demo” sequence in Star Trek II
Computer Graphics3 Weaknesses of the Z-buffer n Although extremely fast and simple, the Z-buffer: u Aliases too much. u Cannot render transparent objects correctly.
Computer Graphics4 A-buffer Basics n Works with two different data types: u “pixel-structs” (distinct from pixels). u “fragments” n Uses a 4x8 bit mask to represent the subpixel polygons.
Computer Graphics5 A-buffer Basics - Cont. n If a pixel is simple, i.e. completely covered, the Z value is positive and the pixelstruct contains a color. Otherwise, the Z value is negative and the pointer points to a list of fragements sorted front to back by frontmost Z.
Computer Graphics6 Pixelstruct definition floatz;// negative Z fragment_ptrflist// never null OR floatz// positive Z byter,g,b// color bytea;// coverage
Computer Graphics7 Fragment definition fragment_ptrnext; short_intr,g,b;// color, 12 bit short_intopacity;// 1-transparency short_intarea;// 12 bit precision short_intobject_tab;// from parent object pixelmaskm;// 4x8 bits floatzmax, zmin;// positive
Computer Graphics8 A-buffer Basics - Cont. n The object tag is augmented by a bit indicating whether the surface faces forward or backwards (to prevent improper merging on silhouettes) n The following symbols will be used later: u M4x8 bit mask u Aarea (0..1) u Ccolor(r,g,b) u Opacity1-transmission fraction coverage, usually area times opacity
Computer Graphics9 A-buffer Basics - Cont. n Why sort in Z? u Proper calculation of transparency u fragments from the same geometric primitive tend to cluster together in the list and so can be merged.
Computer Graphics10 Merging fragment n Fragments are merged when they: u Have the same object tag. u Overlap in Z. n If the 2 fragments do not overlap on the screen ( ) u The bitmasks are or’ed u The colors are blended: u The areas are added
Computer Graphics11 Merging fragment n If they overlap (highly abnormal): u They are split into 3 parts: u The contribution of the front fragment is computed: u The colors are blended
Computer Graphics12 Merging fragment - Cont. u And the area is computed
Computer Graphics13 Pixel analysis n When no more fragments are to be sent to a pixelstruct, the pixelstruct’s color is determined and written into the picture. n Generally, the pixel will be fully covered by some object and a few pixel-sized fragments will remain. n If any fragments are present, a recursive packing process is invoked.
Computer Graphics14 Packing fragments n Area averaging means that the color of a pixel is computed by the area-weighted average of the colors of the visible surface containing the pixel. n How do we determine the visible parts of fragments? u We start the packing process with a full 32 bit mask to represent the entire pixel. u Fragments are considered only if they overlap the search mask.
Computer Graphics15 Packing fragments - Cont. u When all or part of a fragment is found within the search mask, the search mask part of the pixel is partitioned using the fragment mask u If we use a recursive call with as the search mask to find the color of the rest of the searched area. u If the fragment is transparent, a recursive call using as a search mask is used to find the color of the surfaces behind the fragment to be filtered by the color of the fragment.
Computer Graphics16 Packing fragments - Cont. F F The composite coverage is computed similarly u Otherwise, the color of the fragment suffices for u When we have the colors of the inside and outside regions, we blend them weighted by their coverage
Computer Graphics17 Intersections n Pixels where intersecting object are visible usually number in the dozens or hundreds in a typical 512x512 resolution picture. n Also, the aliasing along the line of intersection is not quite as critical as that on a silhouette, because the contrast is is often lower. n These observations suggest we can get by with simple approximations.
Computer Graphics18 Intersections - Cont. n We define an intersection to occur when the object tags differ and the fragments overlap in Z. n Since we don’t know exactly how much of the frontmost fragment is visible, we estimate it from the minimum and maximum Z values:
Computer Graphics19 Intersections - Cont. n Since part of the front fragment obscures the next fragment and vice versa, we need to estimate the weighting factor to be used to blend the two fragment’s colors. n We now blend the front fragment with the other fragment within the inside mask n Then we blend the inside and outside part