Skip to content

Conversation

@BlueCube3310
Copy link
Contributor

Improves the spherical harmonics evaluation code based on https://github.com/kayru/Probulator/blob/master/Source/Probulator/SphericalHarmonics.h and https://cseweb.ucsd.edu/~ravir/papers/envmap/envmap.pdf .

As a result, the coefficients in the diffuse evaluation process more closely resemble the ones from the lightmapper, making the code slightly easier to comprehend.
Additionally, the magic numbers resulting from the convolution of directional SH are documented as equations.

Resulting numbers comparison:

SH coeff Old Old (calculated) New New (calculated)
0 0.886227 0.886227 0.886227 0.886227
1 0.511664 * 2.0 * y 1.023328 * y 1.023327 * y 1.023327 * y
2 0.511664 * 2.0 * z 1.023328 * z 1.023327 * z 1.023327 * z
3 0.511664 * 2.0 * x 1.023328 * x 1.023327 * x 1.023327 * x
4 0.429043 * 2.0 * x*y 0.858086 * x*y 0.858086 * x*y 0.858086 * x*y
5 0.429043 * 2.0 * y*z 0.858086 * y*z 0.858086 * y*z 0.858086 * y*z
6 0.743125 * z*z - 0.247708 0.743125 * z*z - 0.247708 0.247708 * (3.0 * z*z - 1.0) 0.743124 * z*z - 0.247708
7 0.429043 * 2.0 * x*z 0.858086 * x*z 0.858086 * x*z 0.858086 * x*z
8 0.429043 * (xx - yy) 0.429043 * (xx - yy) 0.429043 * (xx - yy) 0.429043 * (xx - yy)

@clayjohn clayjohn modified the milestones: 4.x, 4.5 Apr 19, 2025
@Repiteo Repiteo merged commit 2a96e89 into godotengine:master Apr 21, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Apr 21, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants