Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-04-26 01:12:06 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-04-26 01:14:28 +0300
commit16639c6f1a31da50715c720d6080b96330da1f89 (patch)
tree209898b7e56aaafd034a18648a23e8d3e4438db7
parentce148c13746092bb695c06747b85fd4baa88befc (diff)
Fix T63784 Eevee : Black Diffuse with Principled BSDF and Mix Shader
This was cause by the SSS energy being lost when using SSRefraction. Also the mix shader did not merge the discarded SSS light into the radiance.
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl20
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 9ed0ab9a5d4..2edc827b7fa 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -837,9 +837,16 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
# ifdef USE_SSS
cl.sss_data.rgb = mix(cl1.sss_data.rgb, cl2.sss_data.rgb, fac);
cl.sss_data.a = (cl1.sss_data.a > 0.0) ? cl1.sss_data.a : cl2.sss_data.a;
+
# ifdef USE_SSS_ALBEDO
/* TODO Find a solution to this. Dither? */
cl.sss_albedo = (cl1.sss_data.a > 0.0) ? cl1.sss_albedo : cl2.sss_albedo;
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb * cl2.sss_albedo :
+ cl1.sss_data.rgb * cl1.sss_albedo;
+# else
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb : cl1.sss_data.rgb;
# endif
# endif
@@ -920,10 +927,19 @@ void main()
/* For Probe capture */
# ifdef USE_SSS
+ float fac = float(!sssToggle);
+
+# ifdef USE_REFRACTION
+ /* SSRefraction pass is done after the SSS pass.
+ * In order to not loose the diffuse light totally we
+ * need to merge the SSS radiance to the main radiance. */
+ fac = 1.0;
+# endif
+
# ifdef USE_SSS_ALBEDO
- fragColor.rgb += cl.sss_data.rgb * cl.sss_albedo.rgb * float(!sssToggle);
+ fragColor.rgb += cl.sss_data.rgb * cl.sss_albedo.rgb * fac;
# else
- fragColor.rgb += cl.sss_data.rgb * float(!sssToggle);
+ fragColor.rgb += cl.sss_data.rgb * fac;
# endif
# endif
}