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();
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")) {
int v = socket.default_value_typed<bNodeSocketValueFloat>()->value;
res.value = MaterialX::Value::createValue<int>(v);
return res;
}
DagerD marked this conversation as resolved Outdated

Override get_input_default in SH_NODE_TEX_NOISE and move this code there.

Override `get_input_default` in SH_NODE_TEX_NOISE and move this code there.
/* Explicit check for Scale socket of Checker Texture node since MaterialX has scales for X and Y axes
* and Blender only single. */
/* Explicit check for Scale socket of Checker Texture node since MaterialX has scales for X and Y
* axes and Blender only single. */
if (node->typeinfo->type == SH_NODE_TEX_CHECKER && STREQ(socket.name, "Scale")) {
float v = socket.default_value_typed<bNodeSocketValueFloat>()->value;
res.value = MaterialX::Value::createValue<MaterialX::Vector2>({v, v});

View File

@ -10,10 +10,10 @@
#include <MaterialXFormat/XmlIo.h>
namespace blender::nodes::materialx {
/* For some reason validator complains about 'octaves' input of 'fractal3d' node (which doesn't even exist here)
* and 'in1' input of 'modulo' node, perhaps implementation is fully correct and similar to standart MaterialX
* Checkerboard node (added in 1.38.8). Also seems like USD due to lack of support doesn't render this material,
* but MaterialX Viewer and GraphEditor do. */
/* For some reason validator complains about 'octaves' input of 'fractal3d' node (which doesn't
DagerD marked this conversation as resolved Outdated

change create_node() signature accessory->noname = true

change create_node() signature accessory->noname = true
* even exist here) and 'in1' input of 'modulo' node, perhaps implementation is fully correct and
* similar to standart MaterialX Checkerboard node (added in 1.38.8). Also seems like USD due to
* lack of support doesn't render this material, but MaterialX Viewer and GraphEditor do. */
NodeItem TexCheckerNodeParser::compute()
{
@ -73,14 +73,14 @@ NodeItem TexCheckerNodeParser::compute()
ifequal.set_input("in1", MaterialX::Value::createValue<float>(1.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 color2 = get_input_value("Color2");
mix.set_input("fg", color1.to_color3());
mix.set_input("bg", color2.to_color3());
mix.set_input("mix", ifequal);
res.set_input("fg", color1.to_color3());
res.set_input("bg", color2.to_color3());
res.set_input("mix", ifequal);
return mix;
return res;
}
} // namespace blender::nodes::materialx

View File

@ -22,7 +22,7 @@ NodeItem TexNoiseNodeParser::compute()
NodeItem position = texcoord * scale;
NodeItem detail = get_input_value("Detail");
NodeItem lacunarity = get_input_value("Lacunarity");
NodeItem res = create_node("fractal3d", "color3", true);
res.set_input("position", position);
res.set_input("octaves", detail);