[Bf-blender-cvs] [c91d2d30dfc] master: Improve backscatter color of subsurface scattering in Principled BSDF

Pascal Schoen noreply at git.blender.org
Wed May 31 07:30:54 CEST 2017


Commit: c91d2d30dfc1000f9cdffa9a49eb29b43458d39a
Author: Pascal Schoen
Date:   Wed May 31 07:29:17 2017 +0200
Branches: master
https://developer.blender.org/rBc91d2d30dfc1000f9cdffa9a49eb29b43458d39a

Improve backscatter color of subsurface scattering in Principled BSDF

Differential Revision: https://developer.blender.org/D2685

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

M	intern/cycles/kernel/osl/osl_bssrdf.cpp
M	intern/cycles/kernel/shaders/node_principled_bsdf.osl
M	intern/cycles/kernel/svm/svm_closure.h

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

diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp
index 188c3960a5f..27a96720c1e 100644
--- a/intern/cycles/kernel/osl/osl_bssrdf.cpp
+++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp
@@ -191,7 +191,7 @@ class PrincipledBSSRDFClosure : public CBSSRDFClosure {
 public:
 	void setup(ShaderData *sd, int path_flag, float3 weight)
 	{
-		alloc(sd, path_flag, weight * albedo, CLOSURE_BSSRDF_PRINCIPLED_ID);
+		alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID);
 	}
 };
 
diff --git a/intern/cycles/kernel/shaders/node_principled_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
index 57f40789d49..9d85d56ba78 100644
--- a/intern/cycles/kernel/shaders/node_principled_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
@@ -57,8 +57,8 @@ shader node_principled_bsdf(
 
 	if (diffuse_weight > 1e-5) {
 		if (Subsurface > 1e-5) {
-			color Albedo = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
-			BSDF = bssrdf_principled(Normal, Subsurface * SubsurfaceRadius, 0.0, Albedo, Roughness);
+			color mixed_ss_base_color = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
+			BSDF = mixed_ss_base_color * bssrdf_principled(Normal, Subsurface * SubsurfaceRadius, 0.0, SubsurfaceColor, Roughness);
 		} else {
 			BSDF = BaseColor * principled_diffuse(Normal, Roughness);
 		}
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index f04f765686e..f3bbd7a7dac 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -141,8 +141,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 			float3 weight = sd->svm_closure_weight * mix_weight;
 
 #ifdef __SUBSURFACE__
-			float3 albedo = subsurface_color * subsurface + base_color * (1.0f - subsurface);
-			float3 subsurf_weight = weight * albedo * diffuse_weight;
+			float3 mixed_ss_base_color = subsurface_color * subsurface + base_color * (1.0f - subsurface);
+			float3 subsurf_weight = weight * mixed_ss_base_color * diffuse_weight;
 			float subsurf_sample_weight = fabsf(average(subsurf_weight));
 
 			/* disable in case of diffuse ancestor, can't see it well then and
@@ -154,7 +154,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 				/* need to set the base color in this case such that the
 				 * rays get the correctly mixed color after transmitting
 				 * the object */
-				base_color = albedo;
+				base_color = mixed_ss_base_color;
 			}
 
 			/* diffuse */
@@ -186,7 +186,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 						bssrdf->sample_weight = subsurf_sample_weight;
 						bssrdf->radius = radius.x;
 						bssrdf->texture_blur = texture_blur;
-						bssrdf->albedo = albedo.x;
+						bssrdf->albedo = subsurface_color.x;
 						bssrdf->sharpness = sharpness;
 						bssrdf->N = N;
 						bssrdf->roughness = roughness;
@@ -200,7 +200,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 						bssrdf->sample_weight = subsurf_sample_weight;
 						bssrdf->radius = radius.y;
 						bssrdf->texture_blur = texture_blur;
-						bssrdf->albedo = albedo.y;
+						bssrdf->albedo = subsurface_color.y;
 						bssrdf->sharpness = sharpness;
 						bssrdf->N = N;
 						bssrdf->roughness = roughness;
@@ -214,7 +214,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 						bssrdf->sample_weight = subsurf_sample_weight;
 						bssrdf->radius = radius.z;
 						bssrdf->texture_blur = texture_blur;
-						bssrdf->albedo = albedo.z;
+						bssrdf->albedo = subsurface_color.z;
 						bssrdf->sharpness = sharpness;
 						bssrdf->N = N;
 						bssrdf->roughness = roughness;




More information about the Bf-blender-cvs mailing list