Graphics Systems (LEEC)

1.      Illumination model

The aim of this exercise is to study local illumination models, mainly by changing material (diffuse and specular characteristics) and light properties.

Fig. 1 - 3D scene to create using OpenGL

The zip file G1_Ilum it is supplied a C program that produces part of the scene shown in figure 1. For now the attention should be given for the global variable declarations and the function  display() and inicializacao(). In the display() function we put the code that should be executed in every screen refresh (several times per second), while in the inicializacao()function we put the instruction that can be executed just once.

Compile and execute the code given. As you can see, the initial scene contains:

  1. A punctual light source, positioned in the space at the coordinates given by light0_position[]. Note that the light source in not visible so that there is a sphere for you to identity it better;
  2. A colored axis system (x, y, z = R, G, B) each one obtained by gluCylinder()
  3. An horizontal plane divided in small polygons (GL_TRIANGLE_STRIP);
  4. Two faces of a box located below the former plane (GL_POLYGON, inside the function  myBox() );

The punctual light source properties are declared in the variables light0_xxx and take effect by calling the function glLightfv(). The ambient component light_ambient[]is activated by calling glLightModelfv().

The plane and the box have the same material properties (mat1_xxx); the 3 axis have no material defined, instead their color is directly defined with glColor3f().

Note: it is advised to read the chapter 6 of OpenGL Programming Guide  that describes the main function of the OpenGL light model. The chapters 1-Introduction to OpenGL and 2-Drawing Geometric Objects are also considered indispensable in order to have a good understanding of the OpenGL technology. The OpenGL Reference Manual and OpenGL Online Manual contain the functions syntax and describe their meaning.

1.     Complete the scene as shown in figure 1, by finishing the box and by putting the white sphere at the origin.

a)     The box is drawn in myBox() and is a collection of individual polygons (GL_POLYGON); the polygon front is defined by the counter clockwise order of vertices. The surface normal used by the illumination model is defined by glNormal3d().

b)     The white sphere that is at the origin is drawn by gluSphere() from the GLU-OpenGL Utility Library (see OpenGL Online Manual).

2.     Turn off LIGHT0, so that only ambient light is on. Analyze the illumination value obtained in each object.

3.     Turn on LIGHT0 and turn off ambient light. Analize the image and identify, on the horizontal plane, the diffuse and specular reflection effects.

4.     Turn on ambient light and compare with the last result. Take particular attention to the lateral and inferior faces of the box.

5.     Try to answer to the following questions before experimenting them on the program.

a)     What is the effect, on the plane surface, if the LIGHT0 y coordinate is increased?

b)     What happens to the specular reflection if the parameter mat1_shininess[]is changed? For example, if it assumes values like 4, 16, 64, 128.

c)     What happens to the specular reflection if the parameter mat1_shininess[r,g,b]is changed? Experiment the following values {0.0,0.0,0.0}, {0.2,0.2,0.2}, {0.4,0.4,0.4}, {0.6,0.6,0.6}, {0.8,0.8,0.8}, {1.0,1.0,1.0} with mat1_shininess=128.

6.     Modify the RGB coefficients of the ambient and diffuse reflection of the material mat1_xxx so that R and G component are equal to zero. What happens in the following conditions:

a)     With the initial specular coefficients;

b)     By zeroing the R and G components of the specular reflectiom;

c)     By putting also LIGHT0 with pure yellow color.

7.     Insert, to the LIGHT0 declaration, the parameters light0_kc, light0_kl e light0_kq used by the illumination model to attenuate the light intensity with distance. The following instruction should be inserted also in the inicializacao():

      glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION,  light0_kc);

      glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION,    light0_kl);

      glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, light0_kq);

a)     Make light0_kc=1.0, light0_kl=0.0 and light0_kq=0.0; comment the plane illumination obtained (diffuse and specular illumination, vertices illumination, general illumination aspect …), for the following situations light0_y=1, light0_y=3 e light0_y=6.

b)     Repeat the former question with light0_kc=0.0, light0_kl=1.0 e light0_kq=0.0.

c)     Also with light0_kc=0.0, light0_kl=0.0 e light0_kq=1.0

8.     How do you confirm that there is no shadow projections?

9.     Justify why the plane is built with many and small polygons instead of a single polygon like the box.

AAS/JGB/JVV