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
path: root/intern
diff options
context:
space:
mode:
authorMai Lavelle <mai.lavelle@gmail.com>2016-09-11 20:39:12 +0300
committerMai Lavelle <mai.lavelle@gmail.com>2016-09-11 20:49:34 +0300
commit49df5d0980c3350bdcd34fa33220693f67f49e29 (patch)
tree017aa0e6319dcd7790fb04e2a33a9dbaf0c4e2ea /intern
parent013b46d6bda4388736d7953746d6b335ce495b16 (diff)
Cycles: Fix shading and crashes resulting from constant folding on displacement
Constant folding was removing all nodes connected to the displacement output if they evaluated to a constant, causing there to be no valid graph for displacement even when there was displacement to be applied, and sometimes caused crashes.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/render/graph.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 9ee8b674412..ed8c7056aaa 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -483,6 +483,8 @@ void ShaderGraph::constant_fold()
ShaderNodeSet done, scheduled;
queue<ShaderNode*> traverse_queue;
+ bool has_displacement = (output()->input("Displacement")->link != NULL);
+
/* Schedule nodes which doesn't have any dependencies. */
foreach(ShaderNode *node, nodes) {
if(!check_node_inputs_has_links(node)) {
@@ -520,6 +522,17 @@ void ShaderGraph::constant_fold()
node->constant_fold(folder);
}
}
+
+ /* Folding might have removed all nodes connected to the displacement output
+ * even tho there is displacement to be applied, so add in a value node if
+ * that happens to ensure there is still a valid graph for displacement.
+ */
+ if(has_displacement && !output()->input("Displacement")->link) {
+ ValueNode *value = (ValueNode*)add(new ValueNode());
+ value->value = output()->displacement;
+
+ connect(value->output("Value"), output()->input("Displacement"));
+ }
}
/* Step 3: Simplification. */