Printable Version

Graphics Assignments


Computer graphics assignments at Monash University were always fun, even though the time to complete them was very limited. The assignments in question were quite simple and don't stand up to today's benchmark of computer graphics. That said, such projects can be educational for those who are interested, hence I decided to release the source code under the GNU General Public License.

1 Introduction

Advanced Topics in Graphics (Monash University, 2001) was one of the subjects I found very interesting. Any aspiring game developer or graphics enthusiast would want to enrol in this subject and take a crash course in the world of computer graphics. Part of this subject's assessment criteria consisted of three assignments, which are summarised below.

2 Advanced Topics in Graphics (CSC415): Assignment A

In this particular assignment, students were required to code a fractal mountain generator, an ocean wave animator and a simple particle system. To address these requirements, a program was implemented that parsed a set of input parameters from a custom script file. These parameters were required to define the 3D scene, which also influenced the geometry of the fractal mountain, the ocean waves and the particle system.

A simple procedural texture technique was used to generate turbulence for the ocean waves. The program computed the animation for the ocean and the particle system. The results were saved in a series of POV scene files, which were passed on to the POVRAY ray-tracing software. The sequence of raw images produced by POVRAY were imported into an AVI file for visualising the animation.

Figure 1 Figure 2 Figure 3
Figure 1: Volcano island with water. Figure 2: Eruption, showing the lava. Figure 3: Animated GIF video (2.9MB).

3 Advanced Topics in Graphics (CSC415): Assignment B

Assignment B focused on real-time animation. In this case, a program was written to animate a school of fish flocking in zero gravity. The flocking mechanism was based on the Boid system. Each fish was represented with a blue cube-like body. The direction each fish travelled was indicated by a small direction vector in white. The school contained predators as well.

The initial idea was to model a stonefish as the predator, because it uses stealth to catch the prey. Unfortunately due to lack of time a simpler predator model had to be used. The concept of trickery used by animals in nature was still an attractive idea. Hence a new predator was implemented that disguised itself as the prey, which became purplish-blue colour. This allowed the predator to come close the unsuspecting flock, and after some time it turned into an attack mode (red colour) and tried to chase the nearest prey. Sometimes it managed to single out a prey and separated the prey from the flock. The program also contained a fully working L-System algorithm for modelling simple plants.

The whole implementation worked surprisingly well. The animation was quite fast, even though the code was not optimised for performance. That said, the Boid algorithm had a few problems; for example, a "flash explosion" in the flock would cause the fish to jitter. Sometimes the flock would also escape from the enclosed environment. There was an obvious problem with the collision detection algorithm.

Update 11/10/2009: Video sequences of the boid system in action is now available on line. For details, see the Appendix section of this page.

Figure 4 Figure 5 Figure 6
Figure 4: The flock (blue) and the predators (red). Figure 5: Predators are in stealth mode, the flock stays together. Figure 6: "Flash explosion" of the flock as the predators suddenly attack.
Figure 7 Figure 8 Figure 9
Figure 7: A single predator isolating a prey. Figure 8: The flock in a free-range environment. Figure 9: More frenzied flock activity.

4 Advanced Topics in Graphics (CSC415): Ray Tracer Assignment

The third assignment required students to explore ray tracing algorithms. One of the criteria for this project was to implement a ray tracer capable of rendering at least two types of primitives: spheres and planes. The shading algorithm was based on the standard Phong model, complete with reflection. The assignment also had an enhancement criteria, which required students to add features that visually improved the ray tracer. For this criteria, a shadow and a refraction algorithm was implemented.

Figures 10 to 15 demonstrate some of the features implemented in the ray tracer. Each pair of images show the scene rendered using the standard Phong shading model with reflection (left), and with shadows and/or refractions enabled (right). Figure 14 illustrates how a basic geometric model can be built using spheres.

This ray-tracer became the framework for the panoramic rendering project later on.

Figure 10a Figure 10b Figure 11a Figure 11b
(a) (b) (a) (b)
Figure 10: Room with spheres. Figure 11: Marbles on an infinite plane.
Figure 12a Figure 12b Figure 13a Figure 13b
(a) (b) (a) (b)
Figure 12: Refraction demo. Figure 13: Pair of infinite planes with recursive reflection.
Figure 14a Figure 14b Figure 15a Figure 15b
(a) (b) (a) (b)
Figure 14: Bear, highlighting the Phong shading model. Figure 15: More detailed refraction demo.


Video Clips

Source Code

The source code and sample programs used in these assignments are available to download under the GNU General Public License. Be warned, the code is not exactly a shining example of good C++ programming practices; they contain a lot of cheap and inefficient hacks. Furthermore, the projects were compiled under Visual C++ 6.0 and gcc. Do not expect the source to build with the latest generation compilers without modification.

Copyright 2003, Dominik Deák

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (gpl-2.0.txt) for more details.