From 7cbc7dd90499f98e3f44f86fdacae5365e53cd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 24 Nov 2017 22:29:18 +0100 Subject: Eevee: SSS: Add separated Albedo option. This option prevent from automatically blurring the albedo color applied to the SSS. While this is great for preserving details it can bleed more light onto the nearby objects since the blurring will be done on pure "white" irradiance. This issue is to be tackled in a separate commit. --- source/blender/gpu/shaders/gpu_shader_material.glsl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index b23c1708ee1..9d22fbba65e 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2909,7 +2909,12 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subs result.ssr_id = int(ssr_id); #ifdef USE_SSS result.sss_data.a = sss_scalef; - result.sss_data.rgb = (out_diff + out_trans) * mix(vec3(0.0), subsurface_color.rgb, subsurface); + result.sss_data.rgb = out_diff + out_trans; +#ifdef USE_SSS_ALBEDO + result.sss_albedo.rgb = mix(vec3(0.0), subsurface_color.rgb, subsurface); +#else + result.sss_data.rgb *= mix(vec3(0.0), subsurface_color.rgb, subsurface); +#endif result.sss_data.rgb *= (1.0 - transmission); #endif @@ -2954,7 +2959,14 @@ void node_subsurface_scattering( result.ssr_id = -1; result.sss_data.a = scale; eevee_closure_subsurface(N, color.rgb, 1.0, scale, out_diff, out_trans); - result.sss_data.rgb = (out_diff + out_trans) * color.rgb; + result.sss_data.rgb = out_diff + out_trans; +#ifdef USE_SSS_ALBEDO + /* Not perfect for texture_blur not exaclty equal to 0.0 or 1.0. */ + result.sss_albedo.rgb = mix(color.rgb, vec3(1.0), texture_blur); + result.sss_data.rgb *= mix(vec3(1.0), color.rgb, texture_blur); +#else + result.sss_data.rgb *= color.rgb; +#endif #else node_bsdf_diffuse(color, 0.0, N, result); #endif -- cgit v1.2.3