I have recently been looking at the use of spherical harmonics as a way of doing real-time diffuse lighting and shadowing effects in OpenGL. As I usually only really understand stuff when I can see it, I did a quick viewer in Processing to help make sure I was getting all the algorithms correct. Some of the visualisations and shapes started to look pretty good, so I figured I’d polish it a bit and put it up on my site.
The best way to use this is to start with the ‘Random Shape’ buttons and some of the items in the ‘Examples’ menu. The items at the bottom of that menu are a range of visualisation settings that I thought added something to the shape.
The above is an embedded interactive Java applet that demonstrates spherical harminic patterns. Click and drag the sliders with the left mouse buttonto control the patterns and use the middle and right buttons to pan and rotate the view.
Launch as a separate application.
Right-click the icon for your operating system and choose 'Save target as...'
NOTE: The native applications allow you to save images and the generated shape as a DXF file.
Spherical Harmonics are really interesting as they can be used to reduce what is usually an inordinately expensive integration of the diffuse lighting environment into a series of much faster dot products. This is done by approximating the diffuse lighting environment, given as a complex luminous distribution over a sphere, with a matrix of Spherical Harmonics coefficients. Use this instead of the standard diffuse surface reflection model and very detailed and realistic diffuse lighting effects are possible to real-time. Robin Green explains it better and in much more detail in Spherical Harmonic Lighting: The Gritty Details.
The viewer itself was probably most inspired by Paul Bourke’s page on Spherical Harmonics, as well as the many supershapes viewers already written for Processing. Of course, with this one under my belt, a supershapes viewer of my own probably won’t be far behind…
Wow - I got it!
I have looked at spherical harmonics before, but I never really got it. As soon as I clicked on the luminosity map button some times, I finally understood and could see the colour map and shape relationships.
Be careful though, I click too many times (maybe hundred or so) and the model turned entirely red. Refresh the page fixed it though.
Thanks for your great website,
Wilhelm