Re: [Algorithms] Cubemap to spherical harmonics (again)
Brought to you by:
vexxed72
From: <ca...@gm...> - 2006-04-21 22:01:28
|
That seems to be right and is pretty close to what I do. The only difference is that I compute the area element in a different way, computing the solid angle of the texel polygon using Girard's formula: omega =3D sum_i(alpha_i - (n-2)*pi) where alpha_i is the dihedral angle between the planes that form the polygon and n is the number of planes (Graphic Gems R27, R6). You can find another derivation of the area element of the texels of the cube map in Manne Ohrstrom thesis: http://coblitz.codeen.org:3125/citeseer.ist.psu.edu/cache/papers/cs/30957/h= ttp:zSzzSzwww.student.lu.sezSz~cif97mohzSzthesis.pdf/spherical-harmonics-pr= ecomputed-radiance.pdf I assume that r^-3/2 is the differential solid angle, where did you get that result? With a low number of coefficients, the results usually look weird, but after convoling it with the cosine term and sampling it, you end up getting the nice results. -- Ignacio Casta=F1o ca...@gm... On 4/21/06, Alen Ladavac <ale...@cr...> wrote: > Hi list, > > I believe that this issue, even though discussed a lot, was never > completely clarified in one place. So as my implementation is a kind > of a Frankenstein creation stitched from fragments of math that I > understand and pieces that still make by head steam, I guess it can't > hurt to run the actual result by some people that comprehend the SH > math better than me. > > The reason I ask is that when I run it on a cube that has upper half > pure red and lower half pure green, I get something that I don't quite > expect. Upon evaluating the resulting SH in various directions, I get > mostly yellow everywhere, with just a tiny bit of red/green in the > up/down directions. > > Even with the cosine term, I'd expect the straight up/down directions > to be pure red/green. Is my expectation wrong, or is the problem in my > implementation? > > Here is the pcode: > > correction =3D 1/(PI*16/17) > pixelarea =3D 4/(sizeU*sizeV) > > for each face on the cube > for each pixel on the face > > vdir =3D position on cube (domain is (-1,+1)^3) > r =3D len(vdir); > vdir /=3D r; > > da =3D pixelarea*r^(-3/2) > > rgb =3D sample the pixel value > rgb *=3D angle * correction; > addtoSHC(rgb,dir) > > Where "addtoSHC()" is the one normally used by the directional light. > I.e. it uses the squared factors with extra corrections: > > 0.282095*0.282095 * PI*16/17 * 1, > 0.488603*0.488603 * PI*16/17 * 2/3, > 1.092548*1.092548 * PI*16/17 * 1/4, > 0.315392*0.315392 * PI*16/17 * 1/4, > 0.546274*0.546274 * PI*16/17 * 1/4 > > I also tried using the plain set of factors for adding (without the > squaring and the corrections), but I get even stranger results. > > Thanks in advance for any insight, > > Alen |