forked from blender/blender
matx-extend-create_node #25
@ -98,7 +98,7 @@ NodeItem GroupOutputNodeParser::compute_full()
|
||||
res = compute();
|
||||
return res;
|
||||
#else
|
||||
return NodeParser::compute_full();
|
||||
return compute();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ NodeItem GroupInputNodeParser::compute_full()
|
||||
res = compute();
|
||||
return res;
|
||||
#else
|
||||
return NodeParser::compute_full();
|
||||
return compute();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,10 @@
|
||||
|
||||
#include "IMB_colormanagement.h"
|
||||
|
||||
#include "hydra/image.h"
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
namespace blender::nodes::node_shader_tex_environment_cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
@ -130,8 +134,50 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat,
|
||||
NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
/* TODO: Implement */
|
||||
return empty();
|
||||
NodeItem res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
|
||||
Image *image = (Image *)node_->id;
|
||||
if (!image) {
|
||||
return res;
|
||||
}
|
||||
|
||||
NodeTexEnvironment *tex_env = static_cast<NodeTexEnvironment *>(node_->storage);
|
||||
Scene *scene = DEG_get_input_scene(depsgraph_);
|
||||
Main *bmain = DEG_get_bmain(depsgraph_);
|
||||
|
||||
/* 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. */
|
||||
std::string image_path = io::hydra::cache_or_get_image_file(
|
||||
bmain, scene, image, &tex_env->iuser);
|
||||
|
||||
NodeItem vector = get_input_link("Vector", NodeItem::Type::Vector2);
|
||||
if (!vector) {
|
||||
vector = texcoord_node();
|
||||
}
|
||||
/* TODO: texcoords should be translated to spherical coordinates */
|
||||
|
||||
std::string filtertype;
|
||||
switch (tex_env->interpolation) {
|
||||
case SHD_INTERP_LINEAR:
|
||||
filtertype = "linear";
|
||||
break;
|
||||
case SHD_INTERP_CLOSEST:
|
||||
filtertype = "closest";
|
||||
break;
|
||||
case SHD_INTERP_CUBIC:
|
||||
case SHD_INTERP_SMART:
|
||||
filtertype = "cubic";
|
||||
break;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
|
||||
res = create_node("image", NodeItem::Type::Color4);
|
||||
res.set_input("file", image_path, NodeItem::Type::Filename);
|
||||
res.set_input("texcoord", vector);
|
||||
res.set_input("filtertype", val(filtertype));
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
@ -179,7 +179,14 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
|
||||
NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
NodeItem res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
/* Getting node name for Color output. This name will be used for <image> node. */
|
||||
std::string image_node_name = node_name();
|
||||
image_node_name = image_node_name.substr(0, image_node_name.rfind('_')) + "_Color";
|
||||
|
||||
NodeItem res = empty();
|
||||
res.node = graph_->getNode(image_node_name);
|
||||
if (!res.node) {
|
||||
res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
|
||||
Image *image = (Image *)node_->id;
|
||||
if (image) {
|
||||
@ -187,8 +194,8 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
Scene *scene = DEG_get_input_scene(depsgraph_);
|
||||
Main *bmain = DEG_get_bmain(depsgraph_);
|
||||
|
||||
/* 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. */
|
||||
/* 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. */
|
||||
std::string image_path = io::hydra::cache_or_get_image_file(
|
||||
bmain, scene, image, &tex_image->iuser);
|
||||
|
||||
@ -238,6 +245,8 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
{"uaddressmode", val(addressmode)},
|
||||
{"vaddressmode", val(addressmode)}});
|
||||
res.set_input("file", image_path, NodeItem::Type::Filename);
|
||||
res.node->setName(image_node_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (STREQ(socket_out_->name, "Alpha")) {
|
||||
|
Loading…
Reference in New Issue
Block a user