A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 1
COMPUTER GRAPHICSCOMPUTER GRAPHICS
Visible Surface DetectionVisible Surface Detection
(Z-Buffer/Depth Buffer)(Z-Buffer/Depth Buffer)
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 2
DEPTH-BUFFER METHODDEPTH-BUFFER METHOD
 Compares surface depth values throughout a scene
for each pixel position on the projection plane
 Usually applied to scenes only containing polygons
 Fast approach due to easy depth values computation
 Also often called the z-buffer method
(x2, y2) & z2
(x3, y3) & z3
(x1, y1) & z1
 (x1, y1), (x2, y2) &
(x3, y3) are the pixel
positions of surfaces
S1, S2, and S3
respectively.
 z1, z2 and z3 defines
the depth values
(distance) of surfaces
S1, S2, and S3
respectively from the
View Plane
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 3
DEPTH-BUFFER METHOD (Cont…)DEPTH-BUFFER METHOD (Cont…)
1. Initialise the depth buffer and frame buffer so that for
all buffer positions (x, y)
depthBuff(x, y) = 1.0
frameBuff(x, y) = bgColour
2. Process each polygon in a scene, one at a time
– For each projected (x, y) pixel position of a
polygon, calculate the depth z (if not already
known)
– If z < depthBuff(x, y), compute the surface colour
at that position and set
depthBuff(x, y) = z
frameBuff(x, y) = surfColour(x, y)
 After all surfaces are processed depthBuff and frameBuff
will store correct values
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 4
DEPTH CALCULATIONDEPTH CALCULATION
ExampleExample
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 5
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
6 6 6 6 6 6 6
6 6 6 6 6 6
6 6 6 6 6
6 6 6 6
6 6 6
6 6
6
6 6 6 6 6 6 6 1
6 6 6 6 6 6 1 1
6 6 6 6 6 1 1 1
6 6 6 6 1 1 1 1
6 6 6 1 1 1 1 1
6 6 1 1 1 1 1 1
6 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
6 6 6 6 6 6 6 1
6 6 6 6 6 6 1 1
6 6 6 6 6 1 1 1
6 6 6 6 1 1 1 1
6 6 6 1 1 1 1 1
6 6 1 1 1 1 1 1
6 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
Surface-1
Depth Buffer
Depth Buffer Frame Buffer
ExampleExample
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 6
6 6 6 6 6 6 6 1
6 6 6 6 6 6 1 1
6 6 6 6 6 1 1 1
6 6 6 6 1 1 1 1
6 6 6 7 1 1 1 1
6 6 7 7 7 1 1 1
6 7 7 7 7 7 1 1
1 1 1 1 1 1 1 1
6 6 6 6 6 6 6 1
6 6 6 6 6 6 1 1
6 6 6 6 6 1 1 1
6 6 6 6 1 1 1 1
6 6 6 1 1 1 1 1
6 6 1 1 1 1 1 1
6 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
7 1 1 1 1 1 1 1
7 1 1 1 1 1 1
7 1 1 1 1 1
7 1 1 1 1
7 1 1 1
7 1 1
1 1 1 1 1 1 1 1
7 7 7 7 7
7 7 7 7
7 7 7
7 7
7
6 6 6 6 6 6 6 1
6 6 6 6 6 6 1 1
6 6 6 6 6 1 1 1
6 6 6 6 1 1 1 1
6 6 6 1 1 1 1 1
6 6 1 1 1 1 1 1
6 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
Surface-2Depth Buffer
Depth Buffer Frame Buffer
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 7
Iterative Calculations (cont…)Iterative Calculations (cont…)
top scan line
bottom scan line
y scan line
y - 1 scan line
x x’
A. K. Biswas, Dept. Of Computer Apllication, B.I.T., Durg 8
DISADVANTAGES OF DEPTH BUFFERDISADVANTAGES OF DEPTH BUFFER
This method only find out one visible surface
at each pixel position that means it deals
with only Opaque surface.
1
2
3
4
5
6
1 Red
2 Red
3 Green
4 Blue
5 Green
6 Red

Z buffer

  • 1.
    A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 1 COMPUTER GRAPHICSCOMPUTER GRAPHICS Visible Surface DetectionVisible Surface Detection (Z-Buffer/Depth Buffer)(Z-Buffer/Depth Buffer)
  • 2.
    A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 2 DEPTH-BUFFER METHODDEPTH-BUFFER METHOD  Compares surface depth values throughout a scene for each pixel position on the projection plane  Usually applied to scenes only containing polygons  Fast approach due to easy depth values computation  Also often called the z-buffer method (x2, y2) & z2 (x3, y3) & z3 (x1, y1) & z1  (x1, y1), (x2, y2) & (x3, y3) are the pixel positions of surfaces S1, S2, and S3 respectively.  z1, z2 and z3 defines the depth values (distance) of surfaces S1, S2, and S3 respectively from the View Plane
  • 3.
    A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 3 DEPTH-BUFFER METHOD (Cont…)DEPTH-BUFFER METHOD (Cont…) 1. Initialise the depth buffer and frame buffer so that for all buffer positions (x, y) depthBuff(x, y) = 1.0 frameBuff(x, y) = bgColour 2. Process each polygon in a scene, one at a time – For each projected (x, y) pixel position of a polygon, calculate the depth z (if not already known) – If z < depthBuff(x, y), compute the surface colour at that position and set depthBuff(x, y) = z frameBuff(x, y) = surfColour(x, y)  After all surfaces are processed depthBuff and frameBuff will store correct values
  • 4.
    A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 4 DEPTH CALCULATIONDEPTH CALCULATION
  • 5.
    ExampleExample A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 1 1 6 6 6 6 6 1 1 1 6 6 6 6 1 1 1 1 6 6 6 1 1 1 1 1 6 6 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 1 6 6 6 6 6 6 1 1 6 6 6 6 6 1 1 1 6 6 6 6 1 1 1 1 6 6 6 1 1 1 1 1 6 6 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Surface-1 Depth Buffer Depth Buffer Frame Buffer
  • 6.
    ExampleExample A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 1 1 6 6 6 6 6 1 1 1 6 6 6 6 1 1 1 1 6 6 6 7 1 1 1 1 6 6 7 7 7 1 1 1 6 7 7 7 7 7 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 1 6 6 6 6 6 6 1 1 6 6 6 6 6 1 1 1 6 6 6 6 1 1 1 1 6 6 6 1 1 1 1 1 6 6 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 1 1 7 1 1 1 1 1 1 7 1 1 1 1 1 7 1 1 1 1 7 1 1 1 7 1 1 1 1 1 1 1 1 1 1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 1 6 6 6 6 6 6 1 1 6 6 6 6 6 1 1 1 6 6 6 6 1 1 1 1 6 6 6 1 1 1 1 1 6 6 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Surface-2Depth Buffer Depth Buffer Frame Buffer
  • 7.
    A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 7 Iterative Calculations (cont…)Iterative Calculations (cont…) top scan line bottom scan line y scan line y - 1 scan line x x’
  • 8.
    A. K. Biswas,Dept. Of Computer Apllication, B.I.T., Durg 8 DISADVANTAGES OF DEPTH BUFFERDISADVANTAGES OF DEPTH BUFFER This method only find out one visible surface at each pixel position that means it deals with only Opaque surface. 1 2 3 4 5 6 1 Red 2 Red 3 Green 4 Blue 5 Green 6 Red