[Bf-blender-cvs] [f91635e64e5] soc-2018-hair-shader: Refactor Melanin into Tungsten's quantity and ratio parameters

L. E. Segovia noreply at git.blender.org
Sun Jun 17 03:12:24 CEST 2018


Commit: f91635e64e50eaa50bd911af3f93da881eacf4d0
Author: L. E. Segovia
Date:   Sun Jun 17 01:06:23 2018 +0000
Branches: soc-2018-hair-shader
https://developer.blender.org/rBf91635e64e50eaa50bd911af3f93da881eacf4d0

Refactor Melanin into Tungsten's quantity and ratio parameters

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

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/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 2c79188f2b5..f5b82a5200d 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -734,12 +734,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 			float alpha = (stack_valid(offset_ofs))? stack_load_float(stack, offset_ofs): __uint_as_float(data_node.z);
 			float ior = (stack_valid(ior_ofs))? stack_load_float(stack, ior_ofs): __uint_as_float(data_node.w);
 
-			uint primary_reflection_roughness_ofs, eumelanin_ofs, pheomelanin_ofs, absorption_coefficient_ofs;
-			decode_node_uchar4(data_node2.x, &primary_reflection_roughness_ofs, &eumelanin_ofs, &pheomelanin_ofs, &absorption_coefficient_ofs);
+			uint primary_reflection_roughness_ofs, melanin_qty_ofs, melanin_ratio_ofs, absorption_coefficient_ofs;
+			decode_node_uchar4(data_node2.x, &primary_reflection_roughness_ofs, &melanin_qty_ofs, &melanin_ratio_ofs, &absorption_coefficient_ofs);
 
 			float m0_roughness = (stack_valid(primary_reflection_roughness_ofs))? stack_load_float(stack, primary_reflection_roughness_ofs): __uint_as_float(data_node2.y);
-			float eumelanin = (stack_valid(eumelanin_ofs)) ? stack_load_float(stack, eumelanin_ofs) : __uint_as_float(data_node2.z);
-			float pheomelanin = (stack_valid(pheomelanin_ofs)) ? stack_load_float(stack, pheomelanin_ofs) : __uint_as_float(data_node2.w);
+			float melanin_qty = (stack_valid(melanin_qty_ofs)) ? stack_load_float(stack, melanin_qty_ofs) : __uint_as_float(data_node2.z);
+			float melanin_ratio = (stack_valid(melanin_ratio_ofs)) ? stack_load_float(stack, melanin_ratio_ofs) : __uint_as_float(data_node2.w);
 			
 			uint tint_ofs, random_ofs, color_randomization_ofs, roughness_randomization_ofs;
 			decode_node_uchar4(data_node3.x, &tint_ofs, &random_ofs, &color_randomization_ofs, &roughness_randomization_ofs);
@@ -760,9 +760,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 
 				param1 *= factor_random_roughness;
 				param2 *= factor_random_roughness;
+
+				float eumelanin = melanin_qty*(1.0f-melanin_ratio);
+				float pheomelanin = melanin_qty*melanin_ratio;
 				eumelanin *= factor_random_color;
 				pheomelanin *= factor_random_color;
-				
+
 				bsdf->N = N;
 				bsdf->v = param1;
 				bsdf->s = param2;
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index f4de43e1aee..f69ce974a46 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3046,8 +3046,8 @@ 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(pheomelanin, "Melanin Redness", 1.3f);
+	SOCKET_IN_FLOAT(eumelanin, "Melanin", 1.3f);
+	SOCKET_IN_FLOAT(pheomelanin, "Melanin Redness", 1.0f);
 	SOCKET_IN_COLOR(tint, "Tint", make_float3(1.f, 1.f, 1.f));
 	SOCKET_IN_FLOAT(color_randomization, "Color Randomization", 0.0f);
 	SOCKET_IN_VECTOR(absorption_coefficient, "Absorption Coefficient", make_float3(0.245531f, 0.52f, 1.365f), SocketType::VECTOR);
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 3eecd60f0dd..b7da28cf908 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,8 +31,8 @@
 
 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, 10.0f},
-	{	SOCK_FLOAT,		1, N_("Melanin Redness"),			1.3f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+	{	SOCK_FLOAT,		1, N_("Melanin"),					1.3f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+	{	SOCK_FLOAT,		1, N_("Melanin Redness"),			1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
 	{	SOCK_RGBA,		1, N_("Tint"),						1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
 	// Benedikt Bitterli's default brownish hair with PHEOmelanin
 	// The absorption coefficient below is 1.3f * pheomelanin mapping



More information about the Bf-blender-cvs mailing list