E26/CS40 Lab 9: Illumination and Shading

Paul Azunre, David Wright

Description

This lab implements light sources and shading in our 3-D modeling system.

Light Sources

For this lab, two types of light sources were implemented, ambient and point.

Shading Methods

A Gouraud shading algorithm was implemented for this lab. It works with multiple of light sources, both ambient and point. A shaded color is calculated at polygon vertices based on the combined lighting from the light sources and the surface and body colors of the polygon. This color is then interpolaed between vertices to fill in the entire polygon.

Simple Shading Test Case
Figure 1. Testing shade fill function.


Figure 2. Required Image.

A full list of the functions added can be seen in the API section.

Starfury Animations

[Be sure to click on animations for larger versions]:

First, an animation of the starfury fliers rotating about an axis was created to observe the models in detail. This animation can be seen in Figure 3.

Figure 3. Rotating starfury fighters.

Next, rotation axes were chosen in order to make the fliers appear to be flying through space while performing crazy acrobat tricks. To give an illusion of motion, a large number of points were randomly generated and translated/rotated for each frame. The result is an illusion of space dust consistent with the motion of the fliers.

Figure 4. Starfury fighters spinning out of control in a cloud of spacedust.

Next, the animation was inserted into a cool outer space background. The result can be seen in Figure 5.

Figure 5. Spinning out of control on an outer space background.

The animation in Figure 5 takes something away from the illusion of motion. Hence, the background was taken out, and a radially filled shpere was made to pan across the scene. The resulting animation is shown in Figure 6.

Figure 6. Passing very close to a planet.

Animation to demonstrate surface reflection

Because the starfury animations did not clearly show surface reflection, an additional animation was created to make sure that it works correctly. The animation shows a sphere and a cylinder with a good amount of surface reflection. The effect is that the objects appear metallic. Click on the animation for a larger version.

Figure 7. Metallic sphere and cylinder: animation to demonstrate surface reflection

 

Simple Particle System

A simple particle system was created with the aim of decorating the starfury fighters. Due to time constraints, it could not be implemented in 3D (for the starfury fighters). As such, a simple 2D animation was created to showcase the work done. This animation is shown in Figure 8.

Figure 8. Simple particle system demonstration.

 

Finale: A christmas tree!

The following picture shows a christmas tree made out of cones and spheres models. The ability to add light sources can help create cheery pictures. Merry Christmas!!!

Figure 7. An image relevant to the current season!

Questions

1. What extensions did you do for this assignment, how did you do them, and how well did they work?

Cool animations were created as described in the section "Starfury Animations". An additional animation was created to demonstrate the "metallic" appearance of objects with high surface reflection. A simple particle system was created. Finally, a christmas tree image was created to end the course appropriately.

The API

For the most part, the API is the same as that given in the Graphics Environment Specification. Additional functions are specified below.

Particle system functions:
-----------------------------------------------------------------------------------------------------------
void PartSysDraw(PartSys *sys, Image *src);
- Draw particle system sys into the image src.

Particle *PartInit(int Tlim, int Mlife, Color Clim, int Vlim);
- Initialize a particle with a temperature limit Tlim, life limit (in ticks) Mlife, highest temperature color Clim and velocity limit Vlim.