Use correct lightmap coefficients to ensure that the directional lightmap mode looks correct

Also remove the metallic option from directional lightmap as it is guaranteed to return negative numbers in many cases

(cherry picked from commit f4ccba7508)
This commit is contained in:
clayjohn
2024-08-21 00:30:59 -07:00
committed by Rémi Verschelde
parent e79157af72
commit 0a1724f713
6 changed files with 48 additions and 44 deletions

View File

@@ -1738,16 +1738,10 @@ void main() {
vec3 n = normalize(lightmap_normal_xform * normal);
ambient_light += lm_light_l0 * 0.282095f;
ambient_light += lm_light_l1n1 * 0.32573 * n.y * lightmap_exposure_normalization;
ambient_light += lm_light_l1_0 * 0.32573 * n.z * lightmap_exposure_normalization;
ambient_light += lm_light_l1p1 * 0.32573 * n.x * lightmap_exposure_normalization;
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 * lightmap_exposure_normalization;
specular_light += lm_light_l1_0 * 0.32573 * r.z * lightmap_exposure_normalization;
specular_light += lm_light_l1p1 * 0.32573 * r.x * lightmap_exposure_normalization;
}
ambient_light += lm_light_l0 * lightmap_exposure_normalization;
ambient_light += lm_light_l1n1 * n.y * lightmap_exposure_normalization;
ambient_light += lm_light_l1_0 * n.z * lightmap_exposure_normalization;
ambient_light += lm_light_l1p1 * n.x * lightmap_exposure_normalization;
#else
ambient_light += textureLod(lightmap_textures, uvw, 0.0).rgb * lightmap_exposure_normalization;
#endif