[Bf-blender-cvs] [b891aa81094] soc-2018-hair-shader: Use Benedikt Bitterli's and PBRT's sane defaults

L. E. Segovia noreply at git.blender.org
Mon Jun 4 22:51:04 CEST 2018


Commit: b891aa81094707c36504b28b40ace7996401be3c
Author: L. E. Segovia
Date:   Mon Jun 4 20:50:42 2018 +0000
Branches: soc-2018-hair-shader
https://developer.blender.org/rBb891aa81094707c36504b28b40ace7996401be3c

Use Benedikt Bitterli's and PBRT's sane defaults

This should give brownish hair, implemented with pheomelanin.

Defaults:
 - Color: Blender's default gray
 - Melanin: Eumelanin 0, Pheomelanin 1.3
 - Absorption coefficient: 1.3*d'Eon's pheomelanin mapping (brown hair)
 - Offset: 2º
 - Roughness: 0.3 in both directions
 - Primary Reflection Roughness: 1.0 (fully enabled)
 - IOR: 1.55

Ref T54796

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

M	intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
M	intern/cycles/kernel/svm/svm_closure.h
M	intern/cycles/render/nodes.cpp
M	source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c

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

diff --git a/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
index 6831c6e3d2a..17bb43b22a6 100644
--- a/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
@@ -22,14 +22,14 @@ color log3 (color a) {
 
 shader node_principled_hair_bsdf(
 	color Color = 0.8,
-	float Melanin = 0.0,
+	float Melanin = 1.3,
 	float MelaninRedness = 0.0,
-	color AbsorptionCoefficient = 0.0,
+	color AbsorptionCoefficient = color(0.245531, 0.52, 1.365),
 	normal Normal = Ng,
 	string parametrization = "Absorption coefficient",
-	float Offset = 0,
-	float RoughnessU = 0.2,
-	float RoughnessV = 0.2,
+	float Offset = radians(2),
+	float RoughnessU = 0.3,
+	float RoughnessV = 0.3,
 	float PrimaryReflectionRoughness = 1.0,
 	float IOR = 1.55,
 
@@ -46,11 +46,16 @@ shader node_principled_hair_bsdf(
 	else if (parametrization == "Melanin concentration") {
 		Sigma = Melanin*color(0.419, 0.697, 1.37) + MelaninRedness*color(0.187, 0.4, 1.05);
 	}
-	else {
+	else if (parametrization == "Direct coloring"){
 		float roughness_fac = (((((0.245*RoughnessU) + 5.574)*RoughnessU - 10.73)*RoughnessU + 2.532)*RoughnessU - 0.215)*RoughnessU + 5.969;
 		Sigma = log3(Color)/roughness_fac;
 		Sigma *= Sigma;
 	}
+	else {
+		// Falling back to Benedikt Bitterli's brownish hair with Tungsten (via PHEOmelanin concentration)
+		// This gives the exact amount set as default above
+		Sigma = 0.0*color(0.419, 0.697, 1.37) + 1.3*color(0.187, 0.4, 1.05);
+	}
 
 	//printf("Info: color %f, incoming eumelanin %f, incoming pheomelanin %f, incoming sigma %f, incoming normal %f, parametrization %s, resulting sigma %f, Longitudinal %f, Azimuthal %f, Scale deviation %f, IOR %f\n", Color, Melanin, MelaninRedness, AbsorptionCoefficient, Normal, parametrization, Sigma, RoughnessU, RoughnessV, Offset, IOR);
 
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 7da0b3bee26..bf7b96bc7e7 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -767,15 +767,18 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 					case NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION:
 						bsdf->sigma = eumelanin*make_float3(0.419f, 0.697f, 1.37f) + pheomelanin*make_float3(0.187f, 0.4f, 1.05f);
 						break;
-					default:
-						kernel_assert(!"Invalid Principled Hair parametrization!");
-						//fallthrough
 					case NODE_PRINCIPLED_HAIR_REFLECTANCE: {
 						float roughness_fac = (((((0.245f*param2) + 5.574f)*param2 - 10.73f)*param2 + 2.532f)*param2 - 0.215f)*param2 + 5.969f;
 						bsdf->sigma = log3(color)/roughness_fac;
 						bsdf->sigma *= bsdf->sigma;
 						break;
 					}
+					default: {
+						kernel_assert(!"Invalid Principled Hair parametrization!");
+						// Falling back to Benedikt Bitterli's brownish hair with Tungsten (via PHEOmelanin concentration)
+						bsdf->sigma = 0.0f*make_float3(0.419f, 0.697f, 1.37f) + 1.3f*make_float3(0.187f, 0.4f, 1.05f);
+						break;
+					}
 				}
 
 				sd->flag |= bsdf_principled_hair_setup(sd, bsdf);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 2dff177e7d4..25141bea38d 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3043,9 +3043,9 @@ NODE_DEFINE(PrincipledHairBsdfNode)
 	NodeType* type = NodeType::add("principled_hair_bsdf", create, NodeType::SHADER);
 
 	SOCKET_IN_COLOR(color, "Color", make_float3(0.8f, 0.8f, 0.8f));
-	SOCKET_IN_FLOAT(eumelanin, "Melanin", 0.0f);
+	SOCKET_IN_FLOAT(eumelanin, "Melanin", 1.3f);
 	SOCKET_IN_FLOAT(pheomelanin, "Melanin Redness", 0.0f);
-	SOCKET_IN_VECTOR(absorption_coefficient, "Absorption Coefficient", make_float3(0.0f, 0.0f, 0.0f), SocketType::VECTOR);
+	SOCKET_IN_VECTOR(absorption_coefficient, "Absorption Coefficient", 1.3f*make_float3(0.187f, 0.4f, 1.05f), SocketType::VECTOR);
 	SOCKET_IN_NORMAL(normal, "Normal", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL);
 	SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL);
 
@@ -3056,9 +3056,9 @@ NODE_DEFINE(PrincipledHairBsdfNode)
 	parametrization_enum.insert("Melanin concentration", NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION);
 	SOCKET_ENUM(parametrization, "Parametrization", parametrization_enum, NODE_PRINCIPLED_HAIR_REFLECTANCE);
 
-	SOCKET_IN_FLOAT(offset, "Offset", 0.0f);
-	SOCKET_IN_FLOAT(roughness_u, "RoughnessU", 0.2f);
-	SOCKET_IN_FLOAT(roughness_v, "RoughnessV", 0.2f);
+	SOCKET_IN_FLOAT(offset, "Offset", 2.f*M_PI/180.f);
+	SOCKET_IN_FLOAT(roughness_u, "RoughnessU", 0.3f);
+	SOCKET_IN_FLOAT(roughness_v, "RoughnessV", 0.3f);
 	SOCKET_IN_FLOAT(primary_reflection_roughness, "Primary Reflection Roughness", 1.0f);
 	SOCKET_IN_FLOAT(ior, "IOR", 1.55f);
 
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
index 8821326c90c..be3c67a5d26 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
@@ -31,12 +31,14 @@
 
 static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = {
 	{	SOCK_RGBA,   1, N_("Color"),						0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
-	{	SOCK_FLOAT,  1, N_("Melanin"),						0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f, PROP_FACTOR},
-	{	SOCK_FLOAT,  1, N_("Melanin Redness"),				0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f, PROP_FACTOR},
-	{	SOCK_VECTOR, 1, N_("Absorption Coefficient"),		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f, PROP_FACTOR},
-	{	SOCK_FLOAT,  1, N_("Offset"),						0.0f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE},
-	{	SOCK_FLOAT,  1, N_("RoughnessU"),					0.2f, 0.2f, 0.2f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
-	{	SOCK_FLOAT,  1, N_("RoughnessV"),					0.2f, 0.2f, 0.2f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+	{	SOCK_FLOAT,  1, N_("Melanin"),						1.3f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+	{	SOCK_FLOAT,  1, N_("Melanin Redness"),				0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+	// Benedikt Bitterli's default brownish hair with PHEOmelanin
+	// The absorption coefficient below is 1.3f * pheomelanin mapping
+	{	SOCK_VECTOR, 1, N_("Absorption Coefficient"),		0.245531f, 0.52f, 1.365f, 0.0f, 0.0f, 1000.0f},
+	{	SOCK_FLOAT,  1, N_("Offset"),						2.f*M_PI/180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE},
+	{	SOCK_FLOAT,  1, N_("RoughnessU"),					0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+	{	SOCK_FLOAT,  1, N_("RoughnessV"),					0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
 	{	SOCK_FLOAT,  1, N_("Primary Reflection Roughness"),	1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
 	{	SOCK_FLOAT,  1, N_("IOR"),							1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
 	{	-1, 0, ""	},



More information about the Bf-blender-cvs mailing list