Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-03-31 05:18:10 +0400
committerThomas Dinges <blender@dingto.org>2013-03-31 05:18:10 +0400
commit2c58e96685e80e4e12dfad56ed3bb51fa3824197 (patch)
tree15c34097befcecbb43b3f3e74bf0b1b76da84f1b /intern/cycles/render/graph.cpp
parent1fea6220a2418b07bec8bbf49da00cc77094076f (diff)
Cycles / Shader Graph optimization:
* Unnecessary shader inputs inside the Mix Shader are now ignored, in case the factor is 0.0 / 1.0 and not connected. This way we save some render time for complex node graphs. Example: http://www.pasteall.org/pic/show.php?id=48226 Check the Mix Shader at the end: In this case, Cycles will now avoid the complete huge shader tree, and only calculate the Diffuse Shader. Rendertime decreased from 1:50 min to 1:20 min on CPU. GPU rendering benefits as well from this. This only affects SVM, OSL was already doing these optimizations.
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r--intern/cycles/render/graph.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index af27b46771c..50fee15c231 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -365,6 +365,45 @@ void ShaderGraph::remove_proxy_nodes(vector<bool>& removed)
}
}
}
+
+ /* remove unused mix closure input when factor is 0.0 or 1.0 */
+ if(node->special_type == SHADER_SPECIAL_TYPE_MIX_CLOSURE) {
+ MixClosureNode *mix = static_cast<MixClosureNode*>(node);
+ /* Check for closure links and make sure factor link is disconnected */
+ if(mix->outputs[0]->links.size() && mix->inputs[1]->link && mix->inputs[2]->link && !mix->inputs[0]->link) {
+
+ /* Factor 0.0 */
+ if(mix->inputs[0]->value.x == 0.0f) {
+ 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);
+ if (output)
+ connect(output, input);
+ }
+ }
+ /* Factor 1.0 */
+ else if (mix->inputs[0]->value.x == 1.0f) {
+ ShaderOutput *output = mix->inputs[2]->link;
+ vector<ShaderInput*> inputs = mix->outputs[0]->links;
+
+ foreach(ShaderInput *sock, mix->inputs)
+ if(sock->link)
+ disconnect(sock);
+
+ foreach(ShaderInput *input, inputs) {
+ disconnect(input);
+ if (output)
+ connect(output, input);
+ }
+ }
+ }
+ }
}
}