CMSC 635: Advanced Computer Graphics

Lab 2: Texture Mapping
Due April 16, 1999.


Computer Science and Electrical Engineering Department
University of Maryland, Baltimore County

Spring 1999


Purpose:

To gain experience implementing texture mapping and anti-aliasing techniques.


Assignment

You need to modify your renderer to implement texture-mapping using polar-coordinates, implement bump-mapping, and mip-mapping. The following input command changes are needed:
color_type: 8 filename u_res v_res 0/1
0 = per_face says to use inverse-bilinear mapping to each face,
1 = wrap_map says to wrap the texture around the object.
You need only implement wrap_map
This should use mip-mapping. See the file read_table_color_mip.c

normal_type: 8 filename u_res v_res 0/1

apply the texture map as a bump map, modifying the surface normal. Again for this, only polar coordinate mapping is required.

Extra Credit


Detailed changes needed:

NOTES:

You need to map pixel corners back for mip-mapping. The code above gives the image space location from the screen coordinates for x.

   /*    calc x image space distance between 2 pixels */
    x_inv_map(10,&xl, width); x_inv_map(11, &xt, width);
    d_pix_x = xl-xt;

For y, add and subtract 1/2 scanline. delta_y_iumage for 1/2 scanline is the following:

   numsl = (view_p.vt - view_p.vb)/2 * Y_RES;
   delta_y_image =( 2.0 * (0.5)/(double)(numsl-1));

For Bump Mapping, here is example code to calculate Pu and Pv


  pv_0.x = wld_sp[0].x + ansv*(wld_sp[1].x-wld_sp[0].x);
  pv_0.y = wld_sp[0].y + ansv*(wld_sp[1].y-wld_sp[0].y);
  pv_0.z = wld_sp[0].z + ansv*(wld_sp[1].z-wld_sp[0].z);

  pv_1.x = wld_sp[3].x + ansv*(wld_sp[2].x-wld_sp[3].x);
  pv_1.y = wld_sp[3].y + ansv*(wld_sp[2].y-wld_sp[3].y);
  pv_1.z = wld_sp[3].z + ansv*(wld_sp[2].z-wld_sp[3].z);

  Pu.x = pv_1.x -pv_0.x;
  Pu.y = pv_1.y -pv_0.y;
  Pu.z = pv_1.z -pv_0.z;

  pu_0.x = wld_sp[0].x + ansu*(wld_sp[3].x-wld_sp[0].x);
  pu_0.y = wld_sp[0].y + ansu*(wld_sp[3].y-wld_sp[0].y);
  pu_0.z = wld_sp[0].z + ansu*(wld_sp[3].z-wld_sp[0].z);

  pu_1.x = wld_sp[1].x + ansu*(wld_sp[2].x-wld_sp[1].x);
  pu_1.y = wld_sp[1].y + ansu*(wld_sp[2].y-wld_sp[1].y);
  pu_1.z = wld_sp[1].z + ansu*(wld_sp[2].z-wld_sp[1].z);

  Pv.x = pu_1.x -pu_0.x;
  Pv.y = pu_1.y -pu_0.y;
  Pv.z = pu_1.z -pu_0.z;  

  cross_xyz(Pu,norm,&pv_temp);
  cross_xyz(norm,pv_temp,&Pu);
  
  cross_xyz(Pv,norm,&pv_temp);
  cross_xyz(norm,pv_temp,&Pv);

How to get object Center


David S. Ebert
Last modified: Tues March 10 9:48:15 EST