Blend file import: Don't keep original files when not unpacking them #96782
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Draft because this depends on PR #96778. Fixes #82455 assuming it is acceptable to require users to uncheck a box.
In the current master, the Blend file import code always keeps the original files, and there is a checkbox to control if the original textures are unpacked. By default, the checkbox is checked, which unpacks the original textures, imports them, and uses them. However, this is not always the correct behavior, as pointed out in #82455 sometimes the correct textures are not the originals. If the user unchecks this box, then the original textures are not unpacked, but it still tries to keep using them, resulting in the textures simply being missing.
With this PR, the behavior of having the checkbox unchecked is different. Now when it is unchecked, keep originals will also be set to false, allowing Blender to convert textures as needed. For example, re-packing roughness and metallic into one roughness+metallic texture. This means that when the checkbox is unchecked, instead of failing to import the textures, it will successfully import.
Ideally, it would be nice if we could just have keep originals set to false, letting Blender do whatever conversion it needs when it needs it to make the textures correct, and then have the unpack checkbox only control whether those correct textures are saved in the project or not. However, it does not seem that Blender has an option for unpacking the altered textures, only the originals. I dug around the Blender glTF export code for a few hours and I was not able to figure it out. Regardless, if we do figure that out, this PR does not prevent doing so in the future. It would also be nice if there was a way to detect when a texture needs conversion, and convert it anyway, even if the arguments were to keep the originals (better to convert than to export a broken file). However, the Blender code has a warning in it already for this case, so I think it's intentionally not supported. All that said, this PR is the best solution I can come up with unless we want to modify Blender or do some weird hacks on our end.