[Algorithms] Cubemap to spherical harmonics (again)
Brought to you by:
vexxed72
From: Alen L. <ale...@cr...> - 2006-04-21 16:10:13
|
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 = 1/(PI*16/17) pixelarea = 4/(sizeU*sizeV) for each face on the cube for each pixel on the face vdir = position on cube (domain is (-1,+1)^3) r = len(vdir); vdir /= r; da = pixelarea*r^(-3/2) rgb = sample the pixel value rgb *= 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 |