diff options
-rw-r--r-- | intern/cycles/render/nodes.cpp | 19 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index e36a75f59b1..d732189af66 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -5785,6 +5785,15 @@ DisplacementNode::DisplacementNode() { } +void DisplacementNode::constant_fold(const ConstantFolder& folder) +{ + if(folder.all_inputs_constant()) { + if((height - midlevel == 0.0f) || (scale == 0.0f)) { + folder.make_zero(); + } + } +} + void DisplacementNode::compile(SVMCompiler& compiler) { ShaderInput *height_in = input("Height"); @@ -5836,6 +5845,16 @@ VectorDisplacementNode::VectorDisplacementNode() { } +void VectorDisplacementNode::constant_fold(const ConstantFolder& folder) +{ + if(folder.all_inputs_constant()) { + if((vector == make_float3(0.0f, 0.0f, 0.0f) && midlevel == 0.0f) || + (scale == 0.0f)) { + folder.make_zero(); + } + } +} + void VectorDisplacementNode::attributes(Shader *shader, AttributeRequestSet *attributes) { if(shader->has_surface && space == NODE_NORMAL_MAP_TANGENT) { diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 33df2866341..58c3d472cd3 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -1063,6 +1063,7 @@ public: class DisplacementNode : public ShaderNode { public: SHADER_NODE_CLASS(DisplacementNode) + void constant_fold(const ConstantFolder& folder); virtual int get_feature() { return NODE_FEATURE_BUMP; } @@ -1079,6 +1080,7 @@ public: SHADER_NODE_CLASS(VectorDisplacementNode) void attributes(Shader *shader, AttributeRequestSet *attributes); bool has_attribute_dependency() { return true; } + void constant_fold(const ConstantFolder& folder); virtual int get_feature() { return NODE_FEATURE_BUMP; } |