Lab 8: Illumination and Shading
Andrew Cantino & Will Moss

This is lab 8 of Computer Graphics.

Sections:

The New Light API

In this lab we have added illumination and shading to our modeling system. Like all the rest of our models in our modeling system, lights know how to render themselves, returning themselves as part of a list of light sources. Here is an extension to our API:

class modelLight

  class pointLight
    >A point light source that projects in all directions
      pointLight()
        >Primative constructor
      pointLight(colorVector l)
        >Takes a colorVector, which is a tuple in the range [0 1], specifying the color of the light

  class spotLight
    >A point light source that projects in a specific direction
      spotLight()
        >Primative constructor
      spotLight(colorVector l, vector3D d, double a)
        >Takes a colorVector, as well as a direction and angle, specifying the radius of the beam

Images


The Required Image
A white light illuminating a green cylinder from (-5, 0, 0).

A white cylinder, illuminated by blue and green lights.
The blue light is at (10, 0, 3) and the green light is at (-10, 0, -3).

Questions and Answers
  1. If you use different specular coefficients for the Phong specularity model, what is the apparent effect of increasing or decreasing the coefficient? Test this out, don't just make up an answer. Show the pictures on your lab report so you can visually answer this question.
    By increasing the value of kS, we accomplish two things. First, we make the light the is reflecting off the surface due to specular reflection (i.e. the direct reflection of the light source off of the surface) brighter (and in the case of the white light for our images, whiter). Second, the fact that the light reflecting off the surface if getting brighter means that the region that has a noticable amount of specular reflection increases.
    By increasing the value of nS, we decrease the "radius" that the light reflects off (i.e. the angle between R and v must be smaller). Here are some sample images, with the value for kS across the top and nS on the side:

       
    kS
       
    (0, 0, 0)
    (.2, .2, .2)
    (.4, .4, .4)
    (.6, .6, .6)
    (.8, .8, .8)
    (1, 1, 1)
    nS 2






    4






    8






    16






    32






    64






  2. If you integrated the light sources with your modeling system, how did you do it?
    We added a new modelLight object to our modeling system. modelLights can be added to a scene like any other model object. Then when the scene is rendered, a list of the lights is returned (along with the previously returned list of polygons and points). These lights are then transformed by the VTM to get them into CVV space. Once in CVV space, we can use them when we are rendering the rest of the scene. Since we are interpolating our CVV coordinates as well as our normal values as we scan across a polygon, we can just use our lighting model in CVV space to calculate the color of each pixel.

Extensions

Starting Shadow Rays
In order to let objects in our 3D scenes cast shadows, we have started to implement shadow rays, in which we shoot a ray from every rendered pixel to each light source. If the ray intersects any polygons in the world, then the pixel is in shadow from that light source, and so should not be illuminated. We have the implementation mostly working, but have not eliminated all of the bugs. It will be completed in the next lab. Here is an image looking straight down on a pyramid, illuminated with a blue light on the right and a yellow light on the left. There is some glitching that we plan to iron out by the next lab.

Integration with Hierarchical Modeling System
As mentioned above, we integrated our new lighting model with our hierarchical modeling system. Here is an example image with a light orbiting a pyramid:


Click for full resolution version.

[Back to Lab Index]