You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
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
This commit is contained in:
@@ -1210,17 +1210,10 @@ void main() {
|
||||
vec3 n = normalize(lightmaps.data[ofs].normal_xform * normal);
|
||||
float exposure_normalization = lightmaps.data[ofs].exposure_normalization;
|
||||
|
||||
ambient_light += lm_light_l0 * 0.282095f;
|
||||
ambient_light += lm_light_l1n1 * 0.32573 * n.y * exposure_normalization;
|
||||
ambient_light += lm_light_l1_0 * 0.32573 * n.z * exposure_normalization;
|
||||
ambient_light += lm_light_l1p1 * 0.32573 * n.x * 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 * exposure_normalization;
|
||||
specular_light += lm_light_l1_0 * 0.32573 * r.z * exposure_normalization;
|
||||
specular_light += lm_light_l1p1 * 0.32573 * r.x * exposure_normalization;
|
||||
}
|
||||
|
||||
ambient_light += lm_light_l0 * exposure_normalization;
|
||||
ambient_light += lm_light_l1n1 * n.y * exposure_normalization;
|
||||
ambient_light += lm_light_l1_0 * n.z * exposure_normalization;
|
||||
ambient_light += lm_light_l1p1 * n.x * exposure_normalization;
|
||||
} else {
|
||||
ambient_light += textureLod(sampler2DArray(lightmap_textures[ofs], SAMPLER_LINEAR_CLAMP), uvw, 0.0).rgb * lightmaps.data[ofs].exposure_normalization;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user