This assignment serves as an introduction to the OpenGL graphics library. You will be required to generate a room scene which can be navigated in a walk-through fashion. You will begin the project by implementing the OpenGL analogs of many of the methods that you have implemented for the last ray-tracer assignment. Emphasis is placed both upon the implemention of OpenGL's basic capabilities (e.g. shading. lighting, transparency, materials properties, etc.) and their use in generating more involved effects (e.g. shadows, reflections.)
For this assignment you will continue with the code base from the previous assignment, implementing the OpenGL related methods. There are some small modifications that you will need to make to your code described in the Code Modifications section below. It is highly recommended that you make a copy of your old code before you start working on the new methods.
An overview of the code you will be using can be found here.
An overview of the
.rayfile syntax can be found here.
A (Win32) compiled version of the renderer implementing some of the basic features can be found here. (If that does not work, try this one.)
The OpenGL programming Guide is an invaluable resource in assisting with OpenGL implementation. You can find a link to the guide here or here.
The program takes in as a mandatory arguments the input (
.ray) .ray file name. Additionally, you can also pass in the dimensions of the viewing window and the complexity of the tesselation for objects like the sphere, the cylinder, and the cone. It is invoked from the command line with:Feel free to add new arguments to deal with the new functionalities you are implementing. Just make sure they are documented.
% Assignment3 --in in.ray --width w --height h --cplx c
The assignment is worth 30 points. The following is a list of features that you may implement. The number in parentheses corresponds to how many points it is worth.
The assignment will be graded out of 30 points. In addition to implementing these features, there are several other ways to get more points:
- (1) Implement the RayCamera::drawOpenGL (in
Ray/rayCamera.todo.cpp) to draw the camera.
- (1) Implement the RayGroup::drawOpenGL (in
Ray/rayGroup.todo.cpp) to draw the scene-graph nodes. For now ignore the local transformation information and simply draw all the RayShapes associated to the RayGroup.
- (1) Implement the RaySphere::drawOpenGL (in
Ray/raySphere.todo.cpp) method to draw a sphere at the appropriate tesselation. For now, you can ignore the input
materialIndexparameter and have the method return -1. (You may want to consider using the
gluSpherefunction from the GLU library to assist you with this.)
- (2) Implement the RayTriangle::drawOpenGL (in
Ray/rayTriangle.todo.cpp) method to draw a triangle with per-vertex normals. For now, ignore the texture coordinates and the input
materialIndexparameter, and have the method return -1.
- (2) Impelement the RayMaterial::drawOpenGL (in
Ray/rayScene.todo.cpp) method to draw the material properties.
- (3) To draw the light sources, implement:
- RayDirectionalLight::drawOpenGL (in
- RayPointLight::drawOpenGL (in
- RaySpotLight::drawOpenGL (in
indexparameter specifies which of the OpenGL lights you are using and should be used for specifying the light parameters in the
- (2) Modify the implementation of RayGroup::drawOpenGL (in
Ray/rayGroup.todo.cpp) to take into account the local transformation returned by the call: RayGroup::getMatrix. You can do this by pushing the appropriate matrix onto the stack prior to rendering and then popping it off after you are done.
- (3) Implement triangle texture mapping. To do this you will have to:
- Modify the implementation of RayTriangle::drawOpenGL (in
Ray/rayTriangle.todo.cpp) to specify the texture coordinates prior to specifying the vertex positions.
- Modify the implementation of RayMaterial::drawOpenGL (in
Ray/RayScene.todo.cpp) method to enable and bind the texture if it is present.
- Modify the implementation of RayTexture::setUpOpenGL (in
Ray/RayScene.todo.cpp) method to generate the texture handle.
- (1) Implement the RayBox::drawOpenGL (in
Ray/rayBox.todo.cpp) method to draw a box.
- (1) Implement the RayCylinder::drawOpenGL (in
Ray/rayCylinder.todo.cpp) method to draw a cylinder with bottom and top caps at the appropriate tesselation. (You may want to consider using the
gluDiskfunctions from the GLU library to assist you with this.)
- (1) Implement the RayCone::drawOpenGL (in
Ray/rayCone.todo.cpp) method to draw a cone capped off at the bottom at the appropriate tesselation. (You may want to consider using the
gluDiskfunctions from the GLU library to assist you with this.)
- (2) Implement mouse control to facilitate moving about the interior of the scene. As a minimum, you should implement a crystal-ball system in which dragging the left mouse button rotates the viewer around the model, rotating either about the up-direction or the right-direction. To do this you will have to modify:
- (2) Implement full scene anti-aliasing using the accumulation buffer. Hint: See the OpenGL Programming Guide for information about jittering.
- Generate a
.rayfile describing a room scene with:
- (1) Four walls, a floor and ceiling.
- (3) A table, several chairs, etc. You may choose more interesting furnishings.
- (1) At least one transparent surface, perhaps the table top.
- (1) At least three texture mapped surfaces, each with a different texture.
- (1) At least three point or spot light sources.
- (2) A Luxo Jr. style lamp with keyboard and/or mouse controls for manipulating the joints of the lamp interactively while the spot light representing the bulb moves accordingly. Hint: see the robotic arm example in the OpenGL Programming Guide.
- (2) A mirror. Hint: Reflect the world about the mirror and render it again through a stencil buffer.
- (2) Shadows on at least one surface (such as the floor or table). Hint: See the OpenGL Programming Guide for the transformation which renders objects onto a plane.
- (2) An object that responds to user mouse clicks (such as a light switch which turns on/off a light when clicked on by the user).
- (1) In general, making a call to OpenGL's
glMaterial*commands can be somewhat expensive. Rather than calling these functions before you draw every
RayShape, modify the RayShape::drawOpenGL of the different subclasses so that:
- You first test if the if the index of the material associated to the primitive is the same as the input
materialIndexparameter and only call the
RayMaterial::drawOpenGLmethod if they differ.
- Return the index of the last material used.
- OpenGL Shading Language (See the specification for more details.)
- (2) Write vertex and fragment shaders that implement the traditional fixed pipeline with Gouraud Shading.
- (2) Write vertex and fragment shaders that implement the traditional fixed pipeline with Phong Shading.
- (2) Adapt your Phong shader to support bump mapping.
- (2) Modify the OpenGL renderer to allow the user to ray-trace the scene from the same perspective as the
- (?) Impress us with something we hadn't considered...
- (1) Submitting one or more images for the art contest.
- (1) Submitting one or more .ray files for the art contest.
- (1) Submitting one or more shader files for the art contest. You may consult online resources (make sure to do reference) but the shaders must be your own creation.
- (2) Winning the regular art contest,
- (2) Winning the .ray file art contest,
- (2) Winning the shider file art contest.
It is possible to get more than 30 points. However, after 30 points, each point is divided by 2, and after 32 points, each point is divided by 4. If your raw score is 29, your final score will be 29. If the raw score is 33, you'll get 31.25. For a raw score of 36, you'll get 32.