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:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-11-25 11:07:29 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-11-25 11:07:32 +0300
commit443b159f023a872472d8e61c7270dab472a3d8ee (patch)
tree011015dbde30f6adc8b95c2710e2e5a5f13ca528 /intern/cycles/render/graph.cpp
parentde35827612f85511aed50b9f05953ad857fe7e1c (diff)
Cycles: Ensure order of shader nodes in the dependnecies set
The issue was than nodes dependencies were stored as set<ShaderNode*> which is actually a so called "strict weak ordered", meaning order of nodes in the set is strictly defined, but based on the ShaderNode pointer. This means that between different render invokations order of original nodes could be different due to different pointers allocated for ShaderNode. This commit makes it so dependencies and maps used for ShaderNodes are based on the node->id which has much more predictable order. It's still possible to trick the system by doing some crazy edits during viewport rendfer and cause difference between viewport and final render stacks. Reviewers: brecht Reviewed By: brecht Subscribers: LazyDodo Differential Revision: https://developer.blender.org/D1630
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r--intern/cycles/render/graph.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 7e6e960d585..3e417d13d4d 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -192,11 +192,11 @@ ShaderGraph *ShaderGraph::copy()
ShaderGraph *newgraph = new ShaderGraph();
/* copy nodes */
- set<ShaderNode*> nodes_all;
+ ShaderNodeSet nodes_all;
foreach(ShaderNode *node, nodes)
nodes_all.insert(node);
- map<ShaderNode*, ShaderNode*> nodes_copy;
+ ShaderNodeMap nodes_copy;
copy_nodes(nodes_all, nodes_copy);
/* add nodes (in same order, so output is still first) */
@@ -301,7 +301,7 @@ void ShaderGraph::finalize(Scene *scene,
}
}
-void ShaderGraph::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input)
+void ShaderGraph::find_dependencies(ShaderNodeSet& dependencies, ShaderInput *input)
{
/* find all nodes that this input depends on directly and indirectly */
ShaderNode *node = (input->link)? input->link->parent: NULL;
@@ -314,7 +314,7 @@ void ShaderGraph::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput
}
}
-void ShaderGraph::copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNode*>& nnodemap)
+void ShaderGraph::copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap)
{
/* copy a set of nodes, and the links between them. the assumption is
* made that all nodes that inputs are linked to are in the set too. */
@@ -719,14 +719,14 @@ void ShaderGraph::refine_bump_nodes()
foreach(ShaderNode *node, nodes) {
if(node->name == ustring("bump") && node->input("Height")->link) {
ShaderInput *bump_input = node->input("Height");
- set<ShaderNode*> nodes_bump;
+ ShaderNodeSet nodes_bump;
/* make 2 extra copies of the subgraph defined in Bump input */
- map<ShaderNode*, ShaderNode*> nodes_dx;
- map<ShaderNode*, ShaderNode*> nodes_dy;
+ ShaderNodeMap nodes_dx;
+ ShaderNodeMap nodes_dy;
/* find dependencies for the given input */
- find_dependencies(nodes_bump, bump_input );
+ find_dependencies(nodes_bump, bump_input);
copy_nodes(nodes_bump, nodes_dx);
copy_nodes(nodes_bump, nodes_dy);
@@ -785,13 +785,13 @@ void ShaderGraph::bump_from_displacement()
return;
/* find dependencies for the given input */
- set<ShaderNode*> nodes_displace;
+ ShaderNodeSet nodes_displace;
find_dependencies(nodes_displace, displacement_in);
/* copy nodes for 3 bump samples */
- map<ShaderNode*, ShaderNode*> nodes_center;
- map<ShaderNode*, ShaderNode*> nodes_dx;
- map<ShaderNode*, ShaderNode*> nodes_dy;
+ ShaderNodeMap nodes_center;
+ ShaderNodeMap nodes_dx;
+ ShaderNodeMap nodes_dy;
copy_nodes(nodes_displace, nodes_center);
copy_nodes(nodes_displace, nodes_dx);