Fix DomeLight warning in console for Storm delegate. #55

Merged
Bogdan Nagirniak merged 5 commits from BLEN-432 into hydra-render 2023-06-13 19:13:36 +02:00
3 changed files with 13 additions and 5 deletions
Showing only changes of commit a64d2dcf61 - Show all commits

View File

@ -18,7 +18,8 @@
namespace blender::render::hydra {
static std::string get_cache_file(const std::string &file_name, bool mkdir=true) {
static std::string get_cache_file(const std::string &file_name, bool mkdir = true)
{
char dir_path[FILE_MAX];
BLI_path_join(dir_path, sizeof(dir_path), BKE_tempdir_session(), "hydra_image_cache");
if (mkdir) {
@ -89,9 +90,16 @@ std::string cache_or_get_image_file(Image *image,
return file_path;
}
std::string cache_image_color(float color[4], const std::string &name)
std::string cache_image_color(float color[4])
{
std::string file_path = get_cache_file(name + ".hdr");
char name[128];
snprintf(name,
sizeof(name),
"color_%02x%02x%02x.hdr",
int(color[0] * 255),
int(color[1] * 255),
int(color[2] * 255));
std::string file_path = get_cache_file(name);
ImBuf *ibuf = IMB_allocImBuf(4, 4, 32, IB_rectfloat);
IMB_rectfill(ibuf, color);

View File

@ -13,6 +13,6 @@ class BlenderSceneDelegate;
std::string cache_or_get_image_file(Image *image,
BlenderSceneDelegate *scene_delegate,
ImageUser *iuser);
std::string cache_image_color(float color[4], const std::string &name);
std::string cache_image_color(float color[4]);
} // namespace blender::render::hydra

View File

@ -104,7 +104,7 @@ void WorldData::init()
if (data_.find(pxr::HdLightTokens->textureFile) == data_.end()) {
pxr::GfVec3f c = data_[pxr::HdLightTokens->color].Get<pxr::GfVec3f>();
float color[4] = {c[0], c[1], c[2], 1.0f};
std::string image_path = cache_image_color(color, "world");
std::string image_path = cache_image_color(color);
data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(image_path, image_path);
}
}