This lab focuses on creating an illumination and shading model. We chose to build our shading model directly into our modeling system from the inception. To start with, we created functions that calculated Phong specularity and diffusion given the appropriate Light, Normal, and View-direction vectors. This was straightfoward. In order to do Phong shading, the surface must have a normal vector associated with it at every point. To even permit this to occur, points had to contian information about their normal vector. Furthermore, we decided that since we would already be interpolating the normal vectors, we should interpolate colors and alpha values as well. To facilitate all of this, we created a new class: the uberpoint.
An uberpoint contains a point, the normal vector at that point (an instance of our point class, with homogenous coordinate 0), a color and an alpha value. Any transforms applied to it affect both the normal and the point coordinates (except a translate, which does not affect the normal), and when it is transformed into picture coordinates, it keeps a copy of the point in world coordinates, to allow lighting calcuations and other fun. Since we mainained the heirachical modeling system from the start, there is not a seperate lab 9 page.
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
We found that the a higher specularity coefficient
causes smaller more concentrated specular spots as can be seen when
comparing images 1-3 to image 4 below. The diffuse coefficient cause
more general lighting of areas that are not specular, when it is high
(compare image 1 to the others). The phong shading coefficient makes
things shinier, as you can see in by image 3 matted nature.
In all of these images, there is a white light source from the top and
a faint blue one from below.
| Phong Shading: 3.0 Specular: 0.8 Difuse: 0.4 |
Phong Shading: 3.0 Specular: 0.8 Difuse: 0.6 |
| Phong Shading: 1.0 Specular: 0.8 Difuse: 0.4 |
Phong Shading: 3.0 Specular: 0.4 Difuse: 0.4 |
If you integrated the light sources with your modeling system, how did you do it?
We integated light sources and normal
interpolation, by creating the aforementioned uberpoints. These
monsterous things, pass around way too much data all the time, which
allows us to do whatever calculations we want at whatever stage we need
it. These points carry copies of the point before and after perspective
transform as well as the normal vectors, and extra copies of the point
and normal to interpolate correctly.
If you implemented any other extensions, explain what you did and how you did it.
We added a few primitive graphic objects to our
program. One can now create cubes, spheres, and cylinders that are
completely transformable. A sphere is generated by inscribing an
octahedron into the unit sphere, and then subdividing each face into
four faces, that are closer to the unit sphere iteratively. The user
passes the number of iterations to the sphere as the constructor. The
sphere automatically maintains normals and polygons. Since the number
of polygons grows exponentially, spheres take a long time to process
and a number in the range of 3-5 will create more than enough polygons
for good continuity.
Light Source Api
To account for the nely available light sources
the API had to be extended. The extension is fairly simple to interact
with. One can create any number of LightStructures and add them to a
GraphicsObject as below. Also, each envirnoment can have an ambient
light value associated with it.
While LightStruct.upoint is an
uberpoint, only uberpoint.pt and uberpoint.color have any effect. The
normal vector could be used for implementation of spotlights or other
directional lights, but currently it is ignored. Color blue(0, 0, 255);
Color red(255, 0, 0);
Color white(255, 255, 255);
Color green(30, 255, 30);
point3D zNorm(0, 0, 1);
LightStruct light;
light.upoint = uberpoint(point3D( 0,5, 0), zNorm, white);
light.intensity = 1;
GraphicsObject scene;
scene.addIdent();
scene.addLight(light);
KlingonWarship grknak(blue);
scene.addGraphicsObject(&grknak);
ViewStruct3D view;
view.vrp = point3D(0, 10, 30);
view.vpn = point3D(0, -.5, -1);
view.vup = point3D(0, 1, 0);
view.cop = point3D(0, 0, -5);
view.umin = -1;
view.umax = 1;
view.vmin = -1;
view.vmax = 1;
view.F = .5;
view.B = 50;
ShadingEnv env(view, 300, 300, 3.0, .8, .4);
env.setAmbient(Color(30,30,30));
Draw3D(&scene, &env);
env.WriteToFile("klingon");
Modelling Extension
Rather than write a seperate lab page for the things we did toward lab 10, we have decided to put them here.We added cylinder and sphere primitives, which are fully transformable, as you can see in the above images. They can be instanstiated as follows:
Cylinder cyl(40, red);
Sphere sphere(4, green);
The first argument to the cylinder's constructor is the number of polygons to wrap around the cylinder. The sphere's first argument is the number of times to subdivide each face into four new faces. It should be mentioned that anything over 5 takes a very long time, as the number of polygons grow exponentially.
Since both of these transform the primitives into polygon meshes, these things are fully transformable. Thus you can squish the sphere to get an ellipsoid, or do whatever other evil transformations you have in mind.
We also created a new type of Graphics Environment that attempts to corrode all of the polygons in it by randomly perturbing normals. The magnitude of the pertubation is relative to the perimiter of the polygon, so that large ones are more roughed than smaller ones.
As you can see the effects are not exactly what we had hoped for, but they are interesting. Also worth note is that the plane in the background is a single polygon.

Last modified 2003-10-07 22:15 EST