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
2 changed files with 11 additions and 11 deletions
Showing only changes of commit e80f6cabb5 - Show all commits

View File

@ -24,17 +24,20 @@ NodeItem TexCheckerNodeParser::get_input_default(const bNodeSocket &socket)
NodeItem TexCheckerNodeParser::compute() NodeItem TexCheckerNodeParser::compute()
{ {
NodeItem scale = get_input_value("Scale");
NodeItem color1 = get_input_value("Color1");
NodeItem color2 = get_input_value("Color2");
NodeItem texcoord = create_node("texcoord", "vector2", true); NodeItem texcoord = create_node("texcoord", "vector2", true);
NodeItem frequency = create_node("constant", "vector2", true); NodeItem frequency = create_node("constant", "vector2", true);
NodeItem scale = get_input_value("Scale");
/* Modifier to follow Cycles result. */ /* Modifier to follow Cycles result. */
NodeItem scale_fitter(graph); NodeItem scale_fitter(graph);
scale_fitter.value = MaterialX::Value::createValue<float>(4.0f); scale_fitter.value = MaterialX::Value::createValue<float>(4.0f);
frequency.set_input("value", scale * scale_fitter); frequency.set_input("value", scale * scale_fitter);
NodeItem offset = create_node("constant", "vector2", true); NodeItem offset = create_node("constant", "vector2", true);
offset.set_input("value", MaterialX::Value::createValue<MaterialX::Vector2>({0.0f, 0.0f})); offset.set_input("value", empty().val(MaterialX::Vector2({0.0f, 0.0f})));
NodeItem place2d = create_node("place2d", "vector2", true); NodeItem place2d = create_node("place2d", "vector2", true);
place2d.set_input("texcoord", texcoord * frequency); place2d.set_input("texcoord", texcoord * frequency);
@ -47,24 +50,21 @@ NodeItem TexCheckerNodeParser::compute()
NodeItem modulo_x = create_node("modulo", "float", true); NodeItem modulo_x = create_node("modulo", "float", true);
modulo_x.set_input("in1", separate); modulo_x.set_input("in1", separate);
modulo_x.set_input("in2", MaterialX::Value::createValue<float>(2.0f)); modulo_x.set_input("in2", empty().val(2.0f));
modulo_x.node->setConnectedOutput("in1", separate.node->getOutput("outx")); modulo_x.node->setConnectedOutput("in1", separate.node->getOutput("outx"));
NodeItem modulo_y = create_node("modulo", "float", true); NodeItem modulo_y = create_node("modulo", "float", true);
modulo_y.set_input("in1", separate); modulo_y.set_input("in1", separate);
modulo_y.set_input("in2", MaterialX::Value::createValue<float>(2.0f)); modulo_y.set_input("in2", empty().val(2.0f));
modulo_y.node->setConnectedOutput("in1", separate.node->getOutput("outy")); modulo_y.node->setConnectedOutput("in1", separate.node->getOutput("outy"));
NodeItem ifequal = (modulo_x.floor() + modulo_y.floor()) NodeItem ifequal = (modulo_x.floor() + modulo_y.floor())
.if_else("==", empty().val(1.0f), empty().val(0.0f), empty().val(1.0f)); .if_else("==", empty().val(1.0f), empty().val(0.0f), empty().val(1.0f));
NodeItem res = create_node("mix", "color3", true); NodeItem res = create_node("mix", "color3", true);
NodeItem color1 = get_input_value("Color1");
NodeItem color2 = get_input_value("Color2");
res.set_input("fg", color1.to_color3()); res.set_input("fg", color1.to_color3());
res.set_input("bg", color2.to_color3()); res.set_input("bg", color2.to_color3());
res.set_input("mix", ifequal); res.set_input("mix", ifequal);
return res; return res;
} }

View File

@ -24,14 +24,14 @@ NodeItem TexNoiseNodeParser::get_input_default(const bNodeSocket &socket)
NodeItem TexNoiseNodeParser::compute() NodeItem TexNoiseNodeParser::compute()
{ {
NodeItem texcoord = create_node("position", "vector3", true);
NodeItem scale = get_input_value("Scale"); NodeItem scale = get_input_value("Scale");
NodeItem position = texcoord * scale;
NodeItem detail = get_input_value("Detail"); NodeItem detail = get_input_value("Detail");
NodeItem lacunarity = get_input_value("Lacunarity"); NodeItem lacunarity = get_input_value("Lacunarity");
NodeItem texcoord = create_node("position", "vector3", true);
NodeItem res = create_node("fractal3d", "color3", true); NodeItem res = create_node("fractal3d", "color3", true);
res.set_input("position", position); res.set_input("position", texcoord * scale);
res.set_input("octaves", detail); res.set_input("octaves", detail);
res.set_input("lacunarity", lacunarity); res.set_input("lacunarity", lacunarity);
return res; return res;