Spherical Harmonics is a priceless tool for production rendering: It uses periodic functions on the surface of a sphere to isolate or accumulate influence from a certain direction.
In U-RENDER we use it to get diffuse ambient illumination based on HDR environment maps in real-time.
In this article we’ll avoid being too technical. Our aim is simply to give you an overview about this mathematical concept and its extremely useful applications. Ready? Let’s go!
What are Spherical Harmonics?
Spherical Harmonics, known also as SH, were introduced by Pierre Simon de Laplace in 1782, to calculate gravity influence. They basically are a data representation, nothing more, nothing less.
They are widely used to solve issues in different areas: from problems in gravitational, electric fields and in heat equations to quantum chemistry and physics to model the electron configuration in atoms.
Because of their potential to encode any information signal over a sphere, they are perfect for Computer Graphics (CG). Now, the whole story becomes more interesting for you. Do you know how are SH employed in CG?
They have been used on:
- image relighting,
- image based rendering with controllable lighting,
- HDR environment maps,
- volumetric scattering effects,
- atmospheric scattering and other more.
In particular, SH lighting is a way to calculate the illumination on 3D models from Image Based Lighting (IBL) sources in order to enable you to catch, relight and display Global Illumination (GI) style images in real-time. Comparing it with Ray-tracing using GI, the computational effort is relatively lower. This is why, Spherical Harmonics are also considered a fast alternative for diffuse illumination. Since Spherical Harmonics create diffuse ambient light by making the entire image brighter, you need to set Ambient Occlusion (AO) to darken certain areas. SH and AO are both two similar mathematical demonstrations. Using them together permits you to reach a more balanced result. See picture below.
Another way of thinking to Spherical Harmonics is seeing them as a method to encode an image over a sphere (that can represent incoming light, occlusion, or other types of data), in terms of their frequency representation. Hypothetically, you can represent any kind of resolution with infinite bands. However, only the first few bands are usually employed.
Find out the benefits of Spherical Harmonics!
Using SH has some great advantages:
- the rotation is continuous and regular because they are camera view independent,
- no stitching lines,
- they couldn’t be squeezed or snapped,
- they’re easy for vector units to control.
In real-time rendering, they compute all the incoming light by adding the light sources and then multiplying it by the surface functions. The diffuse light is also clearly influenced by the color of the object.
Last but not least, the combination of SH and AO enables you to have stunning results in photorealism.
If you want to know more about this topic, we suggest an interesting paper made by the University of California, in San Diego: “Analytic Spherical Harmonic Gradients for Real-Time Rendering with Many Polygonal Area Lights”, ACM Trans. Graph., Vol. 39, No. 4, Article 1, July 2020.
Now it’s your turn! Get inspired by downloading and using our sample HDR images. With accurate reflections and image based lighting, you’ll create amazing and realistic scenes.