[Bf-blender-cvs] [013f4a152a3] cycles_disney_brdf: Switched from multiplication of base and subsurface color to blending between them using the subsurface parameter.

Schoen noreply at git.blender.org
Mon Apr 3 08:48:11 CEST 2017


Commit: 013f4a152a3898946ba5c616141c6e44d928ccfd
Author: Schoen
Date:   Thu Mar 30 15:32:55 2017 +0200
Branches: cycles_disney_brdf
https://developer.blender.org/rB013f4a152a3898946ba5c616141c6e44d928ccfd

Switched from multiplication of base and subsurface color to blending
between them using the subsurface parameter.

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

M	intern/cycles/kernel/closure/bssrdf.h
M	intern/cycles/kernel/kernel_subsurface.h
M	intern/cycles/kernel/osl/osl_bssrdf.cpp
M	intern/cycles/kernel/shaders/node_principled_bsdf.osl
M	intern/cycles/kernel/shaders/stdosl.h
M	intern/cycles/kernel/svm/svm_closure.h

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

diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index 92f983049e4..8363cef53c8 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -29,7 +29,6 @@ typedef ccl_addr_space struct Bssrdf {
 	float albedo;
 	float roughness;
 	float3 N;
-	float3 base_color;
 } Bssrdf;
 
 /* Planar Truncated Gaussian
@@ -366,7 +365,7 @@ ccl_device int bssrdf_setup(Bssrdf *bssrdf, ClosureType type)
 		if(type == CLOSURE_BSSRDF_PRINCIPLED_ID) {
 			float roughness = bssrdf->roughness;
 			float3 N = bssrdf->N;
-			float3 weight = bssrdf->weight * bssrdf->base_color;
+			float3 weight = bssrdf->weight;
 			float sample_weight = bssrdf->sample_weight;
 
 			PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf*)bssrdf;
diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h
index 9f7103c7675..c5652ebf7dc 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -150,7 +150,7 @@ ccl_device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, ShaderClos
 	if(hit) {
 		Bssrdf *bssrdf = (Bssrdf *)sc;
 		if(bssrdf->type == CLOSURE_BSSRDF_PRINCIPLED_ID) {
-			PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf*)bsdf_alloc(sd, sizeof(PrincipledDiffuseBsdf), weight * bssrdf->base_color);
+			PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf*)bsdf_alloc(sd, sizeof(PrincipledDiffuseBsdf), weight);
 
 			if(bsdf) {
 				bsdf->N = N;
diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp
index 69221a8d864..44daefee249 100644
--- a/intern/cycles/kernel/osl/osl_bssrdf.cpp
+++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp
@@ -80,7 +80,6 @@ public:
 				bssrdf->albedo = albedo.x;
 				bssrdf->sharpness = sharpness;
 				bssrdf->N = params.N;
-				bssrdf->base_color = params.base_color;
 				bssrdf->roughness = params.roughness;
 				ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
 			}
@@ -93,7 +92,6 @@ public:
 				bssrdf->albedo = albedo.y;
 				bssrdf->sharpness = sharpness;
 				bssrdf->N = params.N;
-				bssrdf->base_color = params.base_color;
 				bssrdf->roughness = params.roughness;
 				ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
 			}
@@ -106,7 +104,6 @@ public:
 				bssrdf->albedo = albedo.z;
 				bssrdf->sharpness = sharpness;
 				bssrdf->N = params.N;
-				bssrdf->base_color = params.base_color;
 				bssrdf->roughness = params.roughness;
 				ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
 			}
@@ -194,7 +191,7 @@ class PrincipledBSSRDFClosure : public CBSSRDFClosure {
 public:
 	void setup(ShaderData *sd, int path_flag, float3 weight)
 	{
-		alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID);
+		alloc(sd, path_flag, weight * albedo, CLOSURE_BSSRDF_PRINCIPLED_ID);
 	}
 };
 
@@ -204,7 +201,6 @@ ClosureParam *closure_bssrdf_principled_params()
 		CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, params.N),
 		CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, radius),
 		CLOSURE_FLOAT_PARAM(PrincipledBSSRDFClosure, params.texture_blur),
-		CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, params.base_color),
 		CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, albedo),
 		CLOSURE_FLOAT_PARAM(PrincipledBSSRDFClosure, params.roughness),
 		CLOSURE_STRING_KEYPARAM(PrincipledBSSRDFClosure, label, "label"),
diff --git a/intern/cycles/kernel/shaders/node_principled_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
index e4ba8b74beb..dd8e572ea0c 100644
--- a/intern/cycles/kernel/shaders/node_principled_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
@@ -57,7 +57,8 @@ shader node_principled_bsdf(
 
 	if (diffuse_weight > 1e-5) {
 		if (Subsurface > 1e-5) {
-			BSDF = bssrdf_principled(Normal, Subsurface * SubsurfaceRadius, 0.0, BaseColor, SubsurfaceColor, Roughness);
+			color Albedo = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
+			BSDF = bssrdf_principled(Normal, Subsurface * SubsurfaceRadius, 0.0, Albedo, Roughness);
 		} else {
 			BSDF = BaseColor * principled_diffuse(Normal, Roughness);
 		}
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h
index 076709e0965..289d1091b0a 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -552,7 +552,7 @@ closure color principled_clearcoat(normal N, float clearcoat, float clearcoat_gl
 closure color bssrdf_cubic(normal N, vector radius, float texture_blur, float sharpness) BUILTIN;
 closure color bssrdf_gaussian(normal N, vector radius, float texture_blur) BUILTIN;
 closure color bssrdf_burley(normal N, vector radius, float texture_blur, color albedo) BUILTIN;
-closure color bssrdf_principled(normal N, vector radius, float texture_blur, color base_color, color subsurface_color, float roughness) BUILTIN;
+closure color bssrdf_principled(normal N, vector radius, float texture_blur, color subsurface_color, float roughness) BUILTIN;
 
 // Hair
 closure color hair_reflection(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 7b8cbbf1536..024d7d6447a 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -140,8 +140,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 			float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
 
 #ifdef __SUBSURFACE__
-			float3 albedo = subsurface_color;
-			float3 subsurf_weight = weight * diffuse_weight;
+			float3 albedo = subsurface_color * subsurface + base_color * (1.0f - subsurface);
+			float3 subsurf_weight = weight * albedo * diffuse_weight;
 			float subsurf_sample_weight = fabsf(average(subsurf_weight));
 
 			/* disable in case of diffuse ancestor, can't see it well then and
@@ -183,7 +183,6 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 						bssrdf->albedo = albedo.x;
 						bssrdf->sharpness = sharpness;
 						bssrdf->N = N;
-						bssrdf->base_color = base_color;
 						bssrdf->roughness = roughness;
 
 						/* setup bsdf */
@@ -198,7 +197,6 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 						bssrdf->albedo = albedo.y;
 						bssrdf->sharpness = sharpness;
 						bssrdf->N = N;
-						bssrdf->base_color = base_color;
 						bssrdf->roughness = roughness;
 
 						/* setup bsdf */
@@ -213,7 +211,6 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 						bssrdf->albedo = albedo.z;
 						bssrdf->sharpness = sharpness;
 						bssrdf->N = N;
-						bssrdf->base_color = base_color;
 						bssrdf->roughness = roughness;
 
 						/* setup bsdf */




More information about the Bf-blender-cvs mailing list