forked from blender/blender
Export to MatX various Texture nodes #5
@ -60,6 +60,15 @@ template<class T> NodeItem NodeParser::value(const T &data) const
|
|||||||
NodeItem compute() override; \
|
NodeItem compute() override; \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define DECLARE_PARSER_OVERRIDE(T) \
|
||||||
|
class T : public NodeParser { \
|
||||||
|
public: \
|
||||||
|
using NodeParser::NodeParser; \
|
||||||
|
NodeItem compute() override; \
|
||||||
|
protected: \
|
||||||
|
NodeItem get_input_default(const bNodeSocket &socket) override; \
|
||||||
|
};
|
||||||
|
|
||||||
DECLARE_PARSER(BSDFPrincipledNodeParser)
|
DECLARE_PARSER(BSDFPrincipledNodeParser)
|
||||||
DECLARE_PARSER(InvertNodeParser)
|
DECLARE_PARSER(InvertNodeParser)
|
||||||
DECLARE_PARSER(MathNodeParser)
|
DECLARE_PARSER(MathNodeParser)
|
||||||
@ -67,23 +76,7 @@ DECLARE_PARSER(MixRGBNodeParser)
|
|||||||
DECLARE_PARSER(OutputMaterialNodeParser)
|
DECLARE_PARSER(OutputMaterialNodeParser)
|
||||||
DECLARE_PARSER(TexImageNodeParser)
|
DECLARE_PARSER(TexImageNodeParser)
|
||||||
DECLARE_PARSER(TexEnvironmentNodeParser)
|
DECLARE_PARSER(TexEnvironmentNodeParser)
|
||||||
|
DECLARE_PARSER_OVERRIDE(TexNoiseNodeParser)
|
||||||
class TexNoiseNodeParser : public NodeParser {
|
DECLARE_PARSER_OVERRIDE(TexCheckerNodeParser)
|
||||||
public:
|
|
||||||
using NodeParser::NodeParser;
|
|
||||||
NodeItem compute() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
NodeItem get_input_default(const bNodeSocket &socket) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TexCheckerNodeParser : public NodeParser {
|
|
||||||
public:
|
|
||||||
using NodeParser::NodeParser;
|
|
||||||
NodeItem compute() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
NodeItem get_input_default(const bNodeSocket &socket) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace blender::nodes::materialx
|
} // namespace blender::nodes::materialx
|
||||||
|
@ -33,15 +33,11 @@ NodeItem TexCheckerNodeParser::compute()
|
|||||||
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 mult = create_node("multiply", "vector2", true);
|
|
||||||
mult.set_input("in1", texcoord);
|
|
||||||
mult.set_input("in2", frequency);
|
|
||||||
|
|
||||||
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", MaterialX::Value::createValue<MaterialX::Vector2>({0.0f, 0.0f}));
|
||||||
|
|
||||||
NodeItem place2d = create_node("place2d", "vector2", true);
|
NodeItem place2d = create_node("place2d", "vector2", true);
|
||||||
place2d.set_input("texcoord", mult);
|
place2d.set_input("texcoord", texcoord * frequency);
|
||||||
place2d.set_input("offset", offset);
|
place2d.set_input("offset", offset);
|
||||||
|
|
||||||
NodeItem separate = create_node("separate2", "multioutput", true);
|
NodeItem separate = create_node("separate2", "multioutput", true);
|
||||||
@ -54,26 +50,13 @@ NodeItem TexCheckerNodeParser::compute()
|
|||||||
modulo_x.set_input("in2", MaterialX::Value::createValue<float>(2.0f));
|
modulo_x.set_input("in2", MaterialX::Value::createValue<float>(2.0f));
|
||||||
modulo_x.node->setConnectedOutput("in1", separate.node->getOutput("outx"));
|
modulo_x.node->setConnectedOutput("in1", separate.node->getOutput("outx"));
|
||||||
|
|
||||||
NodeItem floor_x = create_node("floor", "float", true);
|
|
||||||
floor_x.set_input("in", modulo_x);
|
|
||||||
|
|
||||||
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", MaterialX::Value::createValue<float>(2.0f));
|
||||||
modulo_y.node->setConnectedOutput("in1", separate.node->getOutput("outy"));
|
modulo_y.node->setConnectedOutput("in1", separate.node->getOutput("outy"));
|
||||||
|
|
||||||
NodeItem floor_y = create_node("floor", "float", true);
|
NodeItem ifequal = (modulo_x.floor() + modulo_y.floor())
|
||||||
floor_y.set_input("in", modulo_y);
|
.if_else("==", empty().val(1.0f), empty().val(0.0f), empty().val(1.0f));
|
||||||
|
|
||||||
NodeItem add = create_node("add", "float", true);
|
|
||||||
add.set_input("in1", floor_x);
|
|
||||||
add.set_input("in2", floor_y);
|
|
||||||
|
|
||||||
NodeItem ifequal = create_node("ifequal", "float", true);
|
|
||||||
ifequal.set_input("value1", add);
|
|
||||||
ifequal.set_input("value2", MaterialX::Value::createValue<float>(1.0f));
|
|
||||||
ifequal.set_input("in1", MaterialX::Value::createValue<float>(0.0f));
|
|
||||||
ifequal.set_input("in2", MaterialX::Value::createValue<float>(1.0f));
|
|
||||||
|
|
||||||
NodeItem res = create_node("mix", "color3", true);
|
NodeItem res = create_node("mix", "color3", true);
|
||||||
NodeItem color1 = get_input_value("Color1");
|
NodeItem color1 = get_input_value("Color1");
|
||||||
|
Loading…
Reference in New Issue
Block a user