forked from blender/blender
Export to MatX various Texture nodes #5
@ -152,12 +152,14 @@ if(WITH_MATERIALX)
|
||||
materialx/nodes/node_parser.cc
|
||||
materialx/nodes/output_material.cc
|
||||
materialx/nodes/tex_image.cc
|
||||
materialx/nodes/tex_environment.cc
|
||||
|
||||
materialx/material.h
|
||||
materialx/nodes/bsdf_principled.h
|
||||
materialx/nodes/node_parser.h
|
||||
materialx/nodes/output_material.h
|
||||
materialx/nodes/tex_image.h
|
||||
materialx/nodes/tex_environment.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "bsdf_principled.h"
|
||||
#include "tex_image.h"
|
||||
#include "tex_environment.h"
|
||||
|
||||
#include <BKE_node_runtime.hh>
|
||||
|
||||
@ -154,6 +155,9 @@ NodeItem NodeParser::get_input_link(const std::string &name)
|
||||
case SH_NODE_TEX_IMAGE:
|
||||
parser = std::make_unique<TexImageNodeParser>(graph, depsgraph, material, in_node);
|
||||
break;
|
||||
case SH_NODE_TEX_ENVIRONMENT:
|
||||
parser = std::make_unique<TexEnvironmentNodeParser>(graph, depsgraph, material, in_node);
|
||||
break;
|
||||
default:
|
||||
// TODO: warning log
|
||||
return res;
|
||||
|
@ -0,0 +1,34 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "tex_environment.h"
|
||||
#include "node_parser.h"
|
||||
|
||||
#include "hydra/image.h"
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
NodeItem TexEnvironmentNodeParser::compute()
|
||||
{
|
||||
Image *image = (Image *)node->id;
|
||||
NodeTexEnvironment *tex = static_cast<NodeTexEnvironment *>(node->storage);
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
Main *bmain = DEG_get_bmain(depsgraph);
|
||||
std::string image_path;
|
||||
/* TODO: What if Blender built without Hydra? Also io::hydra::cache_or_get_image_file contains
|
||||
* pretty general code, so could be moved from bf_usd project. */
|
||||
#ifdef WITH_HYDRA
|
||||
image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
|
||||
#endif
|
||||
|
||||
NodeItem texcoord = create_node("texcoord", "vector2", true);
|
||||
NodeItem res = create_node("image", "color3");
|
||||
res.set_input("file", image_path, "filename");
|
||||
res.set_input("texcoord", texcoord);
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::materialx
|
@ -0,0 +1,17 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "node_parser.h"
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
class TexEnvironmentNodeParser : public NodeParser {
|
||||
public:
|
||||
using NodeParser::NodeParser;
|
||||
NodeItem compute() override;
|
||||
};
|
||||
|
||||
} // namespace blender::nodes::materialx
|
@ -18,7 +18,7 @@ NodeItem TexImageNodeParser::compute()
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
Main *bmain = DEG_get_bmain(depsgraph);
|
||||
std::string image_path;
|
||||
/* TODO: What if Blender built without Hydra? Also io::hydra::cache_or_get_image_file contain
|
||||
/* TODO: What if Blender built without Hydra? Also io::hydra::cache_or_get_image_file contains
|
||||
* pretty general code, so could be moved from bf_usd project. */
|
||||
#ifdef WITH_HYDRA
|
||||
image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
|
||||
|
Loading…
Reference in New Issue
Block a user