This lab is designed to show you how shaders enable you to "experience life beyond Phong". Its goals are:
Provide practice with implementing illumination models using shaders
Provide practice in coding a shader from a written specification.
In this lab, you will be implementing a number of standard (and non-standard) illumination models using shaders. All of these shaders were described in Monday's lecture on BRDFs. The shaders that you will write are:
BASIC: Phong illumination model (as a vertex shader in GLSL)
INTERMEDIATE: Phong illumination model (as a fragment shader in GLSL)
ADVANCED: The Strauss "quasi-physically-based" model
As with the previous assignment, two ZIP archives have been provided for you:
lab2files.zip
expands into a folder named lab2 which contains "starter"
code for your GLSL and RenderMan®
implementations
lab2results.zip
expands into a folder named lab2results which is a framework
into which you should place your solutions and resulting images.
As with the previous assignment, please place your solutions in the
lab2results folder, as follows:
Place your source code (not object files or binaries) in the appropriate
subfolder (e.g., your GLSL basic source files in the
GLSL/Basic folder, your RenderMan intermediate source
files in the RenderMan/Intermediate folder, etc.).
Place your result images in the Results subfolder, with
names of the form
lang-task.suffix.
For lang, use glsl or rman,
as appropriate; for task, use basic,
intermediate. or advanced;
suffix should match the type of the image file
you created (typically, tiff, png, gif,
etc.
For example, the result image for the Basic RenderMan task might
be named rman-basic.tiff, and the Advanced GLSL task result
image might be named glsl-advanced.png.
Create a ZIP archive of your results folder by using the "Compress" entry of the right-click menu for the folder; to submit it, run the command
try wrc-grd shading-2 lab2results.zip
on a CS system that supports 'try' (e.g., one of the compute servers, or one of the machines in ICLs 1-4).
Both shading systems that we have looked at prefer the Phong-Blinn model (which makes use of the halfway vector) for basic illumination. In this part of the lab, you will be implementing the Phong model proper (i.e., using the R dot V definition) for specular reflection.
To make things more interesting, you must implement the RenderMan version
of this part without using the built-in diffuse and
specular functions.
You are free to use ambient if you wish.
You can either use the illuminance construct directly, or
write your own diffuse and specular functions (being sure to use
different names for them, like myDiffuse and
mySpecular).
(The advantage of the latter approach is that you can reuse these
function definitions in later parts of this lab by changing the function
definitions.)
You should apply the shader to the scene found in rit.rib
in the RenderMan folder of the ZIP linked above.
Name the shader realPhong.
On examining the RIB file, you will see the sphere making use of
this shader.
Feel free to provide different values to
the shader parameters to see the effect on the rendered image.
By default, point light sources in RenderMan will attenuate
based on distance.
Although this will be useful to us when we get to the
lighting lab, for now, if would be better if this was not the case.
Thus, included in the RenderMan folder is a light source shader
plainPointLight (found in the file
plainPointLight.sl) which is referred to in the RIB file.
Be sure to compile this file before attempting a render.
For the GLSL part of the BASIC shader, you will implement Phong (proper) as a vertex shader. Use the code in the GLSL folder to start. Note that material properties and lights have been set up in this file. Your shader should be able to access this OpenGL state directly. Feel free to refer to this Lighthouse3D tutorial.
The INTERMEDIATE shader will also focus on the Phong model.
Test out the illuminance construct in the shader that you
created above by adding additional light sources.
Note that this will require modification of the RIB file and not the
shader code (assuming your shader is correct).
Also, feel free to move the light source to assure
that the specular highlight moves with it.
For this part, implement the Phong (proper) model as a fragment shader. Recall that if you use a fragment shader, you'll need to write a vertex shader to pass thru the values that need to be interpolated. As with the RenderMan shader, try moving the light positions (from within OpenGL) and assure that the specular highlight moves accordingly.
For part 3, you are to implement the Strauss model. This model is described in this paper and in the slides for the BRDF lecture. Don't let all the equations frighten you; they are just equations, and between the parameters to the shader and the constants defined in the paper you should find all the values needed for the variables in the equations. For GLSL, you are free to implement the shader as either a vertex shader or a fragment shader.