diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-09 01:10:15 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-09 01:10:29 +0300 |
commit | 1a99b6fc7e8e2d670bc5ceed23ecc84020a10555 (patch) | |
tree | 91ad7c9b238dc1400317ef2c29e372339174d7f6 /source/blender/draw/engines/eevee/shaders | |
parent | 558017d6a644282cad31441867c4d96f8cb76eb4 (diff) |
Fix T64158 Eevee: Mixed SSS shader becomes brighter and brighter
This change the logic a bit, when 2 bsdfs using SSS are mixed, we use the
one with the biggest radius (on a per pixel basis).
This change from previous behavior which was to select input 1 if radius
was greater than 0.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | 16 |
1 files changed, 10 insertions, 6 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 e2ce122493b..12e60f0250f 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -836,18 +836,22 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac) cl.radiance /= max(1e-8, cl.opacity); # 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; + /* Apply Mix on input */ + cl1.sss_data.rgb *= 1.0 - fac; + cl2.sss_data.rgb *= fac; + + /* Select biggest radius. */ + bool use_cl1 = (cl1.sss_data.a > cl2.sss_data.a); + cl.sss_data = (use_cl1) ? cl1.sss_data : cl2.sss_data; # 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; + cl.sss_albedo = (use_cl1) ? 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; + cl.radiance += (use_cl1) ? 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; + cl.radiance += (use_cl1) ? cl2.sss_data.rgb : cl1.sss_data.rgb; # endif # endif |