forked from blender/blender
Fix DomeLight warning in console for Storm delegate. #55
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
namespace blender::render::hydra {
|
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];
|
char dir_path[FILE_MAX];
|
||||||
BLI_path_join(dir_path, sizeof(dir_path), BKE_tempdir_session(), "hydra_image_cache");
|
BLI_path_join(dir_path, sizeof(dir_path), BKE_tempdir_session(), "hydra_image_cache");
|
||||||
if (mkdir) {
|
if (mkdir) {
|
||||||
@ -89,9 +90,16 @@ std::string cache_or_get_image_file(Image *image,
|
|||||||
return file_path;
|
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);
|
ImBuf *ibuf = IMB_allocImBuf(4, 4, 32, IB_rectfloat);
|
||||||
IMB_rectfill(ibuf, color);
|
IMB_rectfill(ibuf, color);
|
||||||
|
@ -13,6 +13,6 @@ class BlenderSceneDelegate;
|
|||||||
std::string cache_or_get_image_file(Image *image,
|
std::string cache_or_get_image_file(Image *image,
|
||||||
BlenderSceneDelegate *scene_delegate,
|
BlenderSceneDelegate *scene_delegate,
|
||||||
ImageUser *iuser);
|
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
|
} // namespace blender::render::hydra
|
||||||
|
@ -104,7 +104,7 @@ void WorldData::init()
|
|||||||
if (data_.find(pxr::HdLightTokens->textureFile) == data_.end()) {
|
if (data_.find(pxr::HdLightTokens->textureFile) == data_.end()) {
|
||||||
pxr::GfVec3f c = data_[pxr::HdLightTokens->color].Get<pxr::GfVec3f>();
|
pxr::GfVec3f c = data_[pxr::HdLightTokens->color].Get<pxr::GfVec3f>();
|
||||||
float color[4] = {c[0], c[1], c[2], 1.0f};
|
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);
|
data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(image_path, image_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user