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