CS 381
>
Week 11 Review Problems
CS 381, Fall 2003
Week 11 Review Problems
Below are some problems related to the material covered
in class recently.
Answers are in the
Answers section, below.
Do not turn these in.
You can expect the Final Exam (on Wednesday, December 17)
to contain problems similar to some of these.
Problems
- A number of direction vectors come into the Phong-Model computations:
the surface normal, the viewing direction, and the lighting direction.
For each of the following Phong Model components,
list which direction vectors affect the computation.
a. Ambient.
b. Diffuse.
c. Specular.
- In which computation in the Phong Model is there absolutely no physical basis for the formula used?
- Explain the difference in OpenGL between enabling a “light” and enabling “lighting”.
- Suppose we place an OpenGL light at position (1, 1, –1).
a. What visible effect does this produce at location (1, 1, –1)?
b. Suppose we want this light source to appear as a glowing cube.
How do we do this?
- What is the best way to make a light appear to move in OpenGL?
- Explain exactly what OpenGL’s “double-sided lighting ” does.
- What is it about OpenGL’s double-sided lighting that makes correct normal vectors
especially important?
- What fact about double-sided lighting shows that lighting computations
cannot all be done between model/view and projection?
- In OpenGL, what is a “spotlight”?
- It would seem reasonable to specify how wide a spotlight is, using a cutoff angle.
And, indeed, OpenGL makes that available.
But there is a better way.
What is it, and why is it better?
- a. Explain OpenGL’s “local-viewer” mode:
what is it, and what happens when it is off?
b. When is local-viewer mode necessary?
- Good old Egbert is writing an OpenGL program.
He has enabled lighting and disabled all lights.
“And yet,” he complains, “my objects still appear to have a little bit of
light shining on them!”
Where is Egbert’s light most likely coming from?
- Suppose you have implemented a viewing interface using a stored
model/view matrix;
in particular, you do not explicitly keep track of the camera position.
Briefly, how can you determine the camera position?
- Suppose I have implemented a flying interface as we discussed in class.
How can I determine whether my spaceship (or airplane or whatever)
is within a spherical region in the scene?
- What is the difference between a “raster image” and a “pixmap”?
- a. What are the five broad categories of primitives provided by OpenGL?
b. Which categories are available from glBegin-style primitives?
- a. What is a “bitmap”?
b. What are bitmaps used for (primarily) in OpenGL?
- Draw a diagram of the OpenGL geometry and image pipelines,
showing how they fit together.
- The OpenGL image pipeline begins and ends with the same data type.
What practical effect does this have?
Answers
- Ambient. None of the direction vectors affect the computation.
- Diffuse. The computation is affected by the surface normal and the lighting direction
(their dot product is the Lambert cosine).
- Specular. The computation is affected by all three: surface normal, viewing direction, and lighting direction.
- The specular computation.
Raising the cosine to a power is simply a trick to make the reflection of a point light source
spread out to form a semi-realistic-looking specular highlight.
The power of the cosine has no real physical meaning (as, say, the Lambert cosine does).
- A light in OpenGL is a light source.
Enabling/disabling a light affects whether light from that source enters lighting computations.
- Lighting refers to the overall computations involving light sources and materials.
If lighting is enabled, then light-source and material properties are used to compute colors.
If lighting is disabled, then OpenGL ignores all states relating to light sources and materials.
- None.
The only effect of an OpenGL light on the rendered image relates to how primitives are lit.
Nothing is drawn at the light position.
- To make the light appear as a glowing cube,
draw such a cube at location (1, 1, –1).
- In OpenGL we make lights move in the same way we make objects move:
redraw the scene with a different model/view transformation.
In the scene redrawing, we would set up the proper model/view matrix,
then, with that as the current matrix, set the light position by calling
glLightfv with GL_POSITION as its second parameter.
After this, objects illuminated by the light can be drawn.
- Enabling double-sided lighting in OpenGL makes it test whether
the front or back of a polygon is being viewed.
For the back side, the back material is used, and the normal is reversed.
For the front side, the front material is used, and the normal is left alone.
If double-sided lighting is not enabled, then the front materials and unchanged normals
are always used.
- In OpenGL double-sided lighting,
normal vectors are reversed if the back of a polygon is being viewed.
Thus, if an incorrect normal is given — one that points away from the front
side of the polygon —
then the normal will always point away from the viewer,
and there will never be any diffuse lighting on the polygon.
- Double-sided lighting uses a polygon’s front/back status.
This cannot be determined until after the projection transformation.
Thus, some lighting computations must be done after the projection transformation.
- A spotlight is a light that illuminates with greater intensity
in a given direction.
A normal light illuminates equally in all directions.
- It is generally better to use the spot exponent to specify how wide a spotlight is.
Making a sharp cutoff is a problem, since vertices inside the cutoff are illuminated
at full strength, while those outside are not illuminated.
The result is that the edge of the illuminated region appears jagged.
The spot exponent allows for the illumination strength to smoothly decrease,
which generally eliminates the jagged edge.
- Normally (local-viewer mode off), OpenGL simplifies the Phong-Model specular computation
by using (0, 0, 1) for the viewing direction,
instead of the correct vector.
When local-viewer mode is enabled, the correct viewing direction is used in the specular
computation.
- Local-viewer mode makes specular highlights move appropriately when the viewer moves.
It is thus most helpful when a moving viewer looks at a static scene.
It is generally very necessary in virtual-reality.
- OpenGL has one source of light outside of all “lights”:
the light-model ambient, which defaults to (0.2, ,0.2 0.2).
Egbert’s light is most likely coming from this.
- After model/view, the camera is at (0, 0, 0).
Thus, the camera position is the point which, when sent through the model/view transformation,
comes out as (0, 0, 0).
Thus, to find the camera position, send this point backwards through model/view.
A not-too-hard way to do this is to use gluUnProject.
This function sends a point backwards through viewport, projection,
and model/view.
So set up dummy viewport and projection transformations, and send (0, 0, 0)
back through these and the actual model/view transformation.
The result will be the camera position.
- A point is in a spherical region if its distance from the center of the sphere
is less than the radius of the sphere.
Thus, check the distance of the camera position from the center of the sphere.
If this is less than the radius, then you are inside.
Otherwise, you are not.
To determine the camera position ... see the answer to the previous problem.
- Nothing.
In this class, we use the terms raster image
and pixmap interchangeably.
For historical reasons, however, we may tend to favor one term over the other in certain contexts.
- The types of primitives OpenGL provides are:
- Points.
- Polylines.
- Filled polygons.
- Raster images.
- Bitmaps.
- The glBegin-style primitives include only those from the first three categories, above.
- A bitmap is a raster image in which each pixel is represented by
a single bit (on/off).
- In OpenGL, we use bitmaps primarily for drawing bitmap text.
- See the slides from 11/21/2003, slide number 12.
- The fact that the OpenGL image pipeline begins and ends with the same data type
(pixmap) means that it can run backwards.
This is why we have glReadPixels.
There is no corresponding command for the geometry pipeline.
CS 381, Fall 2003: Week 11 Review Problems /
Last update: 16 Dec 2002 /
Glenn G. Chappell /
ffggc@uaf.edu