3
$\begingroup$

My question is about spherical harmonic lightning, in the context of computing the coefficients with an expensive GI algorithm and passing them to the vertex shader

Another way is to just use an expensive GI algorithm to compute vertex colors and just use them instead.

What is the advantage of using the former method? I'm thinking that you can't do reflections with the latter method, and also there's rotational symmetry in SH (i don't know much about) that allows you to do some very simple dynamics with your lights and meshes. Is there any more points i'm missing?

$\endgroup$

1 Answer 1

3
$\begingroup$

Spherical harmonics are generally used for dynamic objects in your scene, while fully-baked lighting is used for static objects.

A typical game engine will use both. During the GI pass, all surfaces marked as static will have their global lighting fully baked - generally into a lightmap texture rather than per-vertex. At the same time, a bunch of light probes distributed throughout your scene will receive omnidirectional lighting, and this gets converted into SH. Since SH coefficients interpolate nicely, a mesh moving through your scene can pick up the nearest few light probes (generally 4), and use the weighted average to decode a good approximation of the ambient lighting at its current location.

Another use for SH is to render less-important dynamic lights in a scene with many lights in it. The most important light or two can be rendered fully dynamically per-pixel, then for each renderer, the SH coefficients of the less-important lights are calculated and added to the light probe data. This allows the lights to change in real-time, and be rendered effectively for free per-vertex in the shader, with a small CPU overhead.

$\endgroup$
2
  • 1
    $\begingroup$ I would also add that SH (or the related H-basis) is useful for normal maps on static objects. A bumpy surface will reflect light from different directions, so you want a directional representation of incoming light at the surface. $\endgroup$ Jan 23, 2018 at 18:26
  • $\begingroup$ Thanks for the link, I hadn't heard of that basis before. Just been reading about spherical Gaussians which can apparently fake rough specular as well, but the math is pretty gnarly! $\endgroup$
    – russ
    Jan 23, 2018 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.