OpenGL OpenGL Lighting and Materials 1 — Questions and Answers
Question 1: In OpenGL's Phong lighting model, which component represents light scattered equally in all directions regardless of viewing angle?
- Specular
- Diffuse
- Ambient (Correct answer)
- Emissive
Correct answer: Ambient
Ambient light is a constant, non-directional approximation of indirect light that illuminates all surfaces equally regardless of orientation or viewer position.
Question 2: Which OpenGL fixed-function call correctly sets the position of a light source?
- glLightfv(GL_LIGHT0, GL_POSITION, pos) (Correct answer)
- glSetLight(GL_LIGHT0, pos)
- glLightPosition(GL_LIGHT0, pos)
- glBindLight(GL_LIGHT0, pos)
Correct answer: glLightfv(GL_LIGHT0, GL_POSITION, pos)
glLightfv() is the correct function for setting float vector parameters of a light source, using GL_POSITION as the parameter name.
Question 3: In the Phong reflection model, the specular component is determined by which pair of vectors?
- Light direction and surface normal only
- View direction and reflection vector (Correct answer)
- Eye position and light position only
- Surface tangent and bitangent
Correct answer: View direction and reflection vector
The specular term is computed from the dot product of the view (eye) direction and the reflection vector, raised to the shininess exponent.
Question 4: What does the GL_SHININESS material parameter control in OpenGL's legacy lighting model?
- The brightness of the ambient light
- The size and sharpness of specular highlights (Correct answer)
- The diffuse reflectivity of the surface
- The number of active light sources
Correct answer: The size and sharpness of specular highlights
GL_SHININESS is the specular exponent; higher values produce smaller, sharper highlights while lower values create broader, softer ones.
Question 5: What is the maximum number of light sources supported by OpenGL's fixed-function pipeline (GL_MAX_LIGHTS)?
- 4
- 8 (Correct answer)
- 16
- 32
Correct answer: 8
The OpenGL specification guarantees at least 8 light sources (GL_LIGHT0 through GL_LIGHT7) in the fixed-function pipeline.
Question 6: Which lighting components require correctly defined surface normal vectors to produce accurate results?
- Ambient only
- Emissive only
- Both diffuse and specular (Correct answer)
- Neither diffuse nor specular
Correct answer: Both diffuse and specular
Diffuse lighting uses the angle between the normal and light direction, and specular lighting uses the normal to compute the reflection vector — both depend on accurate normals.
Question 7: In OpenGL's legacy lighting, what does enabling GL_LIGHT_MODEL_TWO_SIDE accomplish?
- Enables two light sources simultaneously
- Performs lighting calculations for both front and back faces of polygons (Correct answer)
- Enables two-sided texture mapping
- Creates shadow effects on both sides of a surface
Correct answer: Performs lighting calculations for both front and back faces of polygons
GL_LIGHT_MODEL_TWO_SIDE causes OpenGL to compute separate lighting for back-facing polygons using GL_BACK material properties instead of ignoring them.
In OpenGL's Phong lighting model, which component represents light scattered equally in all directions regardless of viewing angle?