Fix: MaterialX export uses socket names instead of identifiers
Which doesn't work well with upcoming Fac to Factor renaming. Pull Request: https://projects.blender.org/blender/blender/pulls/140498
This commit is contained in:
@@ -109,7 +109,7 @@ NodeItem GroupOutputNodeParser::compute_full()
|
||||
|
||||
std::string GroupOutputNodeParser::out_name(const bNodeSocket *out_socket)
|
||||
{
|
||||
return MaterialX::createValidName(std::string("out_") + out_socket->name);
|
||||
return MaterialX::createValidName(std::string("out_") + out_socket->identifier);
|
||||
}
|
||||
|
||||
NodeItem GroupInputNodeParser::compute()
|
||||
@@ -156,7 +156,7 @@ NodeItem GroupInputNodeParser::compute_full()
|
||||
|
||||
std::string GroupInputNodeParser::in_name() const
|
||||
{
|
||||
return MaterialX::createValidName(std::string("in_") + socket_out_->name);
|
||||
return MaterialX::createValidName(std::string("in_") + socket_out_->identifier);
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::materialx
|
||||
|
||||
@@ -60,7 +60,7 @@ std::string NodeParser::node_name(const char *override_output_name) const
|
||||
to_type_ :
|
||||
NodeItem::Type::Empty;
|
||||
const StringRef socket_out_name = (override_output_name) ? override_output_name :
|
||||
(socket_out_) ? socket_out_->name :
|
||||
(socket_out_) ? socket_out_->identifier :
|
||||
"";
|
||||
return graph_.unique_node_name(node_, socket_out_name, to_type);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
* res.set_input("maxdistance", maxdistance);
|
||||
* \endcode
|
||||
*/
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -91,7 +91,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{
|
||||
/* TODO: some outputs expected be implemented within the next iteration
|
||||
* (see node-definition `<geompropvalue>`). */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -30,7 +30,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* NOTE: This node doesn't have an implementation in MaterialX. */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -63,7 +63,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{
|
||||
/* NOTE: Some outputs aren't supported by MaterialX. */
|
||||
NodeItem res = empty();
|
||||
std::string name = socket_out_->name;
|
||||
std::string name = socket_out_->identifier;
|
||||
|
||||
if (name == "Position") {
|
||||
res = create_node("position", NodeItem::Type::Vector3, {{"space", val(std::string("world"))}});
|
||||
|
||||
@@ -38,7 +38,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* NOTE: This node doesn't have an implementation in MaterialX. */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -38,10 +38,10 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* NOTE: This node isn't supported by MaterialX. Only default values returned. */
|
||||
if (STREQ(socket_out_->name, "Is Camera Ray")) {
|
||||
if (STREQ(socket_out_->identifier, "Is Camera Ray")) {
|
||||
return val(1.0f);
|
||||
}
|
||||
if (STREQ(socket_out_->name, "Ray Length")) {
|
||||
if (STREQ(socket_out_->identifier, "Ray Length")) {
|
||||
return val(1.0f);
|
||||
}
|
||||
NodeItem res = val(0.0f);
|
||||
|
||||
@@ -44,7 +44,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{
|
||||
NodeItem res = get_output_default("Normal", NodeItem::Type::Vector3);
|
||||
|
||||
if (STREQ(socket_out_->name, "Dot")) {
|
||||
if (STREQ(socket_out_->identifier, "Dot")) {
|
||||
return res.dotproduct(get_input_value("Normal", NodeItem::Type::Vector3));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{
|
||||
/* NOTE: Some outputs isn't supported by MaterialX. */
|
||||
NodeItem res = empty();
|
||||
std::string name = socket_out_->name;
|
||||
std::string name = socket_out_->identifier;
|
||||
|
||||
if (name == "Location") {
|
||||
res = create_node("position", NodeItem::Type::Vector3, {{"space", val(std::string("world"))}});
|
||||
|
||||
@@ -36,7 +36,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* NOTE: This node isn't supported by MaterialX. */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -26,7 +26,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* NOTE: This node isn't supported by MaterialX. */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -85,7 +85,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
|
||||
int index = STREQ(socket_out_->name, "Red") ? 0 : STREQ(socket_out_->name, "Green") ? 1 : 2;
|
||||
int index = STREQ(socket_out_->identifier, "Red") ? 0 : STREQ(socket_out_->identifier, "Green") ? 1 : 2;
|
||||
return convert[index];
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -123,7 +123,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
NodeItem vector = get_input_value("Vector", NodeItem::Type::Vector3);
|
||||
int index = STREQ(socket_out_->name, "X") ? 0 : STREQ(socket_out_->name, "Y") ? 1 : 2;
|
||||
int index = STREQ(socket_out_->identifier, "X") ? 0 :
|
||||
STREQ(socket_out_->identifier, "Y") ? 1 :
|
||||
2;
|
||||
return vector[index];
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -118,7 +118,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
}
|
||||
NodeItem value1 = val(1.0f);
|
||||
NodeItem value2 = val(0.0f);
|
||||
if (STREQ(socket_out_->name, "Color")) {
|
||||
if (STREQ(socket_out_->identifier, "Color")) {
|
||||
value1 = get_input_value("Color1", NodeItem::Type::Color3);
|
||||
value2 = get_input_value("Color2", NodeItem::Type::Color3);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{
|
||||
/* NOTE: Some outputs aren't supported by MaterialX. */
|
||||
NodeItem res = empty();
|
||||
std::string name = socket_out_->name;
|
||||
std::string name = socket_out_->identifier;
|
||||
|
||||
if (ELEM(name, "Generated", "UV")) {
|
||||
res = texcoord_node();
|
||||
|
||||
@@ -262,7 +262,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
}
|
||||
}
|
||||
|
||||
if (STREQ(socket_out_->name, "Alpha")) {
|
||||
if (STREQ(socket_out_->identifier, "Alpha")) {
|
||||
res = res[3];
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -238,7 +238,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
break;
|
||||
}
|
||||
|
||||
if (STREQ(socket_out_->name, "Value")) {
|
||||
if (STREQ(socket_out_->identifier, "Value")) {
|
||||
return noise;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{
|
||||
/* TODO: some output expected be implemented within the next iteration
|
||||
* (see node-definition `<geomcolor>`). */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Any);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
@@ -42,7 +42,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* NOTE: This node isn't supported by MaterialX. */
|
||||
return get_output_default(socket_out_->name, NodeItem::Type::Float);
|
||||
return get_output_default(socket_out_->identifier, NodeItem::Type::Float);
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
Reference in New Issue
Block a user