diff options
-rw-r--r-- | intern/cycles/render/graph.cpp | 15 | ||||
-rw-r--r-- | intern/cycles/render/graph.h | 1 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index ab89ee3ae37..9adf6b4b1ed 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -404,6 +404,21 @@ void ShaderGraph::remove_unneeded_nodes() } } } + else if(node->special_type == SHADER_SPECIAL_TYPE_EMISSION) { + EmissionNode *em = static_cast<EmissionNode*>(node); + + if(em->outputs[0]->links.size()) { + /* Black color or zero strength, remove node */ + if((!em->inputs[0]->link && em->inputs[0]->value == make_float3(0.0f, 0.0f, 0.0f)) || + (!em->inputs[1]->link && em->inputs[1]->value.x == 0.0f)) { + vector<ShaderInput*> inputs = em->outputs[0]->links; + + relink(em->inputs, inputs, NULL); + removed[em->id] = true; + any_node_removed = true; + } + } + } else if(node->special_type == SHADER_SPECIAL_TYPE_MIX_CLOSURE) { MixClosureNode *mix = static_cast<MixClosureNode*>(node); diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index e6271009999..1a17909bddc 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -83,6 +83,7 @@ enum ShaderNodeSpecialType { SHADER_SPECIAL_TYPE_BACKGROUND, SHADER_SPECIAL_TYPE_IMAGE_SLOT, SHADER_SPECIAL_TYPE_CLOSURE, + SHADER_SPECIAL_TYPE_EMISSION, }; /* Enum diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 7eaecc2751c..430c059d686 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1923,6 +1923,8 @@ bool SubsurfaceScatteringNode::has_bssrdf_bump() EmissionNode::EmissionNode() : ShaderNode("emission") { + special_type = SHADER_SPECIAL_TYPE_EMISSION; + add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); add_input("Strength", SHADER_SOCKET_FLOAT, 10.0f); add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); |