Support EnvironmentTexture node for world #59

Merged
Bogdan Nagirniak merged 4 commits from BLEN-400 into hydra-render 2023-07-02 14:09:45 +02:00
2 changed files with 12 additions and 10 deletions

View File

@ -40,8 +40,12 @@ static std::string cache_image_file(Image *image,
ImageSaveOptions opts;
if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) {
char file_name[32];
const char *r_ext;
BKE_image_path_ext_from_imformat(&scene->r.im_format, &r_ext);
const char *r_ext = BLI_path_extension_or_end(image->id.name);
if (!pxr::HioImageRegistry::GetInstance().IsSupportedImageFile(image->id.name)) {
BKE_image_path_ext_from_imformat(&scene->r.im_format, &r_ext);
opts.im_format = scene->r.im_format;
}
snprintf(file_name, sizeof(file_name), "img_%016llx%s", (uintptr_t)image, r_ext);
file_path = get_cache_file(file_name);

View File

@ -90,7 +90,7 @@ void WorldData::init()
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) {
if (ELEM(color_input_node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
NodeTexImage *tex = static_cast<NodeTexImage *>(color_input_node->storage);
Image *image = (Image *)color_input_node->id;
if (image) {
@ -176,13 +176,11 @@ void WorldData::write_transform()
{
transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
/* TODO : do this check via RenderSettings*/
if (scene_delegate_->engine->render_delegate_name == "HdRprPlugin") {
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),
pxr::GfVec3d());
}
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),
pxr::GfVec3d());
}
} // namespace blender::render::hydra