Fix: USD: Use exr instead of hdr for world light texture
The spec for .usdz permits only a small handful of file formats to be contained in the archive, and HDR is not among those supported[1]. This also causes validation errors with the `usdchecker` tool (will be properly tested in a follow up change). Ignoring the potential for a user to export a .usdz file with materials referencing unsupported file formats, Blender itself should use only the supported formats for its business. [1] https://openusd.org/release/spec_usdz.html#usdz-specification Pull Request: https://projects.blender.org/blender/blender/pulls/144101
This commit is contained in:
committed by
Jesse Yurkovich
parent
8bf975325b
commit
2822b3badf
@@ -359,20 +359,19 @@ std::string get_image_cache_file(const std::string &file_name, bool mkdir)
|
||||
|
||||
std::string cache_image_color(const float color[4])
|
||||
{
|
||||
char name[128];
|
||||
SNPRINTF(name,
|
||||
"color_%02d%02d%02d.hdr",
|
||||
int(color[0] * 255),
|
||||
int(color[1] * 255),
|
||||
int(color[2] * 255));
|
||||
std::string name = fmt::format("color_{:02X}{:02X}{:02X}.exr",
|
||||
int(color[0] * 255),
|
||||
int(color[1] * 255),
|
||||
int(color[2] * 255));
|
||||
std::string file_path = get_image_cache_file(name);
|
||||
if (BLI_exists(file_path.c_str())) {
|
||||
return file_path;
|
||||
}
|
||||
|
||||
ImBuf *ibuf = IMB_allocImBuf(4, 4, 32, IB_float_data);
|
||||
ImBuf *ibuf = IMB_allocImBuf(1, 1, 32, IB_float_data);
|
||||
IMB_rectfill(ibuf, color);
|
||||
ibuf->ftype = IMB_FTYPE_RADHDR;
|
||||
ibuf->ftype = IMB_FTYPE_OPENEXR;
|
||||
ibuf->foptions.flag = R_IMF_EXR_CODEC_RLE;
|
||||
|
||||
if (IMB_save_image(ibuf, file_path.c_str(), IB_float_data)) {
|
||||
CLOG_INFO(&LOG, "%s", file_path.c_str());
|
||||
|
||||
Reference in New Issue
Block a user