Cycles: tweak some folding tests to avoid unnecessary type conversion.
authorAlexander Gavrilov <angavrilov@gmail.com>
Tue, 2 Aug 2016 09:08:04 +0000 (12:08 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Tue, 2 Aug 2016 09:08:48 +0000 (12:08 +0300)
It's easy to connect a simple value to output without forcing
conversion to color by using the Strength socket of Emission.

intern/cycles/test/render_graph_finalize_test.cpp

index e329384021a0beb4d4b4bfbb425a5857bace71c7..cf4083c23dbf9534a96a3065301a396cf4833a6b 100644 (file)
@@ -140,6 +140,14 @@ public:
                        .output_closure("EmissionNode::Emission");
        }
 
                        .output_closure("EmissionNode::Emission");
        }
 
+       ShaderGraphBuilder& output_value(const string& from)
+       {
+               return (*this)
+                       .add_node(ShaderNodeBuilder<EmissionNode>("EmissionNode"))
+                       .add_connection(from, "EmissionNode::Strength")
+                       .output_closure("EmissionNode::Emission");
+       }
+
 protected:
        ShaderGraph *graph_;
        map<string, ShaderNode *> node_map_;
 protected:
        ShaderGraph *graph_;
        map<string, ShaderNode *> node_map_;
@@ -955,7 +963,7 @@ TEST(render_graph, constant_fold_math)
                          .set(&MathNode::use_clamp, false)
                          .set("Value1", 0.7f)
                          .set("Value2", 0.9f))
                          .set(&MathNode::use_clamp, false)
                          .set("Value1", 0.7f)
                          .set("Value2", 0.9f))
-               .output_color("Math::Value");
+               .output_value("Math::Value");
 
        graph.finalize(&scene);
 }
 
        graph.finalize(&scene);
 }
@@ -976,7 +984,7 @@ TEST(render_graph, constant_fold_math_clamp)
                          .set(&MathNode::use_clamp, true)
                          .set("Value1", 0.7f)
                          .set("Value2", 0.9f))
                          .set(&MathNode::use_clamp, true)
                          .set("Value1", 0.7f)
                          .set("Value2", 0.9f))
-               .output_color("Math::Value");
+               .output_value("Math::Value");
 
        graph.finalize(&scene);
 }
 
        graph.finalize(&scene);
 }
@@ -1007,7 +1015,7 @@ static void build_math_partial_test_graph(ShaderGraphBuilder &builder, NodeMath
                          .set(&MathNode::use_clamp, true))
                .add_connection("Math_Cx::Value", "Out::Value1")
                .add_connection("Math_xC::Value", "Out::Value2")
                          .set(&MathNode::use_clamp, true))
                .add_connection("Math_Cx::Value", "Out::Value1")
                .add_connection("Math_xC::Value", "Out::Value2")
-               .output_color("Out::Value");
+               .output_value("Out::Value");
 }
 
 /*
 }
 
 /*