# What Exactly Is Spherical Harmonics?

#1

This is in response to Jeremy Birn’s suggestion from another thread in GD.

So what is spherical harmonics? from a quick wikipedia search I get that it is a mathematical solution. Other than that I am completely lost in what it is used for and how it is used (the math formulas hurt my brain!)

To be precise, what exactly is spherical harmonics in the context for computer graphics, eg. How it was used in Avatar to light the forests?

#2

Essentially it is a much faster way of approximating a very blurry environment map. If you want to actually blur an environment then it takes a very long time as you need to take into account a lot of pixels.

I’m pretty sure that 3delight’s indirectdiffuse() function uses spherical harmonics if you just pass it an environment map.

Simon

#3

#4

As for rendering i saw master zap put this on his blog

Stuff you never even knew about mental ray 3.5
One of the coolest features of mental ray 3.5 is the way the final gathering feature works.

It may deceptively seem to work the same way as before, but it doesn’t. One really important point is that each FG point stored isn’t just a color, it’s a whole set of colors - with directional information (for the tech heads: think spherical harmonics).

What does this mean? It means a lot for bump-mapping!!

In earlier version of mental ray, bumps basically had to be resolved by the adaptivity of the final gathering, causing an extreme density of final gather points due to the variation in the bumps.

But in mr 3.5 it works completely differently; the final gathering is actually calculated on the un-bumped normal vector, and the result is stored including directional data… and then at render time, data is looked up into this directional data.

The result is:

Much lower density of final gather points needed, the existance of bump maps does not increase the density!
Very high quality of directional effects of indirect light on the bump maps, at levels previously impossible.

This makes bumpy surfaces render faster, and resolve in much greater detail, causing details in the bump maps in “dark” areas, i.e. areas only lit by bounce lights or other forms of indirect light such as photons.

The catch:

Some earlier shaders out in the wild intentionally tried to work around this problem. These workaround can potentially interfere with the “correctness” of the new method.

The good stuff:

The cool stuff is that due to this new FG storage format, it is possible to do directional lookups into the FG map. This is how the “Highlights Only” mode in the Arch&Design material works, which can give a very good “visual simulation” of extremely glossy reflections, without actually shooting a ton of rays and taking almost no extra render time!

I use it differently. is a really nice cheat if you are into non physical correctness.

i actually ranted about that some time ago here http://forums.cgsociety.org/showthread.php?t=866650 (you gotta read through page 2 mostly)
some methods aren’t pretty or physically accurate, but work really nice if you get the hang of them. i use them all the time, actually i 90% of the time use them at my project at work… specially when i have to render 3000 frames or more in 2 days with bunch of animated objects in hd res and still looking “pretty” and not flickery… AO is your friend here.

if you want to convert an hdr to a blurred image by using spherical harmonics you can get HDR shop or if you don’t want to spend money then this app http://www.hdrlabs.com/picturenaut/index.html with this plugins installed(Spherical harmonics is in that pack) http://www.hdrlabs.com/picturenaut/plugins.html its called Diffuse SH

hope it helps.

ps: don’t know how avatar did it. i’m still trying to figure out if sticking their pony tails into animals was correct :curious:

#5

hey Jeb, what is mentioned there is not spherical harmonics, and spherical harmonics isn’t just a way of bluring hdri maps. V-ray has a Spherical Harmonic implentation now, so I recommend people check that out if they want a good idea of how it works ( or read playmesumch00ns post)

#6

My head spins with all those formulas…

thanks for pointing it out Ndeboar, well at least that’s what the plugin said

and since it helps me get faster renders so all good. i wonder how that works in vray? anywhere to see it in action or specifically how that’s handled ?

#7

#8

#9

Here is a little tutorial in the docs

http://www.spot3d.com/vray/help/maya/150R1/tutorials_sph_harm.htm

And if you have access to the forums there are a few threads if I remember correctly.

#10

Whoa. Is it possible to do spherical harmonics in Vray with 3ds max? That documentation is for Maya. I’d love to have this ability in Vray for Max.

#11

Whoa. Is it possible to do spherical harmonics in Vray with 3ds max? That documentation is for Maya. I’d love to have this ability in Vray for Max.

That indeed would be impressive considering it took Weta 2 plus years and a team of genius experts to implement Joe’s vision.

b

#12

The thing about spherical harmonics is the rendering equation is complex and contains a lot of functions that are not linear in nature (powers, etc)

Spherical harmonics allows you to take that numerical integration and turn it from a slow complex equation and turn it into a long linear equation. This is faster for the computer to render.

This is why spherical harmonics is important to real-time rendering.

But it has other applications as well.

#13

All I’m saying is that if Vray for Maya can already do it, surely Vray for Max is not far behind in implementing this feature. Unless of course I am mistaken.

#14

That indeed would be impressive considering it took Weta 2 plus years and a team of genius experts to implement Joe’s vision.

Weta’s version was a certain implementation of spherical harmonics, and needlessly complicated according to some that witnessed the SIGGRAPH presentation.

I missed it, I was possibly getting .

#15

So is the Spherical Harmonics engine in Vray similar to the Point-Based color bleeding in Renderman, or are we talking about two different things here?

#16

From the looks of it the spherical harmonics implementation in VRay (and mr) is just doing radiance caching. Same as a final gather cache but storing a representation of the incoming light from each direction rather than just “how much light got here”.

It’s not the same at all as point-based color bleeding in prman (although confusingly, Pixar’s implementation uses spherical harmonics internally).

Neither has anything to do with the spherical harmonics lighting engine at weta, apart from the fact that they use spherical harmonics, they’re all trying to solve different problems.

#17

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.