Fix #145711: Packed images may fail to export with USD
Certain packed images, like those loaded directly into memory with `BKE_image_packfiles_from_mem`, would cause USD to process the images as "in memory" rather than as "packed" because the API was not removing the IMG_GEN_TILE flag. Additionally, be sure to use the packed filepath whenever possible rather than the name given to the Image datablock as this ensures the correct file names are used inside the USD file and for the resulting file on disk after export. This also fixes 2 render tests which now match when compared to the native renders. Pull Request: https://projects.blender.org/blender/blender/pulls/145749
This commit is contained in:
committed by
Jesse Yurkovich
parent
6a083a5464
commit
3e3ee35e9d
@@ -1527,6 +1527,10 @@ void BKE_image_packfiles_from_mem(ReportList *reports,
|
||||
imapf->view = 0;
|
||||
imapf->tile_number = 1001;
|
||||
STRNCPY(imapf->filepath, ima->filepath);
|
||||
|
||||
/* The image should not be marked as "generated" since image data was provided. */
|
||||
ImageTile *base_tile = BKE_image_get_tile(ima, 0);
|
||||
base_tile->gen_flag &= ~IMA_GEN_TILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -784,6 +784,14 @@ static std::string get_in_memory_texture_filename(Image *ima)
|
||||
BKE_image_release_ibuf(ima, imbuf, nullptr);
|
||||
|
||||
char file_name[FILE_MAX];
|
||||
|
||||
/* NOTE: Any changes in packed filepath handling here should be considered alongside potential
|
||||
* changes in `export_packed_texture`. The file name returned needs to match. */
|
||||
if (is_packed && ima->filepath[0] != '\0') {
|
||||
BLI_path_split_file_part(ima->filepath, file_name, FILE_MAX);
|
||||
return file_name;
|
||||
}
|
||||
|
||||
/* Use the image name for the file name. */
|
||||
STRNCPY(file_name, ima->id.name + 2);
|
||||
|
||||
|
||||
BIN
tests/files/render/image_mapping/storm_usd_renders/image_mapping_udim_packed.png
(Stored with Git LFS)
BIN
tests/files/render/image_mapping/storm_usd_renders/image_mapping_udim_packed.png
(Stored with Git LFS)
Binary file not shown.
BIN
tests/files/render/shader/storm_usd_renders/glossy_normal_map.png
(Stored with Git LFS)
BIN
tests/files/render/shader/storm_usd_renders/glossy_normal_map.png
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user