YASRT
Yet another simple raytracer · v0.1 beta 14
Method
Monte Carlo
Platforms
14
Licence
Free · personal
Spherical harmonic lighting using OpenGL

Spherical Harmonic lighting is a real-time rendering technique that uses a pre-process step — the projection of the lights, of the model and of the transfer function onto the spherical harmonic basis — to render scenes realistically using any type of light source. It is primarily used to reproduce diffuse lighting. The basic idea is to evaluate an approximation of the rendering equation at each vertex of the geometry by projecting its components onto the spherical harmonic basis during a pre-process step.

Three approximations
01

SH diffuse unshadowed

The geometric term reduces to the cosine term — the dot product between the surface normal and the light direction. Identical to standard diffuse lighting under Lambert's law, except the normal is encoded in the SH coefficients.

02

SH diffuse shadowed

The visibility term is added to determine shadowing at a given vertex, easily achieved with a raytracer. Realistic shadows for the same scene, at the cost of extra calculation time.

03

SH diffuse inter-reflected

Lighting arriving indirectly from other objects is taken into account. The pre-process handles direct and indirect lighting, giving global illumination for the scene.

Once coefficients exist for all three modes, the rendering equation is reconstructed at runtime by adding and multiplying them together. Outgoing radiance is calculated per vertex, and Gouraud shading renders the full scene in real time.

Keyboard
f / F
Switch to full screen display
n / N
Switch to windowed display
D
Next rendering mode (GL, SH un-shadowed, SH shadowed)
d
Previous rendering mode (GL, SH shadowed, SH un-shadowed)
S
Scale up the lighting intensity
s
Scale down the lighting intensity
> / <
Toggle between the different cameras, forward / backward
b / B
Capture the window to a BMP file named HDRISHLightingXXXX.bmp
a / A
Toggle animation on/off
y / Y
Switch display mode: point, triangle and fill
q / Q
Exit the program
Command line
-s · --samples
integer
The size of the grid of stratified samples
-b · --bands
integer
The number of bands used to approximate the spherical function
-h · --height
integer
Height of the display window
-w · --width
integer
Width of the display window
-hdr · --hdr
filename
Name of the HDR light probe to load
-3ds · --3ds
filename
Name of the 3ds scene to load
-hs · --hdrscale
float
Scale the intensity of the input HDR image
-dm · --directmode
none
Force direct mode rendering to allow contrast adjustment
-nd · --nodisplay
none
Only calculate SH coefficients (no display) and exit
-nc · --nocache
none
Ignore cached SH coefficients and force recalculation
-v · --verbose
none
Verbose mode
-? · --help
none
Display a help message
Lighting model comparison
OpenGL Phong · 3DS Max scanline · SH unshadowed · SH shadowed
Captures
Downloads
[×]Windows 32-bitzip
[×]Linux Inteltar.gz
Videos · XVID
[!]

Requires HDRI light probes in spherical .hdr format from Paul Debevec's site — not the vertical cross cube format.