ICS 186A : Computer Graphics

Assignment 6

 

Texture Mapping 

Assigned: 24 Feb, 2003

Due: 3 Mar, 2003.

 

 

  1. In the red book, there is an example texture mapping program, in which a checker-board texture is created. Use this texture to texture-map a quadrilateral consisting of two triangles. DO NOT USE ONE QUADRILATERAL. YOU HAVE TO USE TWO TRIANGLES TO REPRESENT A QUADRILATERAL. Add a light to the scene in an appropriate position such that it makes a difference in the scene. You should have user interface to rotate (about itself), translate, and zoom in/out the quadrilateral. You donÕt need to move the light.

 

  1. The program you write has four different states depending on how you issue the vertices of the quadrilateral to OpenGl.  For all the four states, you do the following:

 

    1. perform all the transformation using OpenGl (you can use your own transformation code, if you want to)
    2. get the OpenGlÕs latest modelview and projection matrices in your own matrices (modview and projection). 
    3. Load identity matrices into the modelview and projection stacks of OpenGl.
    4. Issue the vertices of the triangle under the following four states.

 

State 1:  OpenGl Transformation: Load the modview matrix in the ModelView stack of OpenGl and projection in the projection stack of OpenGl. (Basically, you get the matrix from OpenGl, and load the same matrix again into the OpenGl stacks. This shouldnÕt change any of the results.) Issue the vertices along with their normal vector, and texture coordinates. OpenGl does the transformation of vertices and the rasterization, including texture mapping.

 

State 2: Your Transformation: In this state, you do the transformation, and let OpenGl do the rasterization (interpolation of texture coordinates and lighting). Multiply the modview matrix with vertex, and then multiply the projection matrix with this result. You will get a 4D point, with w != 1 (usually). Issue this transformed vertex using glVertex4f command. Remember, since you loaded the identity matrix into the OpenGl matrices earlier, OpenGl does not do any transformation. (It does, but just multiplies the identity matrix with the vertex, and hence does not change anything.) But it just does the rasterization.

 

State 3: Same as State 2, but set w=1 to all the vertices, before sending it to OpenGl using the glVertex4f command.

 

State 4: Same as State 2 (NOTE STATE 2 NOT 3!), but set z=c where c is any constant between 0 and 1 (excluding 0 and 1).

 

 

  1. View the quadrilateral in two different positions. 1. (Close to) Perpendicular to the viewing direction. 2. At a grazing angle.  (Just rotate the quadrilateral to get it into these orientations.) Under these two viewing conditions go through the above four states and document the results.

 

  1.  Press Ō to go through the above four states one after another in a cyclic manner. Print out what state you are in whenever you change state.

 

 

  1. Documentation should include eight images for 4 states x  2 views, and serious detailed explanation of your results.