Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blend file import: Don't keep original files when not unpacking them #96782

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Sep 10, 2024

Draft because this depends on PR #96778. Fixes #82455 assuming it is acceptable to require users to uncheck a box.

Screenshot 2024-09-10 at 2 32 37 AM

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.

@fire
Copy link
Member

fire commented Sep 10, 2024

The design goals for the blender importer is that we keep the image originals and @reduz made great effort to request this several years ago.

  • we can fail the blender import
  • we can apply this pr
  • ???

@aaronfranke
Copy link
Member Author

@fire It still does keep the original images by default, but if the original files do not comply with the glTF specification, then the original images will not function correctly (the material will look wrong). Therefore, this PR allows the user to choose not to keep the originals by unchecking the box to unpack them.

@aaronfranke aaronfranke force-pushed the blend-fix-rough-metallic-if-not-unpack branch from d7d5f55 to 11cf684 Compare October 30, 2024 10:07
@aaronfranke aaronfranke force-pushed the blend-fix-rough-metallic-if-not-unpack branch from 11cf684 to 109bee0 Compare November 5, 2024 12:01
@fire
Copy link
Member

fire commented Nov 5, 2024

Why is this in draft mode?

@aaronfranke aaronfranke marked this pull request as ready for review November 8, 2024 01:41
@aaronfranke aaronfranke requested a review from a team as a code owner November 8, 2024 01:41
@aaronfranke aaronfranke modified the milestones: 4.x, 4.4 Nov 8, 2024
@akien-mga akien-mga merged commit 2669f19 into godotengine:master Nov 29, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@aaronfranke aaronfranke deleted the blend-fix-rough-metallic-if-not-unpack branch November 29, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing .blend file results in Roughness texture being used as Metallic texture
3 participants