Spherical Harmonic Shading

[This page is in the process of being cloned from http://ucspace.canberra.edu.au/display/SHLIGHT/ That other page remains the master page for the SHLight program.]

Main Screenshot

About this Space

This space is for an ongoing 3D computer graphics project — Spherical Harmonic (SH) Lighting Program, which is carried by S.-L. Tracy Huang and Dr. Ian G. Lisle.

This project started from a one-semester coursework Masters research project (ISES 2) in the School of Information Sciences and Engineering (ISE) at University of Canberra in Semester 2, 2006. We continue to work on the project ever since.

Objective of this Space

We would like to share our learning outcomes and resources with people who are interested in SH Lighting and PRT methods.

Other purposes of this space:

  • Recording progress of the project
  • Storing/organising reference materials
  • Keeping motivated to continue working on the project by stating tasks

Spherical Harmonic Lighting Project

The project is to implement a global illumination lighting method in computer graphics called spherical harmonic lighting model. This model was introduced in 2001. To achieve this objective, we use Monte Carlo integration for approximating the lighting equation and spherical harmonics for approximating each term of the lighting equation. We also use the ideas of the Wigner D-matrix and the addition theorem for performing rotation on both cases. A ray-tracing method is also involved for our ray-object intersection test. All our calculations work for arbitrary degree spherical harmonics.

The code is a vanilla C application using OpenGL — no C++ constructs. Shader language GLSL was originally used for the unshadowed SH case, but SH lighting requires too many vertex attributes — later code uses CPU for lighting calculation.

The idea is to implement SH lighting from scratch — deriving mathematical results carefully and basing implementation on those. We did not want to issue DirectX calls, nor to reuse other people’s code without understanding.

The program mainly shows how the spherical harmonic lighting can be performed in a 3D computer graphic scene. We also focus on flexibility of the program such as mouse control, easy switch menu… etc.

Functionality of the Program so far:

  1. Perform 3D Computer Lighting models as follows:
    1. OpenGL Standard Lighting
    2. SH Diffuse Unshadowed Lighting Model
    3. SH Diffuse Shadowed Lighting Model
    4. SH Diffuse Shadowed + Interreflected Lighting Model
    5. SH Diffuse Interreflected Only Lighting Model
  2. Can perform rotation (including rotation of shadows) in real time.
  3. Read mesh data in 3ds format and write it as a scene in 3ds format.
  4. Write out a file for storing SH coefficients of a scene
  5. Generate SH lighting coefficients from light probes
  6. Menus for easy switching at run time of lighting models, SH degree, light probes, scenes, … , etc. (scene switching function is broken at a moment, will fix this shortly)
  7. Texture mapping light probe skybox for realistic background.

Flexible and Efficient Program:

  1. Use Wigner matrices for rotation (Z-Y-Z Euler angles convention, with 3-term recurrence for Y-Wigner) — to arbitrary SH degree — no hard wired matrices.
  2. Use efficient algebraic recurrence for calculating SH values — faster than the method in the Gritty Details.
  3. Calculates diffuse unshadowed SH coefficients by using SH expansion of circularly symmetric function (no ray casting).