Polygon Rendering ------------------------------------------------------------------------ As my opinion polygon rendering is a difficult topic in object rendering in the computer graphics but of the basic importance. The difficulty is that when you draw a pixel on the screen you maybe need to determine whether a ray from the viewpoint or a light source to a pixel will hit a polygon. If the object you consider is a sphere or a plane you will feel comfortable to find the intersection point. But if it is a polygon, O.K. you need to consider a lot of things since it is not simple to determine whether a ray intersects with a polygon. The polygon being one of our primitives shows its importance because most real objects can be partitioned into pieces of polygons by required precisions. The following skull and flask will show you this effect. LEFT: The skull is made up from many many polygons. Is it a skull? RIGHT: And how about this flask? ------------------------------------------------------------------------ When you determine whether you need drawing some part of an object in your viewport, of coure, you depend on whether you can see it, right? O.K., what are the methods used in the computer graphics? For simplicity you can use the "back-face removal" not to draw those parts of the object that you cannot see them. That means that you pre-determine which parts (faces) of an object is front-facing or back-facing to your eyes and you just draw those faces front-facing to you. To draw a house we can use this method as the following pictures show. The house is built by several polygons and we define each plane holding a polygon has a normal vector pointing outside of the house, then we just draw those polygons whose normals point to that side the viewpoint is located. LEFT: Only this wall is front facing to you and you see it, so draw it. RIGHT: From this direction you can see more faces of the house. ------------------------------------------------------------------------ How can you draw a 3_D object on a 2_D viewport? Of course you need to process the real 3_D object into your viewport to its 2_D image, i.e., you need to do the viewing transformation. The process consists of following 3 steps: 1. Normalizing transformation Nper --- transform the object into the cannonical volume(sometimes you need doing clipping). This transformation is definitely influented by your viewing point(VRP & PRP), viewing direction(VPN & VUP) and the size of the viewing window(u_min, u_max, v_min and v_max in VRC). This transformation can be completed by a. setting up VRC by gettting orthogonal u, v and n; b. translating VRP to ORIGIN of the WRC; c. rotating u, v and n to align them with x, y and z axes; d. translating PRP to ORIGIN; e. shearing so that the center of the viewing window is on z-axis; f. scaling to get a cannonical view volume. This transformation can be expressed as Nper = S(x,y,z) * Sh(x,y) * T(-PRP) * R * T(-VRP). 2. Perspective projection Pper --- project the "object" in the volume into the viewing(projection) plane to a 2_D images; 3. Viewport mapping Mper --- map every point of the image to the corresponding pixel on the viewport within the interface window. Below we show you some pictures about 3_D view in 2_D viewports. The house shown has the same vertices as the above one in WRC, but we choose different viewing data, such as VRP, PRP, VUP, F, B, etc. So we have different views about the house. The corresponding data is hidden behind the pictures. After the above three steps the house looks like the followings in 2_D. LEFT: The viewpoint(PRP) is in front, on right and a lttle above of the house. RIGHT: VPN vector rotates a little angle. ABOVE:The viewpoint is is still in front of but on left of the house, and the window size is increased. You can find the detailed TRANSFORMATION here and its VIEW VOLUME. ------------------------------------------------------------------------ Sometimes you just want to view some part of an object instead of the whole object, so you want to CLIP out the other part of the object. For convenience we always do clipping immediately after the normalizing transformation (1st step). To do this you just set two constants F(front) and B(back) to set two clipping planes so that the part of the object you want to view is between the two planes. These two palnes together with the viewing window through which you view the world determine the view volume. In order to clearly see the effect of clipping we draw the above house by only drawing those line segments co nnecting two vertices of the house. ABOVE: No clipping. LEFT: Clipping at the front. RIGHT: Clipping at the back. LEFT: Clipping at the front. RIGHT: Clipping at the back. ------------------------------------------------------------------------ For your better understanding of the influences of viewing data on the 2_D images, you can get those data that help get the above pictures by clicking the corresponding pictures. But sometimes two different sets of viewing data can result the same picture.