Move the MaterialX export code into the existing shader node files #18

Merged
Bogdan Nagirniak merged 14 commits from BogdanNagirniak/blender:matx-move-code into matx-export-material 2023-09-12 13:55:27 +02:00
5 changed files with 32 additions and 23 deletions
Showing only changes of commit ae906b6815 - Show all commits

View File

@ -115,25 +115,4 @@ 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

View File

@ -22,6 +22,8 @@
#include "node_shader_register.hh"
#include "materialx/nodes/node_parser.h"
struct bContext;
typedef struct bContext bContext;
struct bNodeExecContext;
@ -65,3 +67,26 @@ 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(); \
}

View File

@ -22,6 +22,13 @@ static int node_shader_gpu_add_shader(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_add_shader", in, out);
}
NODE_SHADER_MATERIALX_BEGIN
{
/* TODO: Implement */
return empty();
}
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_add_shader_cc
/* node type definition */

View File

@ -4,7 +4,6 @@
#include "BLI_string.h"
#include "../materialx/nodes/node_parser.h"
#include "node_shader_util.hh"
#include "UI_interface.hh"

View File

@ -2,7 +2,6 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "../materialx/nodes/node_parser.h"
#include "node_shader_util.hh"
#include "BKE_scene.h"