[Bf-blender-cvs] [585b886] cycles_disney_brdf: added output parameter to the DisneyBsdfNode

Pascal Schoen noreply at git.blender.org
Mon May 30 09:09:00 CEST 2016


Commit: 585b88623695fa07dfca9c9909d6d9184c3519c8
Author: Pascal Schoen
Date:   Tue May 17 12:03:17 2016 +0200
Branches: cycles_disney_brdf
https://developer.blender.org/rB585b88623695fa07dfca9c9909d6d9184c3519c8

added output parameter to the DisneyBsdfNode

That has been forgotten after removing the inheritance of BsdfNode

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

M	intern/cycles/render/nodes.cpp
M	intern/cycles/render/nodes.h

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

diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 9a0a917..3fcdfe1 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -2128,10 +2128,40 @@ DisneyBsdfNode::DisneyBsdfNode()
 	add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL);
 	add_input("Tangent", SHADER_SOCKET_VECTOR, ShaderInput::TANGENT);
 	add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM);
+
+	add_output("BSDF", SHADER_SOCKET_CLOSURE);
+}
+
+void DisneyBsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3, ShaderInput *param4)
+{
+	ShaderInput *base_color_in = input("BaseColor");
+	ShaderInput *normal_in = input("Normal");
+	ShaderInput *tangent_in = input("Tangent");
+
+	if (base_color_in->link)
+		compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(base_color_in));
+	else
+		compiler.add_node(NODE_CLOSURE_SET_WEIGHT, base_color_in->value);
+
+	int normal_offset = compiler.stack_assign_if_linked(normal_in);
+	int tangent_offset = (tangent_in) ? compiler.stack_assign_if_linked(tangent_in) : SVM_STACK_INVALID;
+	int param3_offset = (param3) ? compiler.stack_assign(param3) : SVM_STACK_INVALID;
+	int param4_offset = (param4) ? compiler.stack_assign(param4) : SVM_STACK_INVALID;
+
+	compiler.add_node(NODE_CLOSURE_BSDF,
+		compiler.encode_uchar4(closure,
+		(param1) ? compiler.stack_assign(param1) : SVM_STACK_INVALID,
+		(param2) ? compiler.stack_assign(param2) : SVM_STACK_INVALID,
+		compiler.closure_mix_weight_offset()),
+		__float_as_int((param1) ? param1->value.x : 0.0f),
+		__float_as_int((param2) ? param2->value.x : 0.0f));
+
+	compiler.add_node(normal_offset, tangent_offset, param3_offset, param4_offset);
 }
 
 void DisneyBsdfNode::compile(SVMCompiler& compiler)
 {
+	compile(compiler, NULL, NULL);
 }
 
 void DisneyBsdfNode::compile(OSLCompiler& compiler)
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 4dbffa2..57c0b92 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -420,6 +420,7 @@ public:
 	SHADER_NODE_CLASS(DisneyBsdfNode)
 
 	bool has_spatial_varying() { return true; }
+	void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL, ShaderInput *param4 = NULL);
 
 	ClosureType closure;




More information about the Bf-blender-cvs mailing list