1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-23 15:16:17 +00:00

Merge pull request #95888 from clayjohn/Lightmap-SH-coefficients

Use correct lightmap coefficients to ensure that the directional lightmap mode looks correct
This commit is contained in:
Rémi Verschelde
2024-08-25 20:18:18 +02:00
6 changed files with 48 additions and 44 deletions

View File

@@ -1532,16 +1532,10 @@ void fragment_shader(in SceneData scene_data) {
vec3 n = normalize(lightmaps.data[ofs].normal_xform * normal);
float en = lightmaps.data[ofs].exposure_normalization;
ambient_light += lm_light_l0 * 0.282095f * en;
ambient_light += lm_light_l1n1 * 0.32573 * n.y * en;
ambient_light += lm_light_l1_0 * 0.32573 * n.z * en;
ambient_light += lm_light_l1p1 * 0.32573 * n.x * en;
if (metallic > 0.01) { // since the more direct bounced light is lost, we can kind of fake it with this trick
vec3 r = reflect(normalize(-vertex), normal);
specular_light += lm_light_l1n1 * 0.32573 * r.y * en;
specular_light += lm_light_l1_0 * 0.32573 * r.z * en;
specular_light += lm_light_l1p1 * 0.32573 * r.x * en;
}
ambient_light += lm_light_l0 * en;
ambient_light += lm_light_l1n1 * n.y * en;
ambient_light += lm_light_l1_0 * n.z * en;
ambient_light += lm_light_l1p1 * n.x * en;
} else {
if (sc_use_lightmap_bicubic_filter) {