[Bf-blender-cvs] [16639c6f1a3] master: Fix T63784 Eevee : Black Diffuse with Principled BSDF and Mix Shader

Clément Foucault noreply at git.blender.org
Fri Apr 26 00:14:40 CEST 2019


Commit: 16639c6f1a31da50715c720d6080b96330da1f89
Author: Clément Foucault
Date:   Fri Apr 26 00:12:06 2019 +0200
Branches: master
https://developer.blender.org/rB16639c6f1a31da50715c720d6080b96330da1f89

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.

===================================================================

M	source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl

===================================================================

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
 }



More information about the Bf-blender-cvs mailing list