6# include <pxr/base/tf/stringUtils.h>
33 socket_out_(socket_out),
35 group_parser_(group_parser),
36 export_params_(export_params)
59 if (NodeItem::is_arithmetic(
to_type_)) {
67 auto valid_name = [](
const std::string &name) {
71 std::string res = MaterialX::createValidName(pxr::TfMakeValidIdentifier(name));
73 std::string res = MaterialX::createValidName(name);
82 if (with_out_socket) {
83 if (
node_->output_sockets().size() > 1) {
91#ifdef USE_MATERIALX_NODEGRAPH
92 return valid_name(name);
99 prefix = valid_name(ngroup->
id.
name) +
"_" + prefix;
102 return prefix + valid_name(name);
130 return get_default(
node_->input_by_identifier(name),
to_type);
135 return get_default(
node_->input_socket(index),
to_type);
160 return get_default(
node_->output_by_identifier(name),
to_type);
165 return get_default(
node_->output_socket(index),
to_type);
185 const bool is_active_uvmap = attribute_name ==
"" ||
193 res =
create_node(
"geompropvalue", type, {{
"geomprop",
val(geomprop)}});
195 res.
node->setName(name);
207 switch (socket.
type) {
213 res.
value = MaterialX::Value::createValue<float>(
v);
218 res.
value = MaterialX::Value::createValue<MaterialX::Vector3>(
219 MaterialX::Vector3(
v[0],
v[1],
v[2]));
224 res.
value = MaterialX::Value::createValue<MaterialX::Color4>(
225 MaterialX::Color4(
v[0],
v[1],
v[2],
v[3]));
237 bool use_group_default)
240 if (!(link && link->is_used())) {
247 while (from_node->is_reroute()) {
248 link = from_node->input_socket(0).link;
249 if (!(link && link->is_used())) {
255 if (from_node->is_group()) {
256 return GroupNodeParser(
graph_,
267 if (from_node->is_group_input()) {
268 return GroupInputNodeParser(
graph_,
280 if (!from_node->
typeinfo->materialx_fn) {
282 "Unsupported node: %s [%d]",
288 NodeParserData data = {
298 res = get_default(socket,
to_type);
#define CLOG_WARN(clg_ref,...)
#define CLG_LOGREF_DECLARE_GLOBAL(var, id)
#define CLOG_INFO(clg_ref, level,...)
ATTR_WARN_UNUSED_RESULT const BMVert * v
NodeItem create_input(const std::string &name, const NodeItem &item) const
MaterialX::ValuePtr value
NodeItem convert(Type to_type) const
NodeItem create_output(const std::string &name, const NodeItem &item) const
std::vector< std::pair< std::string, NodeItem > > Inputs
NodeItem create_node(const std::string &category, Type type) const
GroupNodeParser * group_parser_
NodeItem get_input_value(const std::string &name, NodeItem::Type to_type)
virtual NodeItem compute()=0
virtual NodeItem compute_full()
const bNodeSocket * socket_out_
MaterialX::GraphElement * graph_
const Material * material_
NodeParser(MaterialX::GraphElement *graph, const Depsgraph *depsgraph, const Material *material, const bNode *node, const bNodeSocket *socket_out, NodeItem::Type to_type, GroupNodeParser *group_parser, const ExportParams &export_params)
NodeItem create_input(const std::string &name, const NodeItem &item)
const Depsgraph * depsgraph_
ExportParams export_params_
NodeItem get_input_link(const std::string &name, NodeItem::Type to_type)
NodeItem texcoord_node(NodeItem::Type type=NodeItem::Type::Vector2, const std::string &attribute_name="")
NodeItem get_input_default(const std::string &name, NodeItem::Type to_type)
NodeItem get_output_default(const std::string &name, NodeItem::Type to_type)
NodeItem create_node(const std::string &category, NodeItem::Type type)
std::string node_name(bool with_out_socket=true) const
NodeItem create_output(const std::string &name, const NodeItem &item)
NodeItem val(const T &data) const
const Depsgraph * depsgraph
static Type to_type(const eGPUType type)
static const std::string TEXCOORD_NODE_NAME
struct CLG_LogRef * LOG_MATERIALX_SHADER
bNodeTypeHandle * typeinfo
std::string new_active_uvmap_name
std::string original_active_uvmap_name