Code cleanup: deduplicate some bsdf node methods.
This commit is contained in:
@@ -1801,6 +1801,14 @@ BsdfBaseNode::BsdfBaseNode(const NodeType *node_type)
|
|||||||
special_type = SHADER_SPECIAL_TYPE_CLOSURE;
|
special_type = SHADER_SPECIAL_TYPE_CLOSURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BsdfBaseNode::has_bump()
|
||||||
|
{
|
||||||
|
/* detect if anything is plugged into the normal input besides the default */
|
||||||
|
ShaderInput *normal_in = input("Normal");
|
||||||
|
return (normal_in && normal_in->link &&
|
||||||
|
normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY);
|
||||||
|
}
|
||||||
|
|
||||||
/* BSDF Closure */
|
/* BSDF Closure */
|
||||||
|
|
||||||
BsdfNode::BsdfNode(const NodeType *node_type)
|
BsdfNode::BsdfNode(const NodeType *node_type)
|
||||||
@@ -1845,14 +1853,6 @@ void BsdfNode::compile(OSLCompiler& /*compiler*/)
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BsdfNode::has_bump()
|
|
||||||
{
|
|
||||||
/* detect if anything is plugged into the normal input besides the default */
|
|
||||||
ShaderInput *normal_in = input("Normal");
|
|
||||||
return (normal_in && normal_in->link &&
|
|
||||||
normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Anisotropic BSDF Closure */
|
/* Anisotropic BSDF Closure */
|
||||||
|
|
||||||
NODE_DEFINE(AnisotropicBsdfNode)
|
NODE_DEFINE(AnisotropicBsdfNode)
|
||||||
|
@@ -326,6 +326,16 @@ class BsdfBaseNode : public ShaderNode {
|
|||||||
public:
|
public:
|
||||||
BsdfBaseNode(const NodeType *node_type);
|
BsdfBaseNode(const NodeType *node_type);
|
||||||
|
|
||||||
|
bool has_spatial_varying() { return true; }
|
||||||
|
virtual ClosureType get_closure_type() { return closure; }
|
||||||
|
virtual bool has_bump();
|
||||||
|
|
||||||
|
virtual bool equals(const ShaderNode& /*other*/)
|
||||||
|
{
|
||||||
|
/* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ClosureType closure;
|
ClosureType closure;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -334,20 +344,11 @@ public:
|
|||||||
explicit BsdfNode(const NodeType *node_type);
|
explicit BsdfNode(const NodeType *node_type);
|
||||||
SHADER_NODE_BASE_CLASS(BsdfNode)
|
SHADER_NODE_BASE_CLASS(BsdfNode)
|
||||||
|
|
||||||
bool has_spatial_varying() { return true; }
|
|
||||||
void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL, ShaderInput *param4 = NULL);
|
void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL, ShaderInput *param4 = NULL);
|
||||||
virtual ClosureType get_closure_type() { return closure; }
|
|
||||||
virtual bool has_bump();
|
|
||||||
|
|
||||||
float3 color;
|
float3 color;
|
||||||
float3 normal;
|
float3 normal;
|
||||||
float surface_mix_weight;
|
float surface_mix_weight;
|
||||||
|
|
||||||
virtual bool equals(const ShaderNode& /*other*/)
|
|
||||||
{
|
|
||||||
/* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AnisotropicBsdfNode : public BsdfNode {
|
class AnisotropicBsdfNode : public BsdfNode {
|
||||||
@@ -374,7 +375,6 @@ class PrincipledBsdfNode : public BsdfBaseNode {
|
|||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(PrincipledBsdfNode)
|
SHADER_NODE_CLASS(PrincipledBsdfNode)
|
||||||
|
|
||||||
bool has_spatial_varying() { return true; }
|
|
||||||
bool has_surface_bssrdf();
|
bool has_surface_bssrdf();
|
||||||
bool has_bssrdf_bump();
|
bool has_bssrdf_bump();
|
||||||
void compile(SVMCompiler& compiler, ShaderInput *metallic, ShaderInput *subsurface, ShaderInput *subsurface_radius,
|
void compile(SVMCompiler& compiler, ShaderInput *metallic, ShaderInput *subsurface, ShaderInput *subsurface_radius,
|
||||||
@@ -391,13 +391,6 @@ public:
|
|||||||
float surface_mix_weight;
|
float surface_mix_weight;
|
||||||
ClosureType distribution, distribution_orig;
|
ClosureType distribution, distribution_orig;
|
||||||
|
|
||||||
virtual bool equals(const ShaderNode * /*other*/)
|
|
||||||
{
|
|
||||||
/* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClosureType get_closure_type() { return closure; }
|
|
||||||
bool has_integrator_dependency();
|
bool has_integrator_dependency();
|
||||||
void attributes(Shader *shader, AttributeRequestSet *attributes);
|
void attributes(Shader *shader, AttributeRequestSet *attributes);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user