I have written in blitz3D some code to generate arbitrary 2D lighting lookup textures and I'm looking for a way to compress them. The idea is that they look rather smooth and low frequency, there must be way to lower the memory cost using spherical harmonics since they represent lighting over a sphere ...
Let say I have a 2D texture (let say 512²) that is a stack of lighting ramp (look up with a half lambert). X is the NdotL ramp and Y an arbitrary index parameter given by some function.
Nodtl lighting can be represented as a symmetrical spherical harmonics known as zonal harmonics. By transferring the ramp to zonal harmonics I can compress the texture from 512x512 to 512x9(+7 free to have power of 2) ie a stack of spherical harmonics coefficients.
Now the math is way above my head, I read the stupid spherical harmonics tricks and nitty gritty details paper, but while I understand the principle, the math and the translation to code is way above my level.
The idea is that instead of going through all the slices by hand (512 per textures at least) to create custom curves fitting, having a generic "ndotl ramp to zonal harmonics" function might improve production.
What I want is how the code would look like to turn a slice (ramp) sampling into a proper zonal harmonics?
(post edited for clarification))
Optional: Since a ramp can be assimilated to a 1D lookup function, is there a better GENERIC way to represent it than zonal harmonics?
Relative to the 1D function idea ... Assuming I can get the stack of SH, since SH interpolate linearly, how can I infer a function that fit the Y variation of the SH coefficient? What's the best (free) tools to help me do that ie plotting arbitrary point from a source (ramp texture) and finding/visualizing the correct curve? I heard (and dl) python X,Y can help but it's like handling a Japanese manual written in Klingon to me ...
The idea is to make cheap generic shader by precomputing lighting (similar to unity's shadowgun) and various ndotl effect similar to penner Preintegrated skin shader, among many other ...
Optional 2: Just for curiosity, what is the state of spherical needlet basis to represent smooth lighting? (even more above my punch).