summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2024-08-21 00:30:59 -0700
committerRémi Verschelde <rverschelde@gmail.com>2024-09-17 08:57:41 +0200
commit0a1724f713ad63efb83b4db33c1eb2b4137ab288 (patch)
tree25e96cd2c91e023c0bb388fd290032d998255bd8 /servers
parente79157af726fed9be65bcbaa5577b5012508a434 (diff)
downloadredot-engine-0a1724f713ad63efb83b4db33c1eb2b4137ab288.tar.gz
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 f4ccba7508fe6fbbbda92df855ad59a63a205b17)
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl14
-rw-r--r--servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl15
2 files changed, 8 insertions, 21 deletions
diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl
index 59838f682f..eb80d1df69 100644
--- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl
@@ -1454,16 +1454,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 {
ambient_light += textureLod(sampler2DArray(lightmap_textures[ofs], SAMPLER_LINEAR_CLAMP), uvw, 0.0).rgb * lightmaps.data[ofs].exposure_normalization;
diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl
index e13c0ce827..409a71dc78 100644
--- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl
+++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl
@@ -1214,17 +1214,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;
}