Create parsing system that converts supported nodes and ignores unsupported #2

Merged
Bogdan Nagirniak merged 14 commits from Vasyl-Pidhirskyi/blender:BLEN-500 into matx-export-material 2023-08-28 12:29:46 +02:00
3 changed files with 15 additions and 5 deletions
Showing only changes of commit 57ec8562f5 - Show all commits

View File

@ -21,6 +21,12 @@ set(INC
${CMAKE_BINARY_DIR}/source/blender/makesrna ${CMAKE_BINARY_DIR}/source/blender/makesrna
) )
if(WITH_HYDRA)
list(APPEND INC
../../io/usd
)
add_definitions(-DWITH_HYDRA)
endif()
set(SRC set(SRC
nodes/node_shader_add_shader.cc nodes/node_shader_add_shader.cc

View File

@ -10,6 +10,8 @@
#include "NOD_shader.h" #include "NOD_shader.h"
#include "NOD_shader.h"
namespace blender::nodes::materialx { namespace blender::nodes::materialx {
static void export_nodegraph(MaterialX::DocumentPtr doc, Depsgraph *depsgraph, Material *material) static void export_nodegraph(MaterialX::DocumentPtr doc, Depsgraph *depsgraph, Material *material)
@ -33,7 +35,7 @@ static void create_standard_surface(MaterialX::DocumentPtr doc, Material *materi
->setValue(MaterialX::Color3(material->r, material->g, material->b)); ->setValue(MaterialX::Color3(material->r, material->g, material->b));
surfacematerial->addInput(standard_surface->getType(), standard_surface->getType()) surfacematerial->addInput(standard_surface->getType(), standard_surface->getType())
->setNodeName(standard_surface->getName()); ->setNodeName(standard_surface->getName());
} }
MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph, Material *material) MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph, Material *material)

View File

@ -5,6 +5,8 @@
#include "node.h" #include "node.h"
#include "image.h" #include "image.h"
#include "hydra/image.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
namespace blender::nodes::materialx { namespace blender::nodes::materialx {
@ -22,13 +24,13 @@ MaterialXTexImageNode::MaterialXTexImageNode(MaterialX::DocumentPtr doc,
MaterialX::NodePtr MaterialXTexImageNode::convert() MaterialX::NodePtr MaterialXTexImageNode::convert()
{ {
const Image *image = (Image *)node->id; Image *image = (Image *)node->id;
const NodeTexImage *tex = static_cast<NodeTexImage *>(node->storage); NodeTexImage *tex = static_cast<NodeTexImage *>(node->storage);
Scene *scene = DEG_get_input_scene(depsgraph); Scene *scene = DEG_get_input_scene(depsgraph);
Main *bmain = DEG_get_bmain(depsgraph); Main *bmain = DEG_get_bmain(depsgraph);
std::string image_path = "C:/Users/Vasyl_Pidhirskyi/Desktop/Untitled.png"; std::string image_path;
#ifdef WITH_HYDRA #ifdef WITH_HYDRA
image_path = cache_or_get_image_file(bmain, scene, image, &tex->iuser); image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
#endif #endif
MaterialX::NodePtr uv_node = doc->addNode("texcoord", MaterialX::EMPTY_STRING, "vector2"); MaterialX::NodePtr uv_node = doc->addNode("texcoord", MaterialX::EMPTY_STRING, "vector2");