forked from blender/blender
Move the MaterialX export code into the existing shader node files #18
@ -61,6 +61,9 @@ template<class T> NodeItem NodeParser::val(const T &data) const
|
||||
return empty().val(data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Defines for including MaterialX node parsing code into node_shader_<name>.cc
|
||||
*/
|
||||
struct NodeParserData {
|
||||
MaterialX::GraphElement *graph;
|
||||
const Depsgraph *depsgraph;
|
||||
@ -69,4 +72,25 @@ struct NodeParserData {
|
||||
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
|
||||
|
@ -67,26 +67,3 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec);
|
||||
|
||||
void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node);
|
||||
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