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
4 changed files with 37 additions and 0 deletions
Showing only changes of commit dbd0e4492b - Show all commits

View File

@ -158,6 +158,7 @@ if(WITH_MATERIALX)
materialx/nodes/tex_environment.cc
materialx/nodes/tex_noise.cc
materialx/nodes/tex_checker.cc
materialx/nodes/hueSatVal.cc
materialx/material.h
materialx/nodes/node_item.h

View File

@ -0,0 +1,32 @@
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "node_parser.h"
namespace blender::nodes::materialx {
NodeItem HueSatValNodeParser::compute()
{
/* TODO: implement fac, see do_hue_sat_fac in source\blender\nodes\texture\nodes\node_texture_hueSatVal.cc */
NodeItem hue = get_input_value("Hue");
NodeItem saturation = get_input_value("Saturation");
NodeItem val = get_input_value("Value");
NodeItem fac = get_input_value("Fac");
NodeItem color = get_input_value("Color");
/* Modifier to follow Cycles result */
hue = hue - value(0.5f);
NodeItem combine = create_node("combine3", "vector3");
combine.set_input("in1", hue);
combine.set_input("in2", saturation);
combine.set_input("in3", val);
NodeItem res = create_node("hsvadjust", "color3", false);
res.set_input("in", color.to_color3());
res.set_input("amount", combine);
return res;
}
} // namespace blender::nodes::materialx

View File

@ -136,6 +136,9 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
case SH_NODE_TEX_CHECKER:
parser = std::make_unique<TexCheckerNodeParser>(graph, depsgraph, material, in_node);
break;
case SH_NODE_HUE_SAT:
parser = std::make_unique<HueSatValNodeParser>(graph, depsgraph, material, in_node);
break;
default:
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported node: %s (%d)", in_node->name, in_node->type);
return res;

View File

@ -68,5 +68,6 @@ DECLARE_PARSER(TexCheckerNodeParser)
DECLARE_PARSER(TexEnvironmentNodeParser)
DECLARE_PARSER(TexImageNodeParser)
DECLARE_PARSER(TexNoiseNodeParser)
DECLARE_PARSER(HueSatValNodeParser)
} // namespace blender::nodes::materialx