diff options
author | Thomas Dinges <blender@dingto.org> | 2015-12-07 01:47:38 +0300 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2015-12-07 01:47:38 +0300 |
commit | a3d774e4c94868c747230a200e0a41e371f547bd (patch) | |
tree | 6ce137910b6659e20d1029b9812da7cba68980e5 /intern/cycles/render | |
parent | c6be3fe9972885b7a97d8f5722575d0e9a6d32fb (diff) |
Cycles: Fold Value and RGB node as well.
This way, connecting Value or RGB node to e.g. a Math node will still allow folding.
Note: The same should be done for the ConvertNode, but I leave that for another day.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/graph.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 14 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 4 |
3 files changed, 19 insertions, 1 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index c9f39d449a4..def43876ada 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -617,7 +617,7 @@ void ShaderGraph::constant_fold() */ foreach(ShaderInput *input, output->links) { if(scheduled.find(input->parent) != scheduled.end()) { - /* Node might be not yet optimized but scheduled already + /* Node might not be optimized yet but scheduled already * by other dependencies. No need to re-schedule it. */ continue; diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index fd8410ce71b..e4f5885df0d 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3177,6 +3177,13 @@ ValueNode::ValueNode() add_output("Value", SHADER_SOCKET_FLOAT); } +bool ValueNode::constant_fold(ShaderOutput *socket, float3 *optimized_value) +{ + *optimized_value = make_float3(value, value, value); + + return true; +} + void ValueNode::compile(SVMCompiler& compiler) { ShaderOutput *val_out = output("Value"); @@ -3201,6 +3208,13 @@ ColorNode::ColorNode() add_output("Color", SHADER_SOCKET_COLOR); } +bool ColorNode::constant_fold(ShaderOutput *socket, float3 *optimized_value) +{ + *optimized_value = value; + + return true; +} + void ColorNode::compile(SVMCompiler& compiler) { ShaderOutput *color_out = output("Color"); diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 1fa4b67c6b9..51efbc37f38 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -485,6 +485,8 @@ class ValueNode : public ShaderNode { public: SHADER_NODE_CLASS(ValueNode) + bool constant_fold(ShaderOutput *socket, float3 *optimized_value); + float value; }; @@ -492,6 +494,8 @@ class ColorNode : public ShaderNode { public: SHADER_NODE_CLASS(ColorNode) + bool constant_fold(ShaderOutput *socket, float3 *optimized_value); + float3 value; }; |