diff options
-rw-r--r-- | intern/cycles/render/graph.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index d9486de47c9..77bc9cf27ec 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -325,6 +325,25 @@ void ShaderGraph::remove_proxy_nodes(vector<bool>& removed) removed[proxy->id] = true; } + + /* remove useless mix closures nodes */ + MixClosureNode *mix = dynamic_cast<MixClosureNode*>(node); + + if(mix) { + if(mix->outputs[0]->links.size() && mix->inputs[1]->link == mix->inputs[2]->link) { + ShaderOutput *output = mix->inputs[1]->link; + vector<ShaderInput*> inputs = mix->outputs[0]->links; + + foreach(ShaderInput *sock, mix->inputs) + if(sock->link) + disconnect(sock); + + foreach(ShaderInput *input, inputs) { + disconnect(input); + connect(output, input); + } + } + } } } |