forked from blender/blender
BLEN-335: Export environment light #1
@ -318,6 +318,12 @@ void BlenderSceneDelegate::Populate(BL::Depsgraph &b_deps, View3D *v3d)
|
||||
add_world(view3d->shading, *world);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id.is_a(&RNA_ShaderNodeTree)) {
|
||||
World *world = (World *)b_depsgraph->scene().world().ptr.data;
|
||||
add_world(view3d->shading, *world);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_update_collection) {
|
||||
|
@ -8,16 +8,18 @@
|
||||
#include <pxr/usd/usdLux/tokens.h>
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_node_runtime.hh"
|
||||
#include "BKE_image.h"
|
||||
#include "NOD_shader.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "world.h"
|
||||
|
||||
/* TODO : add tftoken "transparency" and RPR specific? */
|
||||
/* TODO : add custom tftoken "transparency"? */
|
||||
|
||||
using namespace pxr;
|
||||
using namespace std;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
@ -72,6 +74,8 @@ void WorldData::update_world()
|
||||
|
||||
void WorldData::set_as_world()
|
||||
{
|
||||
data.clear();
|
||||
|
||||
if (world->use_nodes) {
|
||||
|
||||
bNode *output_node = ntreeShaderOutputNode(world->nodetree, SHD_OUTPUT_ALL);
|
||||
@ -82,13 +86,21 @@ void WorldData::set_as_world()
|
||||
bNodeSocket color_input = input_node->input_by_identifier("Color");
|
||||
bNodeSocket strength_input = input_node->input_by_identifier("Strength");
|
||||
|
||||
BogdanNagirniak marked this conversation as resolved
|
||||
float const *color = color_input.default_value_typed<float>();
|
||||
float const *strength = strength_input.default_value_typed<float>();
|
||||
|
||||
float const *color = color_input.default_value_typed<float>();
|
||||
data[HdLightTokens->intensity] = strength[1];
|
||||
data[HdLightTokens->exposure] = 1.0f;
|
||||
data[HdLightTokens->color] = GfVec3f(color[0], color[1], color[2]);
|
||||
|
||||
DagerD marked this conversation as resolved
Bogdan Nagirniak
commented
`string const &`
|
||||
if (!color_input.directly_linked_links().is_empty()) {
|
||||
bNode *color_input_node = color_input.directly_linked_links()[0]->fromnode;
|
||||
if (color_input_node->type == SH_NODE_TEX_IMAGE) {
|
||||
data[HdLightTokens->textureFile] = SdfAssetPath(
|
||||
"C:\\Users\\user\\Desktop\\WUH6nAqWDDk.jpg",
|
||||
"C:\\Users\\user\\Desktop\\WUH6nAqWDDk.jpg"); // get_image_filepath(color_input_node);
|
||||
}
|
||||
}
|
||||
|
||||
//blender::Span<bNode *> world_nodes = world->nodetree->nodes_by_type("ShaderNodeOutputWorld");
|
||||
}
|
||||
else {
|
||||
@ -113,4 +125,38 @@ void WorldData::set_as_shading()
|
||||
);
|
||||
}
|
||||
|
||||
string WorldData::get_image_filepath(const bNode *tex_node)
|
||||
{
|
||||
if (!tex_node) {
|
||||
return "";
|
||||
}
|
||||
Image *tex_image = reinterpret_cast<Image *>(tex_node->id);
|
||||
if (!tex_image || !BKE_image_has_filepath(tex_image)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (BKE_image_has_packedfile(tex_image)) {
|
||||
/* Put image in the same directory as the .MTL file. */
|
||||
const char *filename = BLI_path_slash_rfind(tex_image->filepath) + 1;
|
||||
fprintf(stderr,
|
||||
"Packed image found:'%s'. Unpack and place the image in the same "
|
||||
"directory as the .MTL file.\n",
|
||||
filename);
|
||||
return filename;
|
||||
}
|
||||
|
||||
char path[FILE_MAX];
|
||||
BLI_strncpy(path, tex_image->filepath, FILE_MAX);
|
||||
|
||||
if (tex_image->source == IMA_SRC_SEQUENCE) {
|
||||
char head[FILE_MAX], tail[FILE_MAX];
|
||||
ushort numlen;
|
||||
int framenr = static_cast<NodeTexImage *>(tex_node->storage)->iuser.framenr;
|
||||
BLI_path_sequence_decode(path, head, tail, &numlen);
|
||||
BLI_path_sequence_encode(path, head, tail, numlen, framenr);
|
||||
}
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <map>
|
||||
|
||||
#include <pxr/base/gf/matrix4d.h>
|
||||
#include <pxr/usd/sdf/assetPath.h>
|
||||
#include <pxr/usd/sdf/path.h>
|
||||
#include <pxr/base/vt/value.h>
|
||||
#include "pxr/base/tf/staticTokens.h"
|
||||
@ -40,6 +41,7 @@ public:
|
||||
|
||||
void set_as_world();
|
||||
void set_as_shading();
|
||||
std::string get_image_filepath(const bNode *tex_node);
|
||||
};
|
||||
|
||||
BogdanNagirniak marked this conversation as resolved
Bogdan Nagirniak
commented
remove unused methods remove unused methods
|
||||
template<class T>
|
||||
|
Loading…
Reference in New Issue
Block a user
move to constructor