diff options
author | Thomas Dinges <blender@dingto.org> | 2015-01-21 22:06:53 +0300 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2015-01-21 22:16:18 +0300 |
commit | cd723967970e3330d5461eaf8a062d6321de5d4f (patch) | |
tree | 4e72e360bfe3fed6d04296628e0d0dc92e32cccd /intern/cycles/render/graph.cpp | |
parent | 7165db53f2663b78749019ff791816c36e6182e6 (diff) |
Cycles: Optimization for black world backgrounds
* If a Background node is set to a black color or zero strength,
it now gets removed from the shader graph.
* In case the graph is empty (no background node), the kernel will skip
evaluating it and save some rendertime. This can help quite a bit in scenes,
where the majority of the image consists of a black background.
Example: http://www.pasteall.org/pic/show.php?id=82650
In this case the render is ~16% faster.
Differential Revision: https://developer.blender.org/D972
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r-- | intern/cycles/render/graph.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 8f8a69373da..84fe55b69dd 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -374,6 +374,28 @@ void ShaderGraph::remove_unneeded_nodes() removed[proxy->id] = true; any_node_removed = true; } + else if(node->special_type == SHADER_SPECIAL_TYPE_BACKGROUND) { + BackgroundNode *bg = static_cast<BackgroundNode*>(node); + + if(bg->outputs[0]->links.size()) { + /* Black color or zero strength, remove node */ + if((!bg->inputs[0]->link && bg->inputs[0]->value == make_float3(0.0f, 0.0f, 0.0f)) || + (!bg->inputs[1]->link && bg->inputs[1]->value.x == 0.0f)) { + vector<ShaderInput*> inputs = bg->outputs[0]->links; + + foreach(ShaderInput *sock, bg->inputs) { + if(sock->link) + disconnect(sock); + } + + foreach(ShaderInput *input, inputs) + disconnect(input); + + removed[bg->id] = true; + any_node_removed = true; + } + } + } else if(node->special_type == SHADER_SPECIAL_TYPE_MIX_CLOSURE) { MixClosureNode *mix = static_cast<MixClosureNode*>(node); |