<p>This answer tries to give a short overview over some important aspects. Since the HSH definition is rather complex and I couldn't find an overview over some pre-evaluated functions, I didn't provide examples simply because it would take me too much time right now.</p>

<h2>Problem Description &amp; Brute Force</h2>

<p>To determine the convolution any with any set of basis function and thus computing the coefficients we generally need to compute the integral over the domain (= sphere for SH, hemisphere for HSH). Everything we need to do, to represent the hemispherical function <em>f</em>, which is defined over the angles <em>theta</em> ("up/down") and <em>phi</em> ("left/right"), via a coefficient <em>c</em> for HSH basis functions <em>H</em> is the following:</p>

<p><a href="https://i.sstatic.net/gkb7K.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gkb7K.gif" alt="\int_0^{2\pi}\int_0^{\frac{2}{\pi}} f(\theta,\phi) \cdot H_l^m(\theta,\phi) \cdot sin(\theta) \,\, \mathrm{d}\theta\mathrm{d}\phi"></a></p>

<p>The <em>sin(theta)</em> is there because we integrate over the surface of a (hemi-)sphere. Conceptually, the size of a piece of area that comes from changing <em>phi</em> is bigger or smaller on the current theta. More on this <a href="http://tutorial.math.lamar.edu/Classes/CalcIII/TISphericalCoords.aspx" rel="nofollow noreferrer">here</a></p>

<p>If we don't care too much about accuracy or computing time we can solve this simply by sampling: Generate equally distributed (!) directions on the hemisphere, compute the product of f and H and average the outcomes (if you have truly equally distributed points you don't need the <em>sin(theta)</em>).</p>

<h2>Get Started with an Analytical Solution</h2>

<p>Of course we would love to have an analytical solution for our function, but this is where things can get very difficult. As a first step we may need to convert a function that is given on Cartesian directions into spherical coordinates. This part is still easy, just replace all your x, y and z as following:</p>

<p><a href="https://i.sstatic.net/m0jJv.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/m0jJv.gif" alt="(x,y,z) \rightarrow (\sin\theta \cos\phi, \sin\theta \sin\phi, \cos\theta)"></a></p>

<p>Note that this gives us a system where the z-axis is the "up" of the hemisphere (theta=0) which should be represented by the HSH. After that it may already be possible to insert everything into a computer algebra system and solve the equation. Do not try to solve for all <em>m</em> &amp; <em>l</em> but rather try one coefficient at a time, since it is unlikely that there is a compact expression that describes all of them at once. The definition of HSH is relatively complex, which makes it very tedious to evaluate these functions. In <a href="http://www.researchgate.net/publication/221121831_On_the_use_of_hemispherical_harmonics_for_modeling_images_of_objects_under_unknown_distant_illumination" rel="nofollow noreferrer">this paper</a> the zero and 1st order HSH basis functions are mentioned in cartesian coordinates.</p>

<h2>Notes on Rotations &amp; Zonal Harmonics</h2>

<p>Functions that are rotational symmetric around this z-axis are very good candidates for a successful analytic derivation, since they only affect the <em>zonal</em> coefficients, which are all coefficients with index <em>m</em> equals zero. This is especially helpful for the more general Spherical Harmonics where an easy formula exists that allows to rotate any Zonal Spherical Harmonics representation to an arbitrary direction, resulting in a Spherical Harmonics representation without any data loss (see <a href="http://simonstechblog.blogspot.de/2011/12/spherical-harmonic-lighting.html" rel="nofollow noreferrer">here</a>). This means that you can derive ZSH coefficients by assuming that your radial symmetric "function points to z" and rotate it then it into any desired direction. This works perfectly for example with various cosine lobe variations and also gives you the factors you mentioned in the question.</p>

<p>Now the bad news: For HSH, any rotation of a function around another axis than z is lossy, since your function will "touch" the lower undefined hemisphere after the rotation. Therefore, there is also no convenient "Hemi Zonal to HSH" rotation formula. Instead, there are multiple ways to do it with different drawbacks. For more details see the <a href="http://www.cs.ucf.edu/~ceh/Publications/Papers/Rendering/EGSR04GautronEtAl.pdf" rel="nofollow noreferrer">paper</a> and the <a href="https://www.google.de/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;ved=0CDEQFjABahUKEwj6joP13ZrIAhVFVxQKHQliBik&amp;url=http%3A%2F%2Fcgg.mff.cuni.cz%2F~jaroslav%2Fpapers%2Fegsr2004%2Fgautron-egsr2004-hemispherical.ppt&amp;usg=AFQjCNG7U0b1JYorPpGQ3qTkr8C4AOqDpg&amp;sig2=yHEuWgzlvroc65C7wxD2uA&amp;cad=rja" rel="nofollow noreferrer">presentation</a>.</p>

<hr>

<p>By the way: All this is easier with the <a href="https://www.cg.tuwien.ac.at/research/publications/2010/Habel-2010-EIN/" rel="nofollow noreferrer">H-Basis</a>, which is hemispherical as well (but originally only defined for a limited number of frequency-bands).</p>

CC BY-SA 3.0
2015-09-28T22:41:47.203Z
2015-09-28T22:41:47.203Z
Wumpf
<p><a href="http://www.ppsloan.org/publications/StupidSH36.pdf" rel="nofollow noreferrer">Spherical Harmonics</a> (SH) are a way to represent low-frequency spherical functions with only a handful of coefficients. They have some nice mathematical properties, e.g. a convolution with a kernel function <em>h(x)</em> (that has circular symmetry) can be calculated as</p>

<p><a href="https://i.sstatic.net/oh3mt.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oh3mt.gif" alt="(h * f)^m_l = \sqrt{\frac{4\pi}{2l+1}} h^0_l f^m_l"></a></p>

<p>In the case of a <a href="https://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/" rel="nofollow noreferrer">convolution with a cosine lobe</a> for rank 3 SH this results in a simple scaling of the bands with the factors</p>

<p><a href="https://i.sstatic.net/tIf94.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tIf94.gif" alt="[\pi, \frac{2\pi}{3}, \frac{\pi}{4}]"></a></p>

<p>In many cases, e.g. incident light for a given point on an opaque surface, full spherical information is not needed, since half of the sphere is zero / undefined / unused anyway. Thus, <a href="http://www.cs.ucf.edu/~ceh/Publications/Papers/Rendering/EGSR04GautronEtAl.pdf" rel="nofollow noreferrer">Hemispherical Harmonics</a> (HSH) were born.</p>

<p>How does convolution with an arbitrary kernel (with circular symmetry) work for HSH? Can the convolution from SH be extended or is there any paper that goes into details on this?</p>

CC BY-SA 3.0
2015-09-27T12:46:29.590Z
You write "arbitrary kernel with circular symmetry": Doesn't that mean that you actually only need the convolution with the (Hemispheric) Zonal Harmonics part? If your symmetry axis is different you can still use it by adding rotations before and after the Zonal convolution. How to perform rotations is described in the paper. Integration with the Zonal part (m=0) should be comparatively easy. However, as with Spherical Harmonics, it won't be analytically solvable for arbitrary functions. Simple things like cosine lobes should work fine (haven't tried yet though).
Wumpf
CC BY-SA 3.0
2015-09-28T07:42:25.580Z
@Wumpf You're right, that's pretty much what it boils down to. For SH, I'd just scale "each band of f by the corresponding m=0 term from [kernel function] h" (quoting Sloan's Stupid SH Tricks). Question is, can I do the same for HSH?
David Kuri
<hemisphere>
Convolution of Hemispherical Harmonics
David Kuri
# Convolution of Hemispherical Harmonics

(Asked by: username_0 on 2015-09-24)

[Spherical Harmonics](http://www.ppsloan.org/publications/StupidSH36.pdf) (SH) are a way to represent low-frequency spherical functions with only a handful of coefficients. They have some nice mathematical properties, e.g. a convolution with a kernel function *h(x)* (that has circular symmetry) can be calculated as

[![(h * f)^m_l = \sqrt{\frac{4\pi}{2l+1}} h^0_l f^m_l](https://i.sstatic.net/oh3mt.gif)](https://i.sstatic.net/oh3mt.gif)

In the case of a [convolution with a cosine lobe](https://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/) for rank 3 SH this results in a simple scaling of the bands with the factors

[![[\pi, \frac{2\pi}{3}, \frac{\pi}{4}]](https://i.sstatic.net/tIf94.gif)](https://i.sstatic.net/tIf94.gif)

In many cases, e.g. incident light for a given point on an opaque surface, full spherical information is not needed, since half of the sphere is zero / undefined / unused anyway. Thus, [Hemispherical Harmonics](http://www.cs.ucf.edu/~ceh/Publications/Papers/Rendering/EGSR04GautronEtAl.pdf) (HSH) were born.

How does convolution with an arbitrary kernel (with circular symmetry) work for HSH? Can the convolution from SH be extended or is there any paper that goes into details on this?

**Tags:** hemisphere

> **Comments:**
> **username_1**: You write "arbitrary kernel with circular symmetry": Doesn't that mean that you actually only need the convolution with the (Hemispheric) Zonal Harmonics part? If your symmetry axis is different you can still use it by adding rotations before and after the Zonal convolution. How to perform rotations is described in the paper. Integration with the Zonal part (m=0) should be comparatively easy. However, as with Spherical Harmonics, it won't be analytically solvable for arbitrary functions. Simple things like cosine lobes should work fine (haven't tried yet though).  
> **username_0**: @username_1 You're right, that's pretty much what it boils down to. For SH, I'd just scale "each band of f by the corresponding m=0 term from [kernel function] h" (quoting Sloan's Stupid SH Tricks). Question is, can I do the same for HSH?  

---

## 1 answers

### Answer by username_1 on 2015-09-28. Score: 4 | Accepted answer

This answer tries to give a short overview over some important aspects. Since the HSH definition is rather complex and I couldn't find an overview over some pre-evaluated functions, I didn't provide examples simply because it would take me too much time right now.

## Problem Description & Brute Force

To determine the convolution any with any set of basis function and thus computing the coefficients we generally need to compute the integral over the domain (= sphere for SH, hemisphere for HSH). Everything we need to do, to represent the hemispherical function *f*, which is defined over the angles *theta* ("up/down") and *phi* ("left/right"), via a coefficient *c* for HSH basis functions *H* is the following:

[![\int_0^{2\pi}\int_0^{\frac{2}{\pi}} f(\theta,\phi) \cdot H_l^m(\theta,\phi) \cdot sin(\theta) \,\, \mathrm{d}\theta\mathrm{d}\phi](https://i.sstatic.net/gkb7K.gif)](https://i.sstatic.net/gkb7K.gif)

The *sin(theta)* is there because we integrate over the surface of a (hemi-)sphere. Conceptually, the size of a piece of area that comes from changing *phi* is bigger or smaller on the current theta. More on this [here](http://tutorial.math.lamar.edu/Classes/CalcIII/TISphericalCoords.aspx)

If we don't care too much about accuracy or computing time we can solve this simply by sampling: Generate equally distributed (!) directions on the hemisphere, compute the product of f and H and average the outcomes (if you have truly equally distributed points you don't need the *sin(theta)*).

## Get Started with an Analytical Solution

Of course we would love to have an analytical solution for our function, but this is where things can get very difficult. As a first step we may need to convert a function that is given on Cartesian directions into spherical coordinates. This part is still easy, just replace all your x, y and z as following:

[![(x,y,z) \rightarrow (\sin\theta \cos\phi, \sin\theta \sin\phi, \cos\theta)](https://i.sstatic.net/m0jJv.gif)](https://i.sstatic.net/m0jJv.gif)

Note that this gives us a system where the z-axis is the "up" of the hemisphere (theta=0) which should be represented by the HSH. After that it may already be possible to insert everything into a computer algebra system and solve the equation. Do not try to solve for all *m* & *l* but rather try one coefficient at a time, since it is unlikely that there is a compact expression that describes all of them at once. The definition of HSH is relatively complex, which makes it very tedious to evaluate these functions. In [this paper](http://www.researchgate.net/publication/221121831_On_the_use_of_hemispherical_harmonics_for_modeling_images_of_objects_under_unknown_distant_illumination) the zero and 1st order HSH basis functions are mentioned in cartesian coordinates.

## Notes on Rotations & Zonal Harmonics

Functions that are rotational symmetric around this z-axis are very good candidates for a successful analytic derivation, since they only affect the *zonal* coefficients, which are all coefficients with index *m* equals zero. This is especially helpful for the more general Spherical Harmonics where an easy formula exists that allows to rotate any Zonal Spherical Harmonics representation to an arbitrary direction, resulting in a Spherical Harmonics representation without any data loss (see [here](http://simonstechblog.blogspot.de/2011/12/spherical-harmonic-lighting.html)). This means that you can derive ZSH coefficients by assuming that your radial symmetric "function points to z" and rotate it then it into any desired direction. This works perfectly for example with various cosine lobe variations and also gives you the factors you mentioned in the question.

Now the bad news: For HSH, any rotation of a function around another axis than z is lossy, since your function will "touch" the lower undefined hemisphere after the rotation. Therefore, there is also no convenient "Hemi Zonal to HSH" rotation formula. Instead, there are multiple ways to do it with different drawbacks. For more details see the [paper](http://www.cs.ucf.edu/~ceh/Publications/Papers/Rendering/EGSR04GautronEtAl.pdf) and the [presentation](https://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CDEQFjABahUKEwj6joP13ZrIAhVFVxQKHQliBik&url=http%3A%2F%2Fcgg.mff.cuni.cz%2F~jaroslav%2Fpapers%2Fegsr2004%2Fgautron-egsr2004-hemispherical.ppt&usg=AFQjCNG7U0b1JYorPpGQ3qTkr8C4AOqDpg&sig2=yHEuWgzlvroc65C7wxD2uA&cad=rja).

---

By the way: All this is easier with the [H-Basis](https://www.cg.tuwien.ac.at/research/publications/2010/Habel-2010-EIN/), which is hemispherical as well (but originally only defined for a limited number of frequency-bands).


---

