Export to MatX various Texture nodes #5

Merged
Bogdan Nagirniak merged 17 commits from matx-add-tex-nodes into matx-export-material 2023-08-31 19:49:26 +02:00
3 changed files with 14 additions and 13 deletions
Showing only changes of commit 7511e1fcbc - Show all commits

View File

@ -353,14 +353,15 @@ NodeItem NodeParser::get_input_default(const std::string &name)
NodeItem res = empty_value(); NodeItem res = empty_value();
const bNodeSocket &socket = node->input_by_identifier(name); const bNodeSocket &socket = node->input_by_identifier(name);
/* Explicit check for Detail socket of Noise Texture node since MaterialX expects integer for octaves. */ /* Explicit check for Detail socket of Noise Texture node since MaterialX expects integer for
* octaves. */
if (node->typeinfo->type == SH_NODE_TEX_NOISE && STREQ(socket.name, "Detail")) { if (node->typeinfo->type == SH_NODE_TEX_NOISE && STREQ(socket.name, "Detail")) {
int v = socket.default_value_typed<bNodeSocketValueFloat>()->value; int v = socket.default_value_typed<bNodeSocketValueFloat>()->value;
res.value = MaterialX::Value::createValue<int>(v); res.value = MaterialX::Value::createValue<int>(v);
return res; return res;
} }
/* Explicit check for Scale socket of Checker Texture node since MaterialX has scales for X and Y axes /* Explicit check for Scale socket of Checker Texture node since MaterialX has scales for X and Y
* and Blender only single. */ * axes and Blender only single. */
if (node->typeinfo->type == SH_NODE_TEX_CHECKER && STREQ(socket.name, "Scale")) { if (node->typeinfo->type == SH_NODE_TEX_CHECKER && STREQ(socket.name, "Scale")) {
float v = socket.default_value_typed<bNodeSocketValueFloat>()->value; float v = socket.default_value_typed<bNodeSocketValueFloat>()->value;
res.value = MaterialX::Value::createValue<MaterialX::Vector2>({v, v}); res.value = MaterialX::Value::createValue<MaterialX::Vector2>({v, v});

View File

@ -10,10 +10,10 @@
#include <MaterialXFormat/XmlIo.h> #include <MaterialXFormat/XmlIo.h>
namespace blender::nodes::materialx { namespace blender::nodes::materialx {
/* For some reason validator complains about 'octaves' input of 'fractal3d' node (which doesn't even exist here) /* For some reason validator complains about 'octaves' input of 'fractal3d' node (which doesn't
* and 'in1' input of 'modulo' node, perhaps implementation is fully correct and similar to standart MaterialX * even exist here) and 'in1' input of 'modulo' node, perhaps implementation is fully correct and
* Checkerboard node (added in 1.38.8). Also seems like USD due to lack of support doesn't render this material, * similar to standart MaterialX Checkerboard node (added in 1.38.8). Also seems like USD due to
* but MaterialX Viewer and GraphEditor do. */ * lack of support doesn't render this material, but MaterialX Viewer and GraphEditor do. */
NodeItem TexCheckerNodeParser::compute() NodeItem TexCheckerNodeParser::compute()
{ {
@ -73,14 +73,14 @@ NodeItem TexCheckerNodeParser::compute()
ifequal.set_input("in1", MaterialX::Value::createValue<float>(1.0f)); ifequal.set_input("in1", MaterialX::Value::createValue<float>(1.0f));
ifequal.set_input("in2", MaterialX::Value::createValue<float>(0.0f)); ifequal.set_input("in2", MaterialX::Value::createValue<float>(0.0f));
NodeItem mix = create_node("mix", "color3", true); NodeItem res = create_node("mix", "color3", true);
NodeItem color1 = get_input_value("Color1"); NodeItem color1 = get_input_value("Color1");
NodeItem color2 = get_input_value("Color2"); NodeItem color2 = get_input_value("Color2");
mix.set_input("fg", color1.to_color3()); res.set_input("fg", color1.to_color3());
mix.set_input("bg", color2.to_color3()); res.set_input("bg", color2.to_color3());
mix.set_input("mix", ifequal); res.set_input("mix", ifequal);
return mix; return res;
} }
} // namespace blender::nodes::materialx } // namespace blender::nodes::materialx