summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-15 09:34:13 +0200
committerGitHub <noreply@github.com>2019-05-15 09:34:13 +0200
commit61b78e7f3be5121519befd2af3860e2380b3c9af (patch)
tree2198235f1dacaf29b7cc5437e3276f52f19dd32b
parent15cda53d802f5cfe00d8c2cb5263e6b45090d094 (diff)
parent55d11330b05f9b881837bb3646ebb139527e6f90 (diff)
Merge pull request #28891 from clayjohn/brdf-fix
Fix lighting bug introduced in clear color changes
-rw-r--r--drivers/gles3/shaders/scene.glsl38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 4f54fd4ac2..def924cd49 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -1814,25 +1814,6 @@ FRAGMENT_SHADER_CODE
specular_blob_intensity *= specular * 2.0;
#endif
-#ifdef USE_FORWARD_LIGHTING
-
- highp vec4 reflection_accum = vec4(0.0, 0.0, 0.0, 0.0);
- highp vec4 ambient_accum = vec4(0.0, 0.0, 0.0, 0.0);
- for (int i = 0; i < reflection_count; i++) {
- reflection_process(reflection_indices[i], vertex, normal, binormal, tangent, roughness, anisotropy, ambient_light, env_reflection_light, reflection_accum, ambient_accum);
- }
-
- if (reflection_accum.a > 0.0) {
- specular_light += reflection_accum.rgb / reflection_accum.a;
- } else {
- specular_light += env_reflection_light;
- }
-#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
- if (ambient_accum.a > 0.0) {
- ambient_light = ambient_accum.rgb / ambient_accum.a;
- }
-#endif
-
// scales the specular reflections, needs to be be computed before lighting happens,
// but after environment and reflection probes are added
// Environment brdf approximation (Lazarov 2013)
@@ -2038,6 +2019,25 @@ FRAGMENT_SHADER_CODE
}
#endif
+#ifdef USE_FORWARD_LIGHTING
+
+ highp vec4 reflection_accum = vec4(0.0, 0.0, 0.0, 0.0);
+ highp vec4 ambient_accum = vec4(0.0, 0.0, 0.0, 0.0);
+ for (int i = 0; i < reflection_count; i++) {
+ reflection_process(reflection_indices[i], vertex, normal, binormal, tangent, roughness, anisotropy, ambient_light, env_reflection_light, reflection_accum, ambient_accum);
+ }
+
+ if (reflection_accum.a > 0.0) {
+ specular_light += reflection_accum.rgb / reflection_accum.a;
+ } else {
+ specular_light += env_reflection_light;
+ }
+#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
+ if (ambient_accum.a > 0.0) {
+ ambient_light = ambient_accum.rgb / ambient_accum.a;
+ }
+#endif
+
#ifdef USE_VERTEX_LIGHTING
diffuse_light *= albedo;