<p>Spherical harmonics are generally used for dynamic objects in your scene, while fully-baked lighting is used for static objects. </p>

<p>A typical game engine will use both. During the GI pass, all surfaces marked as static will have their global lighting fully baked - generally into a lightmap texture rather than per-vertex. At the same time, a bunch of light probes distributed throughout your scene will receive omnidirectional lighting, and this gets converted into SH. Since SH coefficients interpolate nicely, a mesh moving through your scene can pick up the nearest few light probes (generally 4), and use the weighted average to decode a good approximation of the ambient lighting at its current location.</p>

<p>Another use for SH is to render less-important dynamic lights in a scene with many lights in it. The most important light or two can be rendered fully dynamically per-pixel, then for each renderer, the SH coefficients of the less-important lights are calculated and added to the light probe data. This allows the lights to change in real-time, and be rendered effectively for free per-vertex in the shader, with a small CPU overhead.</p>

CC BY-SA 3.0
2018-01-23T18:26:23.997Z
I would also add that SH (or the related [H-basis](https://www.cg.tuwien.ac.at/research/publications/2010/Habel-2010-EIN/)) is useful for normal maps on static objects. A bumpy surface will reflect light from different directions, so you want a directional representation of incoming light at the surface.
Nathan Reed
CC BY-SA 3.0
2018-01-23T20:15:09.983Z
Thanks for the link, I hadn't heard of that basis before. Just been reading about spherical Gaussians which can apparently fake rough specular as well, but the math is pretty gnarly!
russ
CC BY-SA 3.0
2018-01-23T09:09:35.907Z
2018-01-23T09:09:35.907Z
russ
<p>My question is about spherical harmonic lightning, in the context of computing the coefficients with an expensive GI algorithm and passing them to the vertex shader</p>

<p>Another way is to just use an expensive GI algorithm to compute vertex colors and just use them instead.</p>

<p>What is the advantage of using the former method? I'm thinking that you can't do reflections with the latter method, and also there's rotational symmetry in SH (i don't know much about) that allows you to do some very simple dynamics with your lights and meshes. Is there any more points i'm missing?</p>

<real-time><spherical-harmonics>
Advantages of spherical harmonics over baked vertex lighting?
vuoriov4
# Advantages of spherical harmonics over baked vertex lighting?

(Asked by: username_0 on 2018-01-22)

My question is about spherical harmonic lightning, in the context of computing the coefficients with an expensive GI algorithm and passing them to the vertex shader

Another way is to just use an expensive GI algorithm to compute vertex colors and just use them instead.

What is the advantage of using the former method? I'm thinking that you can't do reflections with the latter method, and also there's rotational symmetry in SH (i don't know much about) that allows you to do some very simple dynamics with your lights and meshes. Is there any more points i'm missing?

**Tags:** real-time, spherical-harmonics


---

## 1 answers

### Answer by username_1 on 2018-01-23. Score: 3 | Accepted answer

Spherical harmonics are generally used for dynamic objects in your scene, while fully-baked lighting is used for static objects.

A typical game engine will use both. During the GI pass, all surfaces marked as static will have their global lighting fully baked - generally into a lightmap texture rather than per-vertex. At the same time, a bunch of light probes distributed throughout your scene will receive omnidirectional lighting, and this gets converted into SH. Since SH coefficients interpolate nicely, a mesh moving through your scene can pick up the nearest few light probes (generally 4), and use the weighted average to decode a good approximation of the ambient lighting at its current location.

Another use for SH is to render less-important dynamic lights in a scene with many lights in it. The most important light or two can be rendered fully dynamically per-pixel, then for each renderer, the SH coefficients of the less-important lights are calculated and added to the light probe data. This allows the lights to change in real-time, and be rendered effectively for free per-vertex in the shader, with a small CPU overhead.

> **Comments:**
> **username_2**: I would also add that SH (or the related [H-basis](https://www.cg.tuwien.ac.at/research/publications/2010/Habel-2010-EIN/)) is useful for normal maps on static objects. A bumpy surface will reflect light from different directions, so you want a directional representation of incoming light at the surface.  
> **username_1**: Thanks for the link, I hadn't heard of that basis before. Just been reading about spherical Gaussians which can apparently fake rough specular as well, but the math is pretty gnarly!  

---

