In the next week or so, I'm going to start implementing Baked GI for my custom engine. I'm not too familiar with Spherical Harmonics(SH), but I'm planning on doing some more research to understand the math behind applying SH to GI.
For Baked GI my plan is:
- Offline, for each light probe in the scene
- Render a Cube Map of the scene at the probes location.
- Calculate the Spherical Harmonics at that given point using the method explained here: https://cseweb.ucsd.edu/~ravir/papers/envmap/envmap.pdf
- Move the SH coefficients to the CPU and save them to a file.
- At run-time, I linearly interpolate the SH coefficients for an object on the CPU.
- Finally, I feed the SH coefficients to the GPU for each object. (This is done when I am creating the GBuffer.)
Questions:
- Is this a viable method to Bake GI and use it at run-time? I've looked through some old posts on this forum and this is what I could piece meal together; but I maybe completely missing the ball.
- How do I interpolate between the SH coefficients (this is kind of a multi-part question):
- In Unity, it appears that they find the smallest fitting simplex of light probes that contains the center of the object.
- How do I find that smallest fitting simplex?
- Once I find probes to interpolate between, can I just use bilinear/trilinear interpolation on each of the coefficients?
- Is there a way to defer applying the SH coefficients?
I'm currently only looking at Baking GI as most of the Dynamic GI that I've researched is out of my breadth at the moment.
Thanks for reading all that!