Starting from:

$34.99

CS3241 Lab 3 Solution


LEARNING OBJECTIVES
Writing OpenGL program to simulate planar reflection using texture-mapping and a multipass rendering technique. After completing the programming assignment, you should have learned how to
• set up texture mapping in OpenGL,
• model and draw texture-mapped objects,
• set up off-center view frustum,
• read back image in framebuffer for texture mapping, and
• simulate planar reflection using a multi-pass rendering technique.
TASKS
Please download the ZIP file Lab3_todo_(*).zip from the Assignments folder in LumiNUS Files.

You are to complete an incomplete C++ application program, so that it can simulate planar reflection, using a multi-pass rendering technique and the texture-mapping capabilities provided by OpenGL. You have to complete the program according to the following requirements.

Task 1
You have to complete main.cpp to produce the planar reflection that you see in the following sample images:








Please read the instructions shown in the console/terminal window to learn how to operate the program.

The 3D scene contains a table with a flat rectangular semi-reflective table-top. The scene is also populated with other objects, at least some resting on the table-top. The table-top must reflect the scene. Here are some additional requirements:

• The reflection on the table-top is created by texture mapping a reflection image onto the tabletop rectangle. The reflection image is generated by drawing the scene seen from an imaginary viewpoint, which looks through the table-top from under the table. This rendered image is then copied from the color buffer to a texture object, to be used for texture mapping the table-top rectangle.

• The reflection on the table-top should not be 100% (it is not a perfect mirror), and the underlying diffuse color and lighting on the table-top must still be visible. (Hint: use the correct texture function/environment.)

• Mipmapping must be used for all texture mapping, including for the reflection texture mapping. For the texture object that contains the texture image copied from the color buffer, you have to set the texture object using

glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

• You are not allowed to use the stencil buffer for this assignment.

• Write your code immediately below the locations marked “WRITE YOUR CODE HERE”. There are three of such locations.

• You are allowed to modify only main.cpp. You are not required and must not change any other source files.

Task 2

You are allowed to modify only main.cpp. You should use your own new image(s) to texture-map your new object(s). As before, mipmapping must be used for all texture mapping.

Besides your completed main.cpp, you also need to submit the new texture image(s).

This task will be assessed based on the fulfillment of the basic requirements, on the technical difficulty and object’s complexity, and on the aesthetics and creativity.


DO NOT HARD-CODE VALUES. You should write your code in such a way that when the values of the named constants (defined in the beginning of the program) are changed to other valid values, your program should function accordingly. For example, if the table’s height is changed, the reflection from the table-top should still look correct.


GRADING




Good coding style. Comment your code adequately, use meaningful names for functions and variables, and indent your code properly. You must fill in your name, and NUS User ID in the header comment.
SUBMISSION
For this assignment, you need to submit only

• Your completed main.cpp that contains code for both Task 1 and Task 2;
• File(s) of your new texture image(s) for Task 2. They must be in the images subfolder. Total image files’ size must not exceed 5 MB.

You must put it/them in a ZIP file and name your ZIP file nus-user-id_lab3.zip. For example, if your NUS User ID is e0123456, you should name your file e0123456_lab3.zip.




——— End of Document ———

More products