| 30 | /////////////////////////////////////////// |
| 31 | |
| 32 | spherical_harmonics_t sh_create(const sh_light_t* lights, int32_t light_count) { |
| 33 | spherical_harmonics_t result = {}; |
| 34 | for (int32_t i = 0; i < light_count; i++) { |
| 35 | sh_add(result, vec3_normalize(lights[i].dir_to), { lights[i].color.r, lights[i].color.g, lights[i].color.b }); |
| 36 | } |
| 37 | for (int32_t i = 0; i < 9; i++) { |
| 38 | result.coefficients[i] /= (float)light_count; |
| 39 | } |
| 40 | |
| 41 | // Apply windowing to prevent overshooting |
| 42 | sh_windowing(result, .01f); |
| 43 | |
| 44 | return result; |
| 45 | } |
| 46 | |
| 47 | /////////////////////////////////////////// |
| 48 |
nothing calls this directly
no test coverage detected