Docsity

Assignment 4 Questions - Advanced Computer Graphics | CMSC 740, Assignments of Computer Graphics

Toggle sidebar
bg1
Assignment 4
CMSC 740, Spring 2001
Due: 4:00pm Wednesday, May 9, 2001
This assignment involves texture mapping and computing illumination. Datasets are at:
http://www.cs.umd.edu/class/spring2001/cmsc740/ assg4/data/ You can get other
free datasets from the web. All code must be your own.
(a) The object datafile for this assignment is temple.obj. The object colors have been computed
after running the radiosity simulation. This dataset is from Lightscape Inc, which we have converted into
the data file format of Assignment 2:
v x1y1z1r1g1b1
v x2y2z2r2g2b2
.
.
.
v xnynznrngnbn
f i11 i12 i13
f i21 i22 i23
.
.
.
f im1im2im3
This file has mfaces (assume all are triangles) and nvertices with coordinates and colors. Each triangle
has three indices ijk that each references a vertex 1≤ijk ≤n.
You will texture map a brick texture to the walls of the above object. Read the file brick.ppm. You
implemented a PPM-format image reader in Assignment 1. (5)
(b) Identify all the vertical triangles in the temple (triangles whose normals have an component of
the normal in the zdirection. Using OpenGL texture-mapping capabilities, texture map the above vertical
triangles with the brick texture. Here are some of the things that you will need to keep in mind: (i) Make
sure that the image dimensions are a power of two (this is an OpenGL texture map requirement). If they are
not, you can use gluScaleImage to do this, (ii) You need to assign uand vcoordinates to the triangles so that
the texture is mapped continuously – figure out how to do this (there are several ways), (iii) If you stretch
the brick texture to cover the entire model, it will look very grainy; therefore you will need to tile textures
across triangles and figure out how to do this. (10)
(c) After the texture-mapping is working well, you will realize that the radiosity solution is no longer
being seen through the textures, i.e. all the walls have the same texture with no bright or dark areas. To get
the underlying radiosity solution to be seen in addition to the texture, you can blend in the radiosity colors
with the texture colors in OpenGL using texture functions. Implement this using OpenGL’s glTexEnv*
function. (5)
(d) Thus far in this assignment you were using radiositized colors and so you should not have been using
lights. Now we will ask you to read beethoven.obj file in this texture-mapped and radiosity illuminated
temple. Place the Beethoven’s bust in the temple such that its center lies at (2.5,0,1). The scaling factor for
the bust is (1,1,1), i.e. you will not need any scaling. Place the eye-point at (6.5,0,1), with a field of view
of 60o. Have the viewer look at the center (2.5,0,1). As in Assignment 3, set up the four light sources at
infinity and then for Beethoven’s bust compute the diffuse and specular illumination yourself at each vertex.
Send the thus computed colors to OpenGL for shading. (5)

Partial preview of the text

Download Assignment 4 Questions - Advanced Computer Graphics | CMSC 740 and more Assignments Computer Graphics in PDF only on Docsity!

Assignment 4

CMSC 740, Spring 2001

Due: 4:00pm Wednesday, May 9, 2001

This assignment involves texture mapping and computing illumination. Datasets are at: http://www.cs.umd.edu/class/spring2001/cmsc740/ assg4/data/ You can get other free datasets from the web. All code must be your own.

(a) The object datafile for this assignment is temple.obj. The object colors have been computed after running the radiosity simulation. This dataset is from Lightscape Inc, which we have converted into the data file format of Assignment 2:

v x 1 y 1 z 1 r 1 g 1 b 1 v x 2 y 2 z 2 r 2 g 2 b 2 .. . v xn yn zn rn gn bn f i 11 i 12 i 13 f i 21 i 22 i 23 .. . f im 1 im 2 im 3

This file has m faces (assume all are triangles) and n vertices with coordinates and colors. Each triangle has three indices ijk that each references a vertex 1 ≤ ijk ≤ n. You will texture map a brick texture to the walls of the above object. Read the file brick.ppm. You implemented a PPM-format image reader in Assignment 1. (5) (b) Identify all the vertical triangles in the temple (triangles whose normals have an  component of the normal in the z direction. Using OpenGL texture-mapping capabilities, texture map the above vertical triangles with the brick texture. Here are some of the things that you will need to keep in mind: (i) Make sure that the image dimensions are a power of two (this is an OpenGL texture map requirement). If they are not, you can use gluScaleImage to do this, (ii) You need to assign u and v coordinates to the triangles so that the texture is mapped continuously – figure out how to do this (there are several ways), (iii) If you stretch the brick texture to cover the entire model, it will look very grainy; therefore you will need to tile textures across triangles and figure out how to do this. (10) (c) After the texture-mapping is working well, you will realize that the radiosity solution is no longer being seen through the textures, i.e. all the walls have the same texture with no bright or dark areas. To get the underlying radiosity solution to be seen in addition to the texture, you can blend in the radiosity colors with the texture colors in OpenGL using texture functions. Implement this using OpenGL’s glTexEnv* function. (5) (d) Thus far in this assignment you were using radiositized colors and so you should not have been using lights. Now we will ask you to read beethoven.obj file in this texture-mapped and radiosity illuminated temple. Place the Beethoven’s bust in the temple such that its center lies at (2. 5 , 0 , 1). The scaling factor for the bust is (1, 1 , 1), i.e. you will not need any scaling. Place the eye-point at (6. 5 , 0 , 1), with a field of view of 60 o. Have the viewer look at the center (2. 5 , 0 , 1). As in Assignment 3, set up the four light sources at infinity and then for Beethoven’s bust compute the diffuse and specular illumination yourself at each vertex. Send the thus computed colors to OpenGL for shading. (5)