Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

cosine lobe in spherical harmonics

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Lightness1024   Members   


Posted 27 September 2012 - 07:41 AM

Hi there, I have an issue understanding contents of various resources and papers around the place talking about how to express a cos lobe in SH basis.

in their LPV implementations, both Andreas Kirsch (c.f http://blog.blackhc....annotations.pdf)
and Benjamin Thaut (http://3d.benjamin-thaut.de/?p=16) are using similar definitions, either premultiplied with c0 and c1 coefficients or not, but basically the same. (0.25, 0.5) along z (for ZonalH), after multiply with c0 and c1.

you can find the rotation formula along axis n in Andreas Kirsch annotation, and concludes that it results to the same thing, but spread on all SH coefficients (in the band 2), just multiplied by normal vector: (0.25,-0.5*ny,0.5*nz,-0.5*nx).

However, if you read Ramamoorthi, they use another way of calculating the coefficients, instead of doing the actual integrand to project the cos(theta) function on the carthesian basis functions, they use the base definitions of the Ylm to extract some horrible formula full of square roots and factorials, and they decide the coefficients are:
(Pi, 2 Pi / 3, Pi / 4) for 3 bands of Zonal Harmonics. (so simply 0 on the non zonal terms)
this is relayed by Sebastien Lagarde on his blog:

though I don't get the feeling that he is truly understanding those coefficients since he mention the sources (peter pike sloan, robert green and ShaderX2) to get them.

and talking about Sloan and Green, we also find disturbing lack of consistencies between papers, notably in the cartesian definitions of the SH basis, when one claims the Zonal of order 2 is k*(3z²-1) the other (Green) claims k*(2z²-x²-y²) !! wtf ?

and there is another inconsistency in the constant of the l=1,m=2 coefficient, where Green claims it is 1/2*sqrt(15/Pi), the others claim it is 1/4*sqrt(15/Pi) which is quite different.

When I calculate the projeciton of the cos lobe on that l=1,m=0 coefficient I get sqrt(5*Pi)/8 which is a coefficient I found nowhere on the literature though I quaduple checked my math.
Also, nobody talks clearly of how to rotate the order 2 coslobe, in ramamoorthi it is completely forgotten, like if it was trivial, in Green he suggests it is extremely complicated and "reaches the limit of current research".
In Sloan, you find the idea that Zonal rotations are simpler, "only O(N) compared to O(N²)" he says.
And if you read Halo 3 engine siggraph 2008 slide presentation, the SH rotation shader they have seems to be quite complicated.
Though this one surely is for any SH ... :/

I simply want to project a goddamn environment map into SH, convolve it with a coslobe.
there is a sample code from Nvidia for that but for paraboloid cube maps.
but I don't understand really how to do it properly, and trying something blindly is the best way to get something, thinks that it works but actually it is wrong but in a way that is difficult to see.
(go prove that an irradiance map is biaised, or incorrectly scaled etc...)

thanks for any help on that.

edit: actually I found a paper that corroborates my result :
but it clearly is different from the result of Lagarde and Ramamoorthi for coefficients of the same function. (ramamoorthi calls it Âl)
the only missing thing now is the rotated clamped cosine lobe in 3 band SH.

edit2: i found some promising stuff for that last part : http://www.iro.umont.../SHRot_mine.pdf
however it will take me ages to understand that paper :'( if I can at all.
for the moment, i'm just going to calculate projections of cos lobes along 6 directions and interpolate between them linearly. at least i can grasp that.

edit3: I have calculated coefficients for the cosine lobe along x : [S0=sqrt(pi)/2, S3=-sqrt(pi/3), S7=sqrt(15*Pi)/8] 0 elsewhere.
the plot is attached file to this post. we can clearly see that it is tilted and not resembling the coslobe along Z. Which would invalidate the famous "rotation invariant" property of SH that everybody seems to praise. Or rather, if I understand it, they seem to praise an erronous assumption that rotations will not make the projection vary, which is false, the property merely says that rotating the coefficients will get the same projection than reprojecting the rotated function. It never mention anything about keeping the same shape. Sload and Green both mention that function will not 'wobble' when rotated. I think this is false and my plot tends to prove it.

Attached Thumbnails

  • coslobe_x_axis.jpg

Edited by Lightness1024, 28 September 2012 - 03:47 AM.

#2 Sébastien Lagarde   Members   


Posted 29 September 2012 - 01:21 PM


I don't understand your thread but for this part:
"and they decide the coefficients are:
(Pi, 2 Pi / 3, Pi / 4) for 3 bands of Zonal Harmonics. (so simply 0 on the non zonal terms)"
I join you a shot of mathematica showing the derivation. It is just a projection of max(cos(theta), 0) into SH then an application of the convolution term.

Also, the D3DX SH math library is now open source and containt the cubemap projection, so enjoy:


Attached Thumbnails

  • Mathematica.png

Edited by Sébastien Lagarde, 29 September 2012 - 01:23 PM.

#3 Lightness1024   Members   


Posted 01 October 2012 - 04:23 AM

Hello, nice to see you here, what you posted up there helps a lot, the missing link was that "convolution coefficient".
I read in the paper "relationship between radiance and irradiance" that this convolution factor is extracted from the rotation formula "exp(Im Beta)*Dlm,0" but frankly it is out of my grasp.
But I'll take that for the correct series of coefs. Posted Image
I'm going to consider that what I have seen in Kirsch's and Thaut's LPV's implementations : the serie {1/4, 1/2} ; must be false then.Posted Image
In Nvdidia's LPV's implementation the explanation is matching what you said up there, and falls back to your result.

merci bien Sébastien. Posted Image

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.