[Bf-blender-cvs] [b6da2a6a86f] master: Cycles: Make it a generic base class for all types of closure nodes

Sergey Sharybin noreply at git.blender.org
Fri Apr 21 14:50:24 CEST 2017


Commit: b6da2a6a86fb948f11f9147c5ed722a064673e6d
Author: Sergey Sharybin
Date:   Fri Apr 21 12:50:04 2017 +0200
Branches: master
https://developer.blender.org/rBb6da2a6a86fb948f11f9147c5ed722a064673e6d

Cycles: Make it a generic base class for all types of closure nodes

The idea is to have osme geenric BSDF node which is subclassed by
"regular" BSDF nodes and uber shaders.

This way we can access special type and closure type for making
decisions somewhere else.

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

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 3f56690d0c1..f9679d52235 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1791,12 +1791,19 @@ void ConvertNode::compile(OSLCompiler& compiler)
 		assert(0);
 }
 
+/* Base type for all closure-type nodes */
+
+BsdfBaseNode::BsdfBaseNode(const NodeType *node_type)
+        : ShaderNode(node_type)
+{
+	special_type = SHADER_SPECIAL_TYPE_CLOSURE;
+}
+
 /* BSDF Closure */
 
 BsdfNode::BsdfNode(const NodeType *node_type)
-: ShaderNode(node_type)
+: BsdfBaseNode(node_type)
 {
-	special_type = SHADER_SPECIAL_TYPE_CLOSURE;
 }
 
 void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3, ShaderInput *param4)
@@ -2323,9 +2330,8 @@ NODE_DEFINE(PrincipledBsdfNode)
 }
 
 PrincipledBsdfNode::PrincipledBsdfNode()
-	: ShaderNode(node_type)
+	: BsdfBaseNode(node_type)
 {
-	special_type = SHADER_SPECIAL_TYPE_CLOSURE;
 	closure = CLOSURE_BSDF_PRINCIPLED_ID;
 	distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID;
 	distribution_orig = NBUILTIN_CLOSURES;
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index bc488161e3b..a56313bd5d4 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -321,7 +321,14 @@ private:
 	static bool initialized;
 };
 
-class BsdfNode : public ShaderNode {
+class BsdfBaseNode : public ShaderNode {
+public:
+	BsdfBaseNode(const NodeType *node_type);
+
+	ClosureType closure;
+};
+
+class BsdfNode : public BsdfBaseNode {
 public:
 	explicit BsdfNode(const NodeType *node_type);
 	SHADER_NODE_BASE_CLASS(BsdfNode)
@@ -333,7 +340,6 @@ public:
 	float3 color;
 	float3 normal;
 	float surface_mix_weight;
-	ClosureType closure;
 
 	virtual bool equals(const ShaderNode& /*other*/)
 	{
@@ -362,7 +368,7 @@ public:
 };
 
 /* Disney principled BRDF */
-class PrincipledBsdfNode : public ShaderNode {
+class PrincipledBsdfNode : public BsdfBaseNode {
 public:
 	SHADER_NODE_CLASS(PrincipledBsdfNode)
 
@@ -381,7 +387,7 @@ public:
 		anisotropic_rotation, refraction_roughness;
 	float3 normal, clearcoat_normal, tangent;
 	float surface_mix_weight;
-	ClosureType closure, distribution, distribution_orig;
+	ClosureType distribution, distribution_orig;
 
 	virtual bool equals(const ShaderNode * /*other*/)
 	{




More information about the Bf-blender-cvs mailing list