Modify your C++ ray tracing program to include the ability to render objects with bump maps and reflectivity maps. Also, add interpolation to all map look-up operations to decrease pixelation of low resolution image maps. A reflectivity map specifies variable reflectivity across the surface of an object. A bump map specifies variable surface normals that are different than a surface's actual normal.
A material library file can specify reflectivity maps for the ambient, diffuse, and specular reflectivity of a material. These files are specified as follows:
map_Ka ambient_map.ppm
map_Kd diffuse_map.ppm
map_Ks specular_map.ppm
map_Ns specular_exponent_map.ppm
Note that Ns is a scalar in the range of 0 to 1000, but the pixels in an image are three values in the range of 0 to 255. To compute the specular reflectivity scalar from a color, use the red channel and scale it to the range of 0 to 1000. The material class should have image pointer member variables for each of the above image maps. The illumination calculations of a material that contain reflectivity maps are modified to multiply the cooresponding reflectivity with the mapped relectivity. For example the ambient illumination equation for a single light becomes:
Ia = Ka * map_Ka.getPixel(u, v) * ia
Where Ka is the material's ambient reflectivity, map_ka is the ambient reflectivity image, u and v are the map coordinates for the intersection location, and ia is the light's ambient intensity. A material library file can also specify a bump, or normal, map as follows:
bump bump_map.ppm
A normal map is an image where the rgb values of each pixel coorespond to the xyz values of normals. Note that the rgb values are integers in the range of 0 to 255, while normals are floats that can have negative values. To compute a normal from a color, create a vector with each value minus 127.5 and then normalize the vector. The illumination calculations of a material that contains a bump map are modified to use the mapped normal instead of the surface normal.
If the resolution of a map image is not sufficient for the size or viewing distance of an object, the object will be rendered with a pixelated surface. This effect can be mitigated by interpolating image map pixels values based on the fractional values of the texture uv coordinates. Add bilinear or bicubic interpolation to all map look-up operations.
Tar your code in a file that contains your name and submit it on the course Inquire site.