Home
                                                                            

Computer Graphics

by Cheng-Cheng Ku

All assignments are implemented in C++ with OpenGL Utility Toolkit ( GLUT ), which is a window system independent toolkit for writing OpenGL programs.

Assignment 1 - Image Processing

Implement several image processing operations: magnification, minification, convolution and edge detection in an interactive application.

Application loads an image file, display it using OpenGL, allow the user to choose which operation to perform using a pop-up menu (additional numerical arguments can be read from standard input), display the result of the operation; the menu should also have an option to save the result. The following operations are in the menu:

  • Scale Prompt for the user to type in two real scale factors for x and y directions, and the filter type: B for "box", H for "hat", L for Lanczos, M for Mitchell.
  • Smooth Perform a smoothing operation.
  • Sharpen Perform a sharpening operation.
  • Detect edges Prompt for the user to type in a threshold value for edge detection.
  • Mode No operation is performed; determines whether each subsequent operation is applied to the result of the previous operation, or to the original image.
  • Load Prompt the user for the file to load.
  • Save Prompt the user for the file name to save to.


Executable with image file and glut32.dll
Instruction:
  • Unzip the file and execute the executable.
  • Click mouse right button to pop-up menu for operations.
  • Type in standard input for numerical scale factors or file name.
Source code


Assignment 2 - Lighting and Textures

There are three distinct parts in this assignment:

Texture: Setting up an environment with textured objects and a simple camera manipulation interface.

  • A texture-mapped sphere, with the whole surface covered by the texture.
  • A texture-mapped closed cylinder, with texture applied to the whole surface, including caps.
  • An object of complex shape, with a texture mapped to it using projective mapping. The texture used for this object has an alpha channel.
  • A texture-mapped ground plane.
  • A cube surrounding the scene with texture map applied on 5 sides.
Lighting: A user interface for positioning lights in this environment.
  • Place 4 point light sources in the scene.
  • Pressing a digit from 1 to 4 enables manipulation of a light.
  • A small sphere is displayed at the light source position for enabled lights.
Material: An interface for choosing material colors for objects.
  • In the lower left corner of your image, display four horizontal bars, three with the gradient of a primary color (red, green or blue) from 255 to 0, and one to set shininess for specular reflection.
  • Clicking on a point inside one of the bars affects the corresponding parameter of the material property of the current object.


Executable with texture image files and glut32.dll
Instruction:
  • Unzip the file and execute the executable.
  • Click mouse right button to pop-up menu for operations.
  • Texture Mode:
    Press M - toggles mipmaps for all textures
    Press F - toggles the filters between linear and nearest neightbor
    Click on a point in the scene - moves it to the center of the image
    UP and DOWN arrows - move the camera closer and further away
  • Lighting Mode:
    Press 1 ~ 4 - enable manipulation of a light
    Space bar - turn the current light on and off
    Click close to the light with the mouse and drag - move the light parallel to the screen plane
    Press shift and move the mouse up and down - move the light along a line perpendicular to the screen
    Press UP and DOWN arrows - change the light intensity
    Press S - toggle all lights on and off
  • Material Mode:
    Click on a point inside one of the color bars - affects the corresponding parameter of the material property of the current object
    Space Bar - switches between objects
Source code


Assignment 3 - Meshes

This assignment implements a simple system for mesh modification. The program loads a mesh from an OBJ file. Construct the half-edge mesh data structure for arbitrary polygonal meshes. The mesh is displayed with lighting enabled. The user is able to rotate the mesh using the trackball interface provided by Prof. Denis Zorin.


Executable with OBJ file and glut32.dll
Instruction:
  • Unzip the file and execute the executable.
  • Click mouse left button - select a mesh polygon (the selected polygon is highlighted)
  • Press mouse left button and drag on the trackball - rotate the object
  • Press D - remove the polygon being selected
  • Press T - convert all polygons to triangles
Source code


Assignment 4 - Ray Tracer : Ray Casting

This assignment implements the camera and several primitive objects (box, sphere, cone, cylinder, quadric) for a ray tracer. The input language of the ray tracer will be a subset of the geometry file format of POV-Ray raytracer. The program reads a file specified on the command line and create an image of the scene described in the file using ray casting. In addition to the name of the file, on the command line user is able to specify the size of the output image.
Rendered result of the file sample.pov

Executable with POV format file sample.pov and glut32.dll
Instruction:
  • Unzip the file and execute the executable.
  • Type in the name of the file in standard input.
  • Type in the size of the output image.
  • After rendering, type in a file name to save the image (.tga format is supported)
Source code


Assignment 5 - Ray Tracer : Shading and Recursive Ray Tracing

This assignment is built on previous one with lights, material properties and recursive ray tracing features. In addition to the name of the file and the size of the output image, on the command line user is able to specify the maximal depth of recursion and the ray weight threshold.

The program implements the basic ray tracing algorithm: for each point, shoot rays to all light sources, the reflected ray and the refracted ray. Also, it implements the coordinate-aligned bounding box acceleration, that is, for each finite object (any object excluding quadrics), compute a bounding box; before intersecting a ray with the object, intersect it with the bounding box.

The recursive spawning of rays is terminated when the maximal depth specified on the command line is reached, or when the ray weight is below a threshold. The weight is computed as follows: for pixel rays (the rays starting at the camera) it is set to 1. Each reflected or refracted ray is assigned a weight equal to the product of its current weight with the coefficient with which its contribution enters the summation in the lighting equation.

Rendered result of the files, sample.pov and cluster.pov

Executable with sample.pov, cluster.pov and glut32.dll
Instruction:
  • Unzip the file and execute the executable.
  • Type in the name of the file in standard input.
  • Type in the size of the output image.
  • Type in the maximal depth of recursion.
  • Type in the ray weight threshold.
  • After rendering, type in a file name to save the image (.tga format is supported)
Source code