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
3 changed files with 30 additions and 0 deletions
Showing only changes of commit fde60b146e - Show all commits

View File

@ -126,6 +126,7 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
switch (from_node->typeinfo->type) { switch (from_node->typeinfo->type) {
CASE_NODE_TYPE(SH_NODE_BSDF_PRINCIPLED, BSDFPrincipledNodeParser) CASE_NODE_TYPE(SH_NODE_BSDF_PRINCIPLED, BSDFPrincipledNodeParser)
CASE_NODE_TYPE(SH_NODE_COMBXYZ, CombineXYZNodeParser)
CASE_NODE_TYPE(SH_NODE_HUE_SAT, HueSatValNodeParser) CASE_NODE_TYPE(SH_NODE_HUE_SAT, HueSatValNodeParser)
CASE_NODE_TYPE(SH_NODE_INVERT, InvertNodeParser) CASE_NODE_TYPE(SH_NODE_INVERT, InvertNodeParser)
CASE_NODE_TYPE(SH_NODE_MATH, MathNodeParser) CASE_NODE_TYPE(SH_NODE_MATH, MathNodeParser)

View File

@ -62,6 +62,7 @@ template<class T> NodeItem NodeParser::value(const T &data) const
}; };
DECLARE_PARSER(BSDFPrincipledNodeParser) DECLARE_PARSER(BSDFPrincipledNodeParser)
DECLARE_PARSER(CombineXYZNodeParser)
DECLARE_PARSER(HueSatValNodeParser) DECLARE_PARSER(HueSatValNodeParser)
DECLARE_PARSER(InvertNodeParser) DECLARE_PARSER(InvertNodeParser)
DECLARE_PARSER(MathNodeParser) DECLARE_PARSER(MathNodeParser)

View File

@ -0,0 +1,28 @@
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "node_parser.h"
namespace blender::nodes::materialx {
NodeItem SeparateXYZNodeParser::compute()
{
NodeItem vector = get_input_value("Vector");
int index = STREQ(socket_out_->name, "X") ? 0 : STREQ(socket_out_->name, "Y") ? 1 : 2;
return vector.separate(index);
}
NodeItem CombineXYZNodeParser::compute()
{
NodeItem x = get_input_value("X");
NodeItem y = get_input_value("Y");
NodeItem z = get_input_value("Z");
NodeItem res = create_node("combine3", "vector3");
res.set_input("in1", x);
res.set_input("in2", y);
res.set_input("in3", z);
return res;
}
} // namespace blender::nodes::materialx