Page 163 - DCAP504_Computer Graphics
P. 163

Computer Graphics



                          Object space method compares objects and parts of objects to each other in order to decide the visibility.
                          The different types of object space methods are back face and Painter’s algorithm.
                          Image space method decides visibility point by point at each  pixel position on the view plane. The
                          different types of image space methods are area subdivision, Z-buffer, and scan line.




                          Did you know?   Image space method requires more work than object space method. Therefore, most
                                        algorithms should theoretically be applied in object space. This  is not the case in
                                        general. Image space methods are considered to be more efficient because it is easier to
                                        take advantage of consistency in raster scan implementation of an image space
                                        method.

                          11.1   Z-Buffer

                          Z-buffer is one of the simplest and commonly used image space approaches to eliminate hidden
                          surfaces. This is referred to as the z-buffer, since depth of an object is mainly calculated from the view
                          plane along the z axis of a coordinate system.
                          A 3-D shape is a collection of 3-D surfaces or planar surface patches. A planar equation can be used to
                          estimate each of these surfaces. The planar equation helps to evaluate the Z co-ordinate value of each of
                          the planar surface points in world co-ordinates.

                                      Once you  have defined the  Z buffer, Direct3-D  will automatically stop  rendering
                                      triangles that are hidden by other triangles. The planar equation helps to evaluate the Z
                                      co-ordinate value of each of the planar surface points in world co-ordinates.


                          When 3-D shapes are projected onto the 2-D computer screen, the position of each pixel on the view
                          plane is represented by x and y coordinates, whereas the z-value holds the information about depth. For
                          every (X, Y) screen location, there is one or more 3-D surface points. The different Z co-ordinate values
                          of these 3-D surface points are defined by the planar equations of the surfaces. These Z values are then
                          compared to determine the visible surface points. A surface is considered visible if it has the minimum
                          Z value. It is important to know that in the corresponding (X, Y) location of the screen, the color of the
                          visible surface point is painted.





                          Did you know?   The Z-buffer algorithm was invented by E. Catmull around the 1970s. It is very simple
                                        and can handle just about any 3-D primitive. Since then, it has become the most
                                        preferred choice for hardware accelerated 3-D boards.

                          The equation of a planar surface is given by, Ax + By + Cz + D = 0, where vectors (A, B, C) are normal to
                          the plane and D is constant.
                          As mentioned earlier, Z-buffer algorithm operates on planar surfaces of a 3-D shape in order to
                          determine visible surfaces. Therefore, the Z value of the plane at location (X, Y) is given by:
                                                 Z = - Ax – By – D/ C       …. (Eq.11.1)
                          Consider a 3-D viewpoint looking at a planar surface, where the Z value of the surface gives the depth
                          of the surface from the viewpoint. Therefore, this algorithm is also known as depth buffer algorithm.
                          For planes with known equations, the visibility of planes can be determined by comparing Z values of
                          these planar points.
                          Let us assume that Z values are written in a 2-D matrix of the same size as a computer screen and let us
                          henceforth refer to it as Z-buffer.  Initially, the Z-buffer values for all the elements of the entire 2-D
                          matrix are set to a maximum possible number. Also, initialize a 2-D screen matrix of same size as Z-



                          156                     LOVELY PROFESSIONAL UNIVERSITY
   158   159   160   161   162   163   164   165   166   167   168