Cycles: Remove Bump Node from the graph, if Height input is not connected.
authorThomas Dinges <blender@dingto.org>
Thu, 11 Jun 2015 21:09:38 +0000 (23:09 +0200)
committerThomas Dinges <blender@dingto.org>
Thu, 11 Jun 2015 21:09:38 +0000 (23:09 +0200)
This way we can avoid building the split kernel with NODE_FEATURE_BUMP enabled, in case we don't need it.

intern/cycles/render/graph.cpp
intern/cycles/render/graph.h
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h

index 9adf6b4b1ed7e826edff368dc4326237dea04bde..e05371012470d4590a9a1d110e9a6265e4b2b270 100644 (file)
@@ -419,6 +419,21 @@ void ShaderGraph::remove_unneeded_nodes()
                                }
                        }
                }
+               else if(node->special_type == SHADER_SPECIAL_TYPE_BUMP) {
+                       BumpNode *bump = static_cast<BumpNode*>(node);
+
+                       if(bump->outputs[0]->links.size()) {
+                               /* Height input not connected */
+                               /* ToDo: Strength zero? */
+                               if(!bump->inputs[0]->link) {
+                                       vector<ShaderInput*> inputs = bump->outputs[0]->links;
+
+                                       relink(bump->inputs, inputs, NULL);
+                                       removed[bump->id] = true;
+                                       any_node_removed = true;
+                               }
+                       }
+               }
                else if(node->special_type == SHADER_SPECIAL_TYPE_MIX_CLOSURE) {
                        MixClosureNode *mix = static_cast<MixClosureNode*>(node);
 
@@ -560,7 +575,7 @@ void ShaderGraph::clean()
                else
                        delete node;
        }
-       
+
        nodes = newnodes;
 }
 
index 93341b56d99adc118a3ec14391135d5bf7d46c3f..9117fd03a95dfdf59f8d238826c1458d35456ec4 100644 (file)
@@ -84,6 +84,7 @@ enum ShaderNodeSpecialType {
        SHADER_SPECIAL_TYPE_IMAGE_SLOT,
        SHADER_SPECIAL_TYPE_CLOSURE,
        SHADER_SPECIAL_TYPE_EMISSION,
+       SHADER_SPECIAL_TYPE_BUMP,
 };
 
 /* Enum
index 430c059d686aaaec392443f3f513debeb8049514..69ae20782162112b701368351d46a5193416c047 100644 (file)
@@ -3934,6 +3934,8 @@ BumpNode::BumpNode()
 {
        invert = false;
 
+       special_type = SHADER_SPECIAL_TYPE_BUMP;
+
        /* this input is used by the user, but after graph transform it is no longer
         * used and moved to sampler center/x/y instead */
        add_input("Height", SHADER_SOCKET_FLOAT);
index 4e78d58aaf324f4fc52a26506812d9e2ac16c850..7ec20f0879be8dd81a542f00e1c05d0882b4867c 100644 (file)
@@ -652,7 +652,6 @@ public:
        SHADER_NODE_CLASS(BumpNode)
        bool has_spatial_varying() { return true; }
        virtual int get_feature() {
-               /* TODO(sergey): Check for incoming links. */
                return NODE_FEATURE_BUMP;
        }