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());
|
||||
|
||||
@@ -1789,7 +1789,7 @@ class USDImportTest(AbstractUSDTest):
|
||||
self.assertEqual({'FINISHED'}, res, f"Unable to export to {usdz2}")
|
||||
|
||||
def check_image(name, tiles_num, size, is_packed):
|
||||
self.assertTrue(name in bpy.data.images)
|
||||
self.assertTrue(name in bpy.data.images, f"Could not find '{name}'")
|
||||
|
||||
image = bpy.data.images[name]
|
||||
self.assertEqual(len(image.tiles), tiles_num)
|
||||
@@ -1816,7 +1816,7 @@ class USDImportTest(AbstractUSDTest):
|
||||
check_image("test_grid_<UDIM>.png", 2, 1024, True)
|
||||
check_image("test_normal.exr", 1, 128, True)
|
||||
check_image("test_normal_invertY.exr", 1, 128, True)
|
||||
check_image("color_121212.hdr", 1, 4, True)
|
||||
check_image("color_0C0C0C.exr", 1, 1, True)
|
||||
check_materials()
|
||||
|
||||
# Reload the empty file and import back in using IMPORT_COPY
|
||||
@@ -1832,7 +1832,7 @@ class USDImportTest(AbstractUSDTest):
|
||||
check_image("test_grid_<UDIM>.png", 2, 128, False)
|
||||
check_image("test_normal.exr", 1, 128, False)
|
||||
check_image("test_normal_invertY.exr", 1, 128, False)
|
||||
check_image("color_121212.hdr", 1, 4, False)
|
||||
check_image("color_0C0C0C.exr", 1, 1, False)
|
||||
check_materials()
|
||||
|
||||
def test_get_prim_map_parent_xform_not_merged(self):
|
||||
|
||||
Reference in New Issue
Block a user