MaterialX: add support for nodes #11

Merged
Bogdan Nagirniak merged 17 commits from matx-add-other-nodes into matx-export-material 2023-09-06 10:37:26 +02:00
Showing only changes of commit 2c6da32ae0 - Show all commits

View File

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