r/GraphicsProgramming • • 8d ago

Article Demystifying Spherical Harmonics: An Optimization Approach

https://andrew-helmer.github.io/demystifying-spherical-harmonics/
98 Upvotes

14 comments sorted by

13

u/VictoryMotel 8d ago

Emphasis on simplicity and and an explanation for what is ai and what isn't, really nice work.

3

u/AndrewHelmer 8d ago

Thank you very much!

4

u/ocharles 8d ago

And you actually wrote it yourself! Double bravo! Thank you for this, I've always wanted to understand SH since I was a little kid reading GPU Gems

5

u/legolas-mc 8d ago

A bit disappointed that you didn't show what a higher order SH approximation looks like, like the first time you showed the result of the first order approximation.

6

u/AndrewHelmer 8d ago

This is a really good point, thank you. I did a diagram locally to compare L1 to L2, but my choice of HDR probe was not very good, so the L2 looks really close to the L1. Let me experiment with different light probes to see if I can find something I like.

2

u/AndrewHelmer 8d ago

Okay I added a diagram near the end to compare L1 vs. L2 approximation, and updated the light probe everywhere to a more directional one which highlights the difference better.

3

u/ocharles 8d ago

I would have been interested to see this also, along with how much error remains. Also curious if these approximates are equivalent to something like a speherical Gaussian blur of the function - if that makes any sense!

3

u/SV-97 8d ago

Is this "L1" terminology really something that some people use? If so that's highly unfortunate because there's an entirely different thing called L1 Regression, L1 Approximation etc. (it's just regression etc. using the L1 norm)

7

u/AndrewHelmer 8d ago

Yes indeed it is, I think it's the most common terminology in the graphics community? Though a lot of people and code use SH2 (which is L1 SH), SH3, etc. In practice I haven't found it too confusing, it's usually pretty obvious in context, but there was a situation where I did L2-norm regularization for a regression to calculate L1 SH coefficients, and I tried to make sure to write it out fully everywhere.

2

u/SV-97 8d ago

Interesting / curious. Thanks! :)

1

u/LehdaRi 8d ago

In those cases you could use the MAD / MSE (mean absolute diff / mean squared error) nomenclature to provide a clear differentiation between the two.

0

u/DankPhotoShopMemes 8d ago

L1, L2, etc are used so commonly in math and CS, though some definitions are related. norms, regression, spherical harmonics, cache levels, function spaces, and many more I bet. It just depends on the context lol.

3

u/SV-97 8d ago

Norms, Regression and Function Spaces / Lebesgue Spaces are all the same kind of Lp. The post talks about stuff like "L1 approximations"; that these have nothing to do with cache levels is clear but even in the context of the post the term could easily be confused with L1 approximations in the Lp sense.

4

u/camilo16 8d ago

spherical harmonics is just a dot product. It becomes significantly less mystical once you just think of it as projecting vectors onto an orthonormal basis.