
I have a question about spherical harmonics.
Let us imagine a simple scenario where we are rendering a simple cube and all the sphericalHarmonicBase values are the same. I am slightly confused on how this will look.
I am porting from XNA and its right handed coordinate system to DirectX and a left handed coordinate system.
I have found that the face of the cube that is facing a neutral camera (the Z face) has less spherical harmonics contribution while the +Z face has more. And this can be seen on the rest of the faces.
But inverting the Z value of the normal only for the purpose of spherical harmonics (leaving the rest of the lighting pipeline to use the supposedly correct left handed normal) makes the spherical harmonics shading more uniform. But I think it also looks more
bland.
So I was wondering if I'm actually ruining the way the effect is supposed to look. How is a cube supposed to look if the entire lighting contribution comes from spherical harmonics, with all parameters set to the same value?


Coordinator
Dec 18, 2013 at 8:53 PM

Hi blo!!
"I have found that the face of the cube that is facing a neutral camera (the Z face) has less spherical harmonics contribution while the +Z face has more. "
It has to have the same contribution. Do you try the same configuration on my engine to see what happens? The spherical harmonic illumination has to be uniform in all directions.
"So I was wondering if I'm actually ruining the way the effect is supposed to look. How is a cube supposed to look if the entire lighting contribution comes from spherical harmonics, with all parameters set to the same value?"
The object should be illuminated uniformly in all directions. And if the spherical harmonics values are the same then the illumination should look very bland.
I am not sure if I understand you correctly.
Jose.



Hi Jose!
Thank you for the quick answer! I'm trying to fix up my entire lighting pipeline and the feedback of professionals is invaluable!
So it is as I suspected: spherical harmonics lighting should be uniform in all directions. I did not try it now with XNA Final Engine, but I did try your engine a long time ago and that is why I first picked up on spherical harmonics and have used them ever
since.
So I have a very stupid question: do you compute the SH value based on the normal as read from the normal map or from the normal transformed to tangent space? Computing it from the base normal gives indeed very uniform lighting conditions. computing it from
the transformed normal with Z gives probably very nonsensical results that is not that uniform, but it looks interesting.
To avoid further stupid questions, I'll go over:
http://www1.cs.columbia.edu/~ravir/papers/envmap/
http://www.research.scea.com/gdc2003/sphericalharmoniclighting.pdf
but the second one looks a bit too advanced for me.
Thank you!


Coordinator
Dec 19, 2013 at 9:39 PM

Not sure if I understand you.
I use the normals stored in my GBuffer and they are stored in view space. You need to calculate the spherical function (in this case spherical harmonics but it could be, for example, a cube map) in the correct way. And that means in this case sampling using
world space direction vectors and that means world space normals. Of course. I transform view space normals to world space.
I think you need to understand what you are doing instead of guessing. You are sampling a very compressed cube map (spherical harmonics) in the direction you think there is more illumination coming. Spherical harmonics are great because they are very compressed,
you can calculate the spherical function (sampling) fast, you can add more contribution to the spherical function also very fast, etc. Spherical harmonics also have interesting mathematical properties. It is not just a compression technique.
Also understand that these "cube maps" are convoluted. Sampling one direction equals to sampling several at the same time but more in the general direction and less in the other areas.
It is hard to me to explain all of this in one post. First try to understand what they are and then ask me questions. Do not enter deeply on the mathematics. It is not needed.
Good luck!!
Jose.

