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

glTF file import creates files that are too large #71538

Closed
gelvinp opened this issue Jan 17, 2023 · 5 comments · Fixed by #76630
Closed

glTF file import creates files that are too large #71538

gelvinp opened this issue Jan 17, 2023 · 5 comments · Fixed by #76630

Comments

@gelvinp
Copy link
Contributor

gelvinp commented Jan 17, 2023

Godot version

4.0 noticed since beta 4

System information

Windows 10 and Arch Linux

Issue description

When importing a glb or gltf file, the .scn file created in .godot/imported is much much larger than creating a new inherited scene, clearing inheritance (so the scene contains all the mesh information), and saving that as a .scn manually.

I've noticed this in my own projects, where manually creating a .scn file by clearing inheritance results in a file that is 60 KB, whereas the .scn file created by godot in the .godot/imported folder is 3.1 MB, 50 times larger. In this same project, adding together the file sizes of all the .scn files created by importing either a .glb or .gltf file shows that there are 700 MB of .scn files. The entire size of my assets folder including textures and audio is only 192 MB. By manually turning every glb or gltf file into a .scn by clearing inheritance, and then excluding *.glb and *.gltf resources in my export profile, I can bring my pck down from 767 MB to 73 MB, a 10 times reduction in size.

Steps to reproduce

  1. Open blender, and export a default cube as a gltf or glb into a Godot project.

  2. Open Godot, importing the model. Navigate to .godot/imported and notice the size of the created .scn file.
    image

  3. Right click on the gltf file in Godot, choose "New inherited scene". Save this scene as a .scn file. Then, right click on the root node and select "Clear inheritance", and save again. Notice the size of this .scn file.
    image
    In this example, the file I created is 2.6 times smaller.

  4. Go to the scene menu, and choose "Save Scene As", saving it as a .tscn file. Notice the size of the file.
    image
    The .tscn file is smaller than the .scn file created by Godot, even though it is text based and not binary and thus should be larger.

  5. Navigate to the .godot/imported directory and copy the created .scn file into your Godot project. Open the .scn file in the editor, and as in step 4, save it as a .tscn file as well. Note the file size.
    image
    Notice that now, it is the same size as the .tscn file I created in step 4.

  6. Diff these two .tscn files together.
    image
    Notice that the only difference between the file created manually by making a new scene and clearing inheritance, and the file created automatically by Godot on import, is the uid assigned to the scene. Therefore, there has been zero loss of content or functionality to explain why the .scn created manually is 2.6 times smaller.

  7. Reopen the .scn file created automatically by Godot during import, and "Save Scene As" again, but this time, continue to save it as a .scn file, just with a new name. Note the file size.
    image
    Even though no modifications were made to the file, and it was simply resaved into the same file format, it is still 2.6 times smaller than the file created automatically by Godot.

Minimal reproduction project

gltf.zip

@gelvinp
Copy link
Contributor Author

gelvinp commented Jan 17, 2023

As an aside, opening up the automatically generated .scn file in a text editor shows that, unlike scenes manually saved as a .scn file, the imported scene is largely text:
image

@akien-mga akien-mga added this to the 4.0 milestone Jan 17, 2023
@lyuma
Copy link
Contributor

lyuma commented Feb 18, 2023

Is this still an issue in 4.0 rc2?

We now extract textures by default in glb files.
If textures are extracted, does this issue no longer happen?

@gelvinp
Copy link
Contributor Author

gelvinp commented Feb 18, 2023

Is this still an issue in 4.0 rc2?

We now extract textures by default in glb files. If textures are extracted, does this issue no longer happen?

I would assume so, but I will check right now (EDIT: Yes, it is still the case.)

In the steps that I outlined in my issue, there were no textures to extract. The difference likely comes down to the file format used. The automatically imported scenes start with a "RSRC" header, and have the ascii string "PackedScene" near the top of the file, while the manually saved scenes start with a "RSCC" header (compressed?), and have no apparent ascii strings.

@gelvinp gelvinp closed this as completed Feb 18, 2023
@gelvinp gelvinp reopened this Feb 18, 2023
@gelvinp
Copy link
Contributor Author

gelvinp commented Feb 18, 2023

(Ignore the closed issue, clicked the wrong button)

@Calinou
Copy link
Member

Calinou commented Jun 18, 2023

I can confirm this on 4.1.dev 33957ae (Linux).

@akien-mga akien-mga changed the title [4.0] gLTF file import creates files that are too large glTF file import creates files that are too large Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants