Unit-5 Computer Graphics Part-2
Unit-5 Computer Graphics Part-2
Unit-V Part 2
Topic : Depth Buffer Method or Z-Buffer
Method, A-Buffer Method and Scan Line
Method
Subject Name: Computer Graphics
Presented By:
Subject Code: RCS-603 Sachin Kumar Saxena
Assistant Professor
CSE Department
SRMS College of Engineering,Technology &
Research,Bareilly
Z-Buffer Method
•Also known as depth-Buffer method.
•Proposed by Catmull in 1974
•Easy to implement
●
How do we ensure that closer polygons
overwrite further ones in general?
Z-Buffer Method
●
Two buffers are used
– Frame Buffer
– Depth Buffer
●
The z-coordinates (depth values) are usually
normalized to the range [0,1]
Z-buffer Algorithm
Initialize all d[I,j]=1.0(max depth),c[I,j]=background color
For(each polygon)
For(each pixel in polygon’s projection)
{
Find depth-z of polygon at (x,y) corresponding to pixel (I,j);
If z<d[I,j]
C[I,j]=color
;
End
}
Calculating depth values efficiently
●
We know the depth values at the vertices.
How can we calculate the depth at any other
point on the surface of the polygon.
● Using the polygon surface equation:
Ax By D
z
C
Calculating depth values efficiently
For any scan line adjacent
horizontal x positions or vertical
●
Z-Buffer
Example
Not Parallel
Depth buffer method (Image
space method)
• It is an image-space approach. The basic idea is to
test the Z-depth of each surface to determine the
closest (visible) surface.
• The depth values for a pixel are compared and the
closest (smallest z) surface determines the color to
be displayed in the frame buffer.
Depth buffer method
Advantages
1. It is easy to implement.
2. It reduces the speed problem if
implemented in hardware.
3. It processes one object at a time.
Disadvantages
4. It requires large memory.
5. It is time consuming process.
Z-BUFFER ALGORITHM:
• Its an extension of Frame Buffer
• Display is always stored on Frame Buffer
• Frame Buffer stores information of each and every
pixel on the screen
• Bits (0, 1) decide that the pixel will be ON or OFF
z display
Pseudocode for the z-buffer algorithm
void zBuffer(void)
{
int x,y;
• The active list stores only those edges that cross the
scan-line in order of increasing x
• Two important
tabl
tables, and
edge
e arepolygon
tabl maintained
e, for
this.
Scan line
method
www.sachinplacement.blogspot.com
or mail at
[email protected]