forked from blender/blender
MaterialX: add support for nodes #11
@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#include "../material.h"
|
||||||
#include "node_parser.h"
|
#include "node_parser.h"
|
||||||
|
|
||||||
namespace blender::nodes::materialx {
|
namespace blender::nodes::materialx {
|
||||||
@ -10,20 +11,18 @@ NodeItem SeparateColorNodeParser::compute()
|
|||||||
{
|
{
|
||||||
int mode = static_cast<NodeCombSepColor *>(node_->storage)->mode;
|
int mode = static_cast<NodeCombSepColor *>(node_->storage)->mode;
|
||||||
NodeItem color = get_input_value("Color");
|
NodeItem color = get_input_value("Color");
|
||||||
std::string channel_1;
|
|
||||||
std::string channel_2;
|
|
||||||
|
|
||||||
NodeItem convert = empty();
|
NodeItem convert = empty();
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case NODE_COMBSEP_COLOR_RGB:
|
case NODE_COMBSEP_COLOR_RGB:
|
||||||
channel_1 = "Red";
|
|
||||||
channel_2 = "Green";
|
|
||||||
break;
|
break;
|
||||||
case NODE_COMBSEP_COLOR_HSV:
|
case NODE_COMBSEP_COLOR_HSV:
|
||||||
|
convert = create_node("rgbtohsv", "color3");
|
||||||
|
convert.set_input("in", color, NodeItem::Type::Color3);
|
||||||
|
break;
|
||||||
case NODE_COMBSEP_COLOR_HSL:
|
case NODE_COMBSEP_COLOR_HSL:
|
||||||
channel_1 = "Hue";
|
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
|
||||||
channel_2 = "Saturation";
|
|
||||||
convert = create_node("rgbtohsv", "color3");
|
convert = create_node("rgbtohsv", "color3");
|
||||||
convert.set_input("in", color, NodeItem::Type::Color3);
|
convert.set_input("in", color, NodeItem::Type::Color3);
|
||||||
break;
|
break;
|
||||||
@ -31,9 +30,7 @@ NodeItem SeparateColorNodeParser::compute()
|
|||||||
BLI_assert_unreachable();
|
BLI_assert_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = STREQ(socket_out_->name, channel_1.c_str()) ? 0 :
|
int index = STREQ(socket_out_->name, "Red") ? 0 : STREQ(socket_out_->name, "Green") ? 1 : 2;
|
||||||
STREQ(socket_out_->name, channel_2.c_str()) ? 1 :
|
|
||||||
2;
|
|
||||||
|
|
||||||
NodeItem res = convert ? convert : color;
|
NodeItem res = convert ? convert : color;
|
||||||
return res.extract(index);
|
return res.extract(index);
|
||||||
|
Loading…
Reference in New Issue
Block a user