An uncomplicated depth sort is easy to implement;
An uncomplicated depth sort is easy to implement; however, once you start using it you will begin to see strange rendering artifacts. The essential problem comes down to how you measure the distance a triangle is from the viewer. Perhaps you would Take the average distance of each of the three vertices Take the distance of the centroid of the triangle With either of these simple techniques, you can generate scenes with configurations of triangles that render incorrectly. Typically, problems occur when: Triangles intersect Centroid or average depth of the triangle is not representative of the depth of the corners Complex shapes intersect Shapes require splitting to render correctly For example, figure 2.5 shows some complex configurations of triangles that cannot be depth sorted using a simple algorithm. Figure 2.5 Interesting configurations of triangles that are challenging for depth-sorting algorithms The depth of an object in the scene can be calculated if the position of the object is known and the position of the viewer or image plane is known. It would be computationally intensive to have to re-sort all the triangles in the scene every time an object or the viewer s position changed. Fortunately, binary space partition (BSP) trees can be used to store the relative positions of the object in the scene such that they do not need to be re-sorted when the viewpoint changes. BSP trees can also help with some of the complex sorting configurations shown earlier. Depth buffer (Z-buffer) In contrast to the other two algorithms, the Z-buffer technique operates in image space. This is conceptually the simplest technique and is most commonly implemented within the hardware of 3D graphics cards. If you were rendering at 640 480 resolution, you would also allocate a multidimensional array of integers of size 640 480. The array (called the depth buffer or Z-buffer) stores the depth of the closest pixel rendered into the image. As you render each triangle in your scene, you will be drawing pixels into the frame-buffer. Each pixel has a color, and an xy-coordinate in image space. You would also calculate the z-coordinate for the pixel and update the Z-buffer. The values in the Z-buffer are the distance of each pixel in the frame from the viewer. 18
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services