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.
This commit is contained in:
Sergey Sharybin 2017-04-21 12:50:04 +02:00
parent e4ab70da86
commit b6da2a6a86
2 changed files with 20 additions and 8 deletions

View File

@ -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;

View File

@ -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*/)
{