[Bf-blender-cvs] [b666593] master: Cycles: Remove Bump Node from the graph, if Height input is not connected.

Thomas Dinges noreply at git.blender.org
Thu Jun 11 23:24:22 CEST 2015


Commit: b66659377598999f2596288415c3b52224388532
Author: Thomas Dinges
Date:   Thu Jun 11 23:09:38 2015 +0200
Branches: master
https://developer.blender.org/rBb66659377598999f2596288415c3b52224388532

Cycles: Remove Bump Node from the graph, if Height input is not connected.

This way we can avoid building the split kernel with NODE_FEATURE_BUMP enabled, in case we don't need it.

===================================================================

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

===================================================================

diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 9adf6b4..e053710 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -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;
 }
 
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 93341b5..9117fd0 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -84,6 +84,7 @@ enum ShaderNodeSpecialType {
 	SHADER_SPECIAL_TYPE_IMAGE_SLOT,
 	SHADER_SPECIAL_TYPE_CLOSURE,
 	SHADER_SPECIAL_TYPE_EMISSION,
+	SHADER_SPECIAL_TYPE_BUMP,
 };
 
 /* Enum
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 430c059..69ae207 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -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);
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 4e78d58..7ec20f0 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -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;
 	}




More information about the Bf-blender-cvs mailing list