CMPS 160 Introduction to Computer Graphics
Lab 4: Shaders and RTI Rendering

Fall 2010

In this lab you will create a viewer that loads and renders RTI images using fragment shaders. You will have to use OpenGL ES2 syntax to make sure your code runs on both the desktop and the N900s.
The user should be able to load a RTI file and change the light position in real-time to see the rendered result. The goal is to make an intuitive and user-friendly RTI viewer that other people will want to use too!

Due : 11/8 and 11/11 (depending on whether you signed up for the Tuesday or Thursday lab)

We will not have the lab section on next Thursday. However definitely submit the code by the due date. I will be testing it on 10/18.


  • Lab 4 Notes - Use this together with the examples to get a jump start.
  • - Simple GLSL Multitexturing Example.
  • This code draws a polygon to fill the entire screen, and uses a two small (3x4) textures to render on to it using the fragment shader. For good measure it also includes the rtiutil.h file so you can use this as the starting point for your project if you have difficulty combining the other two programs.


  • - Shader example in Qt (Rotating textured cube)
  • This code will give you the building blocks needed to load and use a custom shader.

  • - Same rotating textured cube example, but this time I've included the GLee libraries to help with any OpenGL version support issues. Try this if you have problems running the previous example. For more information about GLee check out
    • Note : I've included the GLee files in the 'GLee' subfolder in the zip file. If you happened to change the location of the default build directory in your project settings, also update the relative path to the Glee.lib in file.

  • - A very simple RTI loader in Qt
  • A quick and dirty RTI loader in Qt. Click on the window to light the image. The mouse position determines the lighting direction. Make sure to either change the working directory to the same folder as the RTI file or copy the RTI file to the working folder before running the code.

  • - Visual Studio based C++ code for working with RTIs
  • I do not expect you to actually build and run this code,it's research code from a OpenCV+GL based Multiviewpoint + RTI viewer. This project contained the utility functions that were copied to the QtRti example. If you want to compile the code, download and install OpenCV on your machine first.

  • universal_rti_format_draft.doc - RTI format specification draft
  • A bit long, read if you are interested in understanding about the format.


  • Functionality (100 points possible)
  • Load and display the RTI file in an OpenGL window (40)
  • If you don't implement the lighting calculation on the GPU, but manage to do all the calculations on the CPU and render the output to an OpenGL window, you will still get these 40 points. For the rest of the 60 points though you need fragment shader based relighting.
  • The fragment shader based relighting calculation. (40)
  • Allow user to change the lighting direction (interactively using the mouse), and recalculate the resultant image using the fragment shader.
  • Allow the user to load a different RTI file through either the command line or the 'File Open' dialog (10)
  • User interface / error handling (10)
    • Making sure that the lighting direction stays in the upper hemisphere.
    • Proper orientation of the RTI (account for OpenGL y-axis texture flipping).
    • The application does not crash if the user goes out of bounds (and robustness in general).

Extra Credit

  • Add support for different number of RTI terms (10) [By default you only need to support the 3rd order (9 term) RTIs]