forked from blender/blender
Move the MaterialX export code into the existing shader node files #18
@ -18,7 +18,7 @@ namespace blender::nodes::materialx {
|
|||||||
class DefaultMaterialNodeParser : public NodeParser {
|
class DefaultMaterialNodeParser : public NodeParser {
|
||||||
public:
|
public:
|
||||||
using NodeParser::NodeParser;
|
using NodeParser::NodeParser;
|
||||||
|
|
||||||
NodeItem compute() override
|
NodeItem compute() override
|
||||||
{
|
{
|
||||||
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
||||||
|
@ -61,6 +61,9 @@ template<class T> NodeItem NodeParser::val(const T &data) const
|
|||||||
return empty().val(data);
|
return empty().val(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defines for including MaterialX node parsing code into node_shader_<name>.cc
|
||||||
|
*/
|
||||||
struct NodeParserData {
|
struct NodeParserData {
|
||||||
MaterialX::GraphElement *graph;
|
MaterialX::GraphElement *graph;
|
||||||
const Depsgraph *depsgraph;
|
const Depsgraph *depsgraph;
|
||||||
@ -69,4 +72,25 @@ struct NodeParserData {
|
|||||||
NodeItem result;
|
NodeItem result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define NODE_SHADER_MATERIALX_BEGIN \
|
||||||
|
class MaterialXNodeParser : public materialx::NodeParser { \
|
||||||
|
public: \
|
||||||
|
using materialx::NodeParser::NodeParser; \
|
||||||
|
materialx::NodeItem compute() override; \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
materialx::NodeItem MaterialXNodeParser::compute() \
|
||||||
|
{ \
|
||||||
|
using NodeItem = materialx::NodeItem;
|
||||||
|
|
||||||
|
#define NODE_SHADER_MATERIALX_END \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
void node_shader_materialx(void *data, struct bNode *node, struct bNodeSocket *out) \
|
||||||
|
{ \
|
||||||
|
materialx::NodeParserData *d = reinterpret_cast<materialx::NodeParserData *>(data); \
|
||||||
|
d->result = MaterialXNodeParser(d->graph, d->depsgraph, d->material, node, out, d->to_type) \
|
||||||
|
.compute_full(); \
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender::nodes::materialx
|
} // namespace blender::nodes::materialx
|
||||||
|
@ -67,26 +67,3 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec);
|
|||||||
|
|
||||||
void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node);
|
void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node);
|
||||||
void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data);
|
void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data);
|
||||||
|
|
||||||
/* ********* MaterialX defines *********** */
|
|
||||||
|
|
||||||
#define NODE_SHADER_MATERIALX_BEGIN \
|
|
||||||
class MaterialXNodeParser : public materialx::NodeParser { \
|
|
||||||
public: \
|
|
||||||
using materialx::NodeParser::NodeParser; \
|
|
||||||
materialx::NodeItem compute() override; \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
materialx::NodeItem MaterialXNodeParser::compute() \
|
|
||||||
{ \
|
|
||||||
using NodeItem = materialx::NodeItem;
|
|
||||||
|
|
||||||
#define NODE_SHADER_MATERIALX_END \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void node_shader_materialx(void *data, struct bNode *node, struct bNodeSocket *out) \
|
|
||||||
{ \
|
|
||||||
materialx::NodeParserData *d = reinterpret_cast<materialx::NodeParserData *>(data); \
|
|
||||||
d->result = MaterialXNodeParser(d->graph, d->depsgraph, d->material, node, out, d->to_type) \
|
|
||||||
.compute_full(); \
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user