Quiz 14: Grazing Cow

In class we discussed the "N dot L" local shading model, which is perhaps the simplest way to give a surface some sense of depth. We can add a little bit more visual sophistication by adding a fresnel term, where rays of light hitting the surface at grazing angles (i.e., directions almost orthogonal to the normal) experience a strong specular reflection.

Your task is to write any (hopefully short!) piece of code that computes an N-dot-L term plus a fresnel-like term. This code assumes a "grayscale" color model, i.e., just a single value giving the intensity of the result; you do not have to worry about color. Your code does not have to be physically or radiometrically accurate! However, it does have to produce the desired effect: rays at grazing angles yield brighter values. You may assume that any ray that reflects off the surface immediately hits a "pure white sky" with a brightness value of 1; you do not have to consider occlusion (i.e., shadows) or indirect lighting (i.e., bounces off other surfaces). The main things we want you to think about are:

  • Concretely, how do I compute the light (L), eye (E), normal (N), and reflected (R) vectors from the given data? Here you should give concrete expressions, not rough intuition. [Hint: these can be found in the slides!]

  • Given this data (L, E, N, R), how do I cook up some shading function that captures the very basic behavior of Lambert's cosine law and fresnel reflection. [Hint: you should not have to think deeply about things like BRDFs and radiometric quantities; just some very simple vector geometry.]

double shadeCow( Vec3 hitPosition,   // position in space where the ray hits the surface
                 Vec3 hitNormal,     // unit surface normal at hit location
                 Vec3 lightPosition, // location of point light
                 Vec3 eyePosition )  // location of observer
{
   // TODO: compute N, L, E, R

   // TODO: add the N-dot-L term (hint: see lecture on radiometry)

   // TODO: add the fresnel term (hint: see lecture on the rendering equation,
   //       and think about *any* function at all that might produce a
   //       fresnel-type effect; it doesn not have to be physically accurate)

   // TODO: make sure to return the final value!
}

To hand in, print out your code (or write it by hand if you like...). Make sure to include your AndrewID.

You should also write a brief explanation for WHY your fresnel term produces the right kind of behavior.