Re: [Algorithms] Cubemap to spherical harmonics (again)
Brought to you by:
vexxed72
From: Ben G. <be...@ga...> - 2006-04-22 07:00:19
|
On 4/21/06, Alen Ladavac <ale...@cr...> wrote: > 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) (Disclaimer: I am a SH newbie.) Are you sure that you're getting a properly "normalized" SH? It sounds like you might be adding too much, thus getting a huge spike of red+green=3Dyellow on one basis, which overwhelms your color range... Depending on implementation details, seems like you could test this by sampling the SH in a few directions and seeing what color values you get. Also seems likely you'll get a yellow band no matter what you do, but it can probably be minimized. -- Ben Garney Torque Technologies Director GarageGames.Com, Inc. |