diff options
author | Thomas Dinges <blender@dingto.org> | 2013-07-04 03:46:56 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2013-07-04 03:46:56 +0400 |
commit | 285ef99931447646b20ec968ec87f7c68939a104 (patch) | |
tree | 52c8b276b800baef886cf0867ad1a99554503ea2 /intern/cycles/render | |
parent | e7fc69bdfd06f9fda7ddbcf53f26fee0b81abf8d (diff) |
Cycles:
* Added 2 new nodes to combine and separate HSV colors.
Screenshot:
http://www.pasteall.org/pic/show.php?id=54828
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 65 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 10 |
2 files changed, 74 insertions, 1 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 3fbcadee423..319d8210377 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -2644,6 +2644,37 @@ void CombineRGBNode::compile(OSLCompiler& compiler) compiler.add(this, "node_combine_rgb"); } +/* Combine HSV */ +CombineHSVNode::CombineHSVNode() +: ShaderNode("combine_hsv") +{ + add_input("H", SHADER_SOCKET_FLOAT); + add_input("S", SHADER_SOCKET_FLOAT); + add_input("V", SHADER_SOCKET_FLOAT); + add_output("Color", SHADER_SOCKET_COLOR); +} + +void CombineHSVNode::compile(SVMCompiler& compiler) +{ + ShaderInput *hue_in = input("H"); + ShaderInput *saturation_in = input("S"); + ShaderInput *value_in = input("V"); + ShaderOutput *color_out = output("Color"); + + compiler.stack_assign(color_out); + compiler.stack_assign(hue_in); + compiler.stack_assign(saturation_in); + compiler.stack_assign(value_in); + + compiler.add_node(NODE_COMBINE_HSV, hue_in->stack_offset, saturation_in->stack_offset, value_in->stack_offset); + compiler.add_node(NODE_COMBINE_HSV, color_out->stack_offset); +} + +void CombineHSVNode::compile(OSLCompiler& compiler) +{ + compiler.add(this, "node_combine_hsv"); +} + /* Gamma */ GammaNode::GammaNode() : ShaderNode("gamma") @@ -2737,7 +2768,39 @@ void SeparateRGBNode::compile(OSLCompiler& compiler) compiler.add(this, "node_separate_rgb"); } -/* Separate RGB */ +/* Separate HSV */ +SeparateHSVNode::SeparateHSVNode() +: ShaderNode("separate_rgb") +{ + add_input("Color", SHADER_SOCKET_COLOR); + add_output("H", SHADER_SOCKET_FLOAT); + add_output("S", SHADER_SOCKET_FLOAT); + add_output("V", SHADER_SOCKET_FLOAT); +} + +void SeparateHSVNode::compile(SVMCompiler& compiler) +{ + ShaderInput *color_in = input("Color"); + ShaderOutput *hue_out = output("H"); + ShaderOutput *saturation_out = output("S"); + ShaderOutput *value_out = output("V"); + + compiler.stack_assign(color_in); + compiler.stack_assign(hue_out); + compiler.stack_assign(saturation_out); + compiler.stack_assign(value_out); + + compiler.add_node(NODE_SEPARATE_HSV, color_in->stack_offset, hue_out->stack_offset, saturation_out->stack_offset); + compiler.add_node(NODE_SEPARATE_HSV, value_out->stack_offset); + +} + +void SeparateHSVNode::compile(OSLCompiler& compiler) +{ + compiler.add(this, "node_separate_hsv"); +} + +/* Hue Saturation Value */ HSVNode::HSVNode() : ShaderNode("hsv") { diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 670d8da7825..ed4d24c774a 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -407,6 +407,11 @@ public: SHADER_NODE_CLASS(CombineRGBNode) }; +class CombineHSVNode : public ShaderNode { +public: + SHADER_NODE_CLASS(CombineHSVNode) +}; + class GammaNode : public ShaderNode { public: SHADER_NODE_CLASS(GammaNode) @@ -422,6 +427,11 @@ public: SHADER_NODE_CLASS(SeparateRGBNode) }; +class SeparateHSVNode : public ShaderNode { +public: + SHADER_NODE_CLASS(SeparateHSVNode) +}; + class HSVNode : public ShaderNode { public: SHADER_NODE_CLASS(HSVNode) |