-pthread argument to LFLAGS definition in Makefile3.
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 or downloaded here.
An overview of the
.rayfile syntax can be found here.A (Windows x64) compiled version of the renderer implementing some of the basic features can be found here. (You will need to have the glut dll installed as well. In case you do not, you can grab the file from here and place it in the same directory as the executable.)
A (Linux) compiled version of the renderer implementing some of the basic features can be found here.
The OpenGL programming Guide is an invaluable resource in assisting with OpenGL implementation. You can find a link to the guide here.
Slides describing the use of OpenGL can be found here.
A tutorial on using OpenGL can be found here.
You should use the same code-base as in previous assignments (Assignments.zip), as a starting point. As in the previous assignments, code modification should be relegated to the*.todo.cppfiles.After you copy the provided files to your directory, the first thing to do is compile the program. To do this, you will first have to compile the
JPEGlibrary and then compile theassignment3executable.On a Windows Machine
Begin by double-clicking onAssignments.slnto open the workspace in Microsoft Visual Studios.
- Compile the
Assignment3executable by right-clicking on "Assignment3" and selecting "Build". (If theJPEG.lib,Image.lib,Ray.lib, andUtil.liblibraries have not already been compiled, they will be compiled first.)- The executable
Assignment3.exeis compiled in Release mode for the 64-bit architecture and will be placed in the root directory.On a Linux Machine
- Type
make -f Makefile3to compile theAssignment3executable. (If thelibImage.a,libRay.a, andlibUtil.alibraries have not already been compiled, they will be compiled first.) This assumes that JPEG libraries have already been installed on your machine. (If it hasn't been installed yet, you can install it by typingsudo apt-get install libjpeg-dev.)- The executable
Assignment3is compiled in Release mode and will be placed in the root directory.- If you are having trouble linking either to the
gllibraries or theglulibraries, you should install the associated packages:For subsequent assignments, you should also install thesudo apt-get install libgl1-mesa-dev libglu1-mesa-devglutpackage:sudo apt-get install freeglut3-dev
Ray/box.todo.cpp
Ray/cone.todo.cpp
Ray/cylinder.todo.cpp
Ray/shapeList.todo.cpp
Ray/sphere.todo.cpp
Ray/torus.todo.cpp
Ray/triangle.todo.cpp
The executable 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. (Specifically, this specifies the resolution, e.g. the number of angular samples.) 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 <input ray file> --width <window width> --height <window height> --cplx <tessellation complexity>
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 Ray::Camera::drawOpenGL (in
Ray/camera.todo.cpp) to draw the camera.- (1) Implement the Ray::ShapeList::drawOpenGL (in
Ray/shapeList.todo.cpp) to draw the scene-graph nodes. For now, ignore the inputglslProgramparameter.- (2) Implement the Ray::TriangleList::drawOpenGL (in
Ray/shapeList.todo.cpp) and Ray::Triangle::drawOpenGL (inRay/triangle.todo.cpp) method to draw triangles with per-vertex normals. For now, ignore the texture coordinates and theglslProgramparameter.- (2) Implement the Ray::Sphere::drawOpenGL (in
Ray/sphere.todo.cpp) method to draw a sphere at the appropriate tesselation. For now, you can ignore the inputglslProgramparameter.
You may not use thegluSpherefunction from the GLU library to assist you with this. Instead, you will have to explicitly generate the primitive (triangles/polygons) and render them yourself. You should use the parameter Shape::OpenGLTessellationComplexity to set the tessellation complexity.- (2) Impelement the Ray::Material::drawOpenGL (in
Ray/scene.todo.cpp) method to draw the material properties. For now, you can ignore the inputglslProgramparameter.- (3) To draw the light sources, implement:
The input
- Ray::DirectionalLight::drawOpenGL (in
Ray/directionalLight.todo.cpp);- Ray::PointLight::drawOpenGL (in
Ray/pointLight.todo.cpp); and- Ray::SpotLight::drawOpenGL (in
Ray/spotLight.todo.cpp)indexparameter specifies which of the OpenGL lights you are using and should be used for specifying the light parameters in theRayLight::drawOpenGLmethod:For now, you can ignore the inputglLightfv(GL_LIGHT0+index, ...);
glEnable(GL_LIGHT0+index);glslProgramparameter.- (2) Modify the implementation of Ray::AffineShape::drawOpenGL (in
Ray/shapeList.todo.cpp) to take into account the local transformation returned by the call: Ray::AffineShape::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. For now, you can ignore the inputglslProgramparameter.- (3) Implement triangle texture mapping. To do this you will have to:
- Modify the implementation of Ray::Triangle::drawOpenGL (in
Ray/triangle.todo.cpp) to specify the texture coordinates prior to specifying the vertex positions.- Modify the implementation of Ray::Material::drawOpenGL (in
Ray/scene.todo.cpp) method to enable and bind the texture if it is present.- Modify the implementation of Ray::Texture::initOpenGL (in
Ray/scene.todo.cpp) method to generate the texture handle.- (1) Implement the Ray::Box::drawOpenGL (in
Ray/box.todo.cpp) method to draw a box. For now, you can ignore the inputglslProgramparameter.- (1) Implement the Ray::Cylinder::drawOpenGL (in
Ray/cylinder.todo.cpp) method to draw a cylinder with bottom and top caps at the appropriate tesselation. For now, you can ignore the inputglslProgramparameter.
You may not use thegluCylinderandgluDiskfunctions from the GLU library to assist you with this. Instead, you will have to explicitly generate the primitives (triangles/polygons) and render them yourself. You should use the parameter Shape::OpenGLTessellationComplexity to set the tessellation complexity.- (1) Implement the Ray::Cone::drawOpenGL (in
Ray/cone.todo.cpp) method to draw a cone capped off at the bottom at the appropriate tesselation. For now, you can ignore the inputglslProgramparameter.
You may not use thegluCylinderandgluDiskfunctions from the GLU library to assist you with this. Instead, you will have to explicitly generate the primitives (triangles/polygons) and render them yourself. You should use the parameter Shape::OpenGLTessellationComplexity to set the tessellation complexity.- (1) Implement the Ray::Torus::drawOpenGL (in
Ray/torus.todo.cpp) method to draw a torus. at the appropriate tesselation. For now, you can ignore the inputglslProgramparameter.
You may not use theglutSolidTorusfunction from the GLUT library to assist you with this. Instead, you will have to explicitly generate the primitive (triangles/polygons) and render them yourself. You should use the parameter Shape::OpenGLTessellationComplexity to set the tessellation complexity.- (1) Implement mouse control to facilitate translating the camera about the scene. To do this you will have to modify:
- Ray::Camera::moveForward (in
Ray/camera.todo.cpp) to implement a translation by a distance ofdistalong the forward direction.- Ray::Camera::moveRight (in
Ray/camera.todo.cpp) to implement a translation by a distance ofdistalong the right direction.- Ray::Camera::moveUp (in
Ray/camera.todo.cpp) to implement a translation by a distance ofdistalong the up direction.- (2) Implement mouse control to facilitate rotating around the scene scene. 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:
- Ray::Camera::rotateUp (in
Ray/camera.todo.cpp) to implement a rotation ofangledegrees, around the up-axis, about the pointcenter.- Ray::Camera::rotateRight (in
Ray/camera.todo.cpp) to implement a rotation ofangledegrees, around the right-axis, about the pointcenter.- 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).
- Support efficient rendering using vertex buffer objects. For this you will need to generate (bind, and set) the buffer objects in Ray::Shape::initOpenGL and draw the buffer objects in Ray::Shape::drawOpenGL.
- (1) Implement vertex buffer objects for Ray::TriangleList.
The implementation of Ray::TriangleList::initOpenGL has already been provided for you, with the vertex buffer object stored in Ray::TriangleList::_vertexBufferID and the element buffer object stored in Ray::TriangleList::_elementBufferID. The vertex buffer stores information about positions, normals, and texture coordinates. The number of vertices is stored in Ray::TriangleList::_vNum and the number of triangles/elements is stored in Ray::TriangleList::_tNum.- (1) Implement vertex buffer objects for Ray::Sphere.
- (1) Implement vertex buffer objects for Ray::Cylinder.
- (1) Implement vertex buffer objects for Ray::Cone.
- (1) Implement vertex buffer objects for Ray::Torus.
- OpenGL Shading Language (See the specification for more details.)
- (2) Write vertex and fragment shaders that implement the traditional fixed pipeline with Phong Shading using point and spot lights and modify the code to provide the necessary values to the shader. An implementation using directional lights has already been provided. However, the code does not provide the values to the shader.
Hint
If you want to be able to see some results using the provided shaders, at a minimum you will need to set the shaders'material_emissiveandmodelviewvariables. The former is specified as 3-vector, which you can set using theGLSLProgram::setUniform< 3 >( ... )member function, while the latter is a matrix which can be set using theGLSLProgram::setUniformMatrix< 4 >( ... )member function.
For an example of how these functions are invoked, look at the implementation ofWindow::DisplayFunction( void )function inwindow.cpp- (2) Adapt your Phong shader to support bump mapping.
- (?) 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.
Ray folder into Ray.zip. Submit the Ray.zip file without the window.cpp file. (The window.cpp file will be overwritten by the auto-grader so do not modify it.)
phong.point.vs, phong.point.fs, phong.spot.vs, and phong.spot.fs respectively.
.ray files as well as images) into artcontest.zip.
writeup.pdf
[Ray.zip]
[phong.point.vs]
[phong.point.fs]
[phong.spot.vs]
[phong.spot.fs]
[artcontest.zip]
awesomepicture.bmp
interestingartpiece.ray
...