Add IBL support #29

Merged
Bogdan Nagirniak merged 5 commits from BLEN-385 into hydra-render 2023-04-27 09:25:11 +02:00
2 changed files with 16 additions and 9 deletions
Showing only changes of commit 194f2d392d - Show all commits

View File

@ -9,6 +9,7 @@
#include <pxr/imaging/hd/light.h>
#include <pxr/imaging/hd/renderDelegate.h>
#include <pxr/imaging/hd/tokens.h>
#include <pxr/imaging/hio/imageRegistry.h>
#include <pxr/usd/usdLux/tokens.h>
#include "BKE_context.h"
@ -97,18 +98,23 @@ void WorldData::init()
NodeTexImage *tex = static_cast<NodeTexImage *>(color_input_node->storage);
Image *image = (Image *)color_input_node->id;
char image_path[1024];
Main *main = CTX_data_main(scene_delegate_->context);
if (image) {
Main *bmain = CTX_data_main(scene_delegate_->context);
Scene *scene = scene_delegate_->scene;
if (!pxr::HioImageRegistry::GetInstance().IsSupportedImageFile(image->filepath)) {
ReportList reports;
ImageSaveOptions opts;
opts.im_format.imtype = R_IMF_IMTYPE_PNG;
ReportList reports;
ImageSaveOptions opts;
opts.im_format.imtype = R_IMF_IMTYPE_PNG;
std::string image_path = cache_image(bmain, scene, image, &tex->iuser, &opts, &reports);
if (!image_path.empty()) {
data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(image_path, image_path);
strcpy(image_path,
cache_image(main, scene_delegate_->scene, image, &tex->iuser, &opts, &reports)
.c_str());
if (image_path && !image_path[0]) {
data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(image_path, image_path);
}
}
BKE_image_user_file_path_ex(main, &tex->iuser, image, image_path, false, true);
data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(image_path, image_path);
}
}
}

View File

@ -1535,6 +1535,7 @@ if((DEFINED LIBDIR) AND TARGETDIR_LIB)
)
install(DIRECTORY
${LIBDIR}/usd/plugin/usd/usdShaders
${LIBDIR}/usd/plugin/usd/hioOiio
DESTINATION "./blender.shared/usd"
)
elseif(USD_PYTHON_SUPPORT)