So, I've gone through this paper (http://www.inf.ufrgs.br/~oliveira/pubs_files/Slomp_Oliveira_Patricio-Tutorial-PRT.pdf). It's all perfectly clear how everything works (or at least I think so), I implemented the stuff - it works. The only thing that bugged was that I had to do pretty lot of computation to just project some analytical lights (as the code in the paper shows you integrate the light function through a number of samples, which could be a lot) and I was pretty sure I had seen SH to be "simpler". And I found chapter 2.15 in ShaderX3. This is the code that author uses for projecting a single directional light into SH:
Later on, these nine SHCoeffs are passed to the vertex shader to compute the final illumination:
vec3 norm = gl_Normal;
color = Coefficients;
color += Coefficients * norm.x;
color += Coefficients * norm.y;
color += Coefficients * norm.z;
color += Coefficients * norm.x * norm.z;
color += Coefficients * norm.y * norm.z;
color += Coefficients * norm.x * norm.y;
color += Coefficients * (3.0 * norm.z * norm.z - 1.0);
color += Coefficients * (norm.x * norm.x - norm.y * norm.y);
This stuff looks much simpler and I don't see any need for sophisticated integration, nor even any dot(lightVector, normal) term (which is present in the PRT Tutorial paper in the projection of the transfer function). So my question is simply about the derivation of the ShaderX3 article's constants and how this relates to the "general" solution presented in the PRT Tutorial paper?
As you can see, in line "HERE" I calculate the inertia tensor in world space, by simply multiplying the local inertia matrix by the rigid body's orientation matrix (which is effectively the local-to-world matrix without the translation part).
Note that I use row-major matrix order.
The way I transform the local inertia tensor seemed natural to me this way. I have local space, I have local-to-world transform, so I just mul by that matrix to get inertia in world space. And it works just fine. I even made a simple simulation in Unity using their rigid body to make sure that my behaves more or less the same. And it does.