Sections:
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
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). |
|
|
|||||||
| nS | 2 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 4 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| 8 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| 16 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| 32 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| 64 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
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. |