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

3.x: Materials generated from .gltf file are too big in filesize #34641

Open
ruki3 opened this issue Dec 27, 2019 · 22 comments
Open

3.x: Materials generated from .gltf file are too big in filesize #34641

ruki3 opened this issue Dec 27, 2019 · 22 comments

Comments

@ruki3
Copy link

ruki3 commented Dec 27, 2019

Godot version:
3.1.2

OS/device including version:
Windows 10 v1809

Issue description:
When you import fully textured .gltf scenes Godot automatically generates .material files for you. Unfortunately there's a flaw in it, because, for example - a door material is 13 mb in size while all the textures are barely 300kb in size. Also, the exported gltf is only 2,6 mb in size. Something's totally not right here.

Steps to reproduce:
Make a model in blender, make materials, export to gltf and finally import to godot.
Minimal reproduction project:

material-bug.zip

here's a screenshot of all of the wooden floor material files - they're only 718 kb in file size, while the material is 9,2 mb (!)
Screenshot_6

@Calinou
Copy link
Member

Calinou commented Dec 27, 2019

Maybe .material files are embedding textures in uncompressed form. It probably shouldn't be doing that.

@ruki3
Copy link
Author

ruki3 commented Dec 27, 2019

Is there any way to avoid that without running a custom build of Godot? I've tried messing with the model's import settings, but couldn't find anything related to texture compression.

@Calinou
Copy link
Member

Calinou commented Dec 27, 2019

cc @fire, as he has some knowledge about the glTF 2.0 importer.

@fire
Copy link
Member

fire commented Dec 28, 2019

Looking!

    "buffers" : [
        {
            "byteLength" : 1991968,
            "uri" : "data:application/octet-stream;base64,

You embedded something binary in the gltf2 file.

I would try exporting as scn to check file size. There was other comments about text formats for example base64'd png files encoded as base64 versions.

@Calinou
Copy link
Member

Calinou commented Dec 28, 2019

Indeed, text formats like .tscn and .tres will encode binary data as Base64, which is at least 33% larger than the raw binary data.

@ruki3
Copy link
Author

ruki3 commented Dec 28, 2019

I didn't embed anything in the gltf2 file, at least not on purpose. Could it be that some addons are causing the problem? I also tried disabling some functions that I don't need at the export stage (animations, skinning etc.) but it didn't reduce the size of the file. Thanks for the suggestion about the scn export, it doesn't include the textures inside the file like gltf, but at least I get to keep the size of my project small, as .dae didn't work for me aswell (I swear Godot hates me)

@aaronfranke
Copy link
Member

Any update? I have a .material file which is 41.9 MB, but the image it contains is only 170.3 kB when saved as a .png file. This is ridiculously huge.

@Calinou Calinou changed the title materials generated from .gltf file are too big in filesize Materials generated from .gltf file are too big in filesize May 11, 2020
@KoBeWi
Copy link
Member

KoBeWi commented May 11, 2020

Might be duplicate of #31632

@Bleuzen
Copy link

Bleuzen commented Sep 27, 2020

Is there any update on this? Would love to use gltf bin, but with this bug it is unusable.
As a workaround for now we can use .dae or gltf separate formats.

Here are my tests so far in different formats (all exported from Blender and imported to Godot).
I'm using this example: https://ln.sync.com/dl/41dc1c2b0/wxfm2fzf-w2ggnk53-i7eyv6zj-caq828di (from video https://www.youtube.com/watch?v=XMfiojwtuKo)

.DAE
total size: 213 kb
grafik

GLTF SEPARATE
total size: 98 kb
grafik

GLTF binary (and embedded) (only one generating the huge material):
total size: 3.1 mb
grafik

@Calinou
Copy link
Member

Calinou commented Sep 27, 2020

@Bleuzen As far as I know, nobody found a solution to this yet. Given how Godot's import system works, I'm not sure if we can even fix this at all.

Maybe the textures embedded in the .glb could be written to external PNGs/JPEGs when importing (then referenced in the .material files), but then, you have to deal with stray files from old imports and stuff like that.

@fire
Copy link
Member

fire commented Sep 27, 2020

For me using gltf where you export text gltf and the textures to a textures folder as png etc works the best.

@abrasivetroop
Copy link

abrasivetroop commented Dec 21, 2022

@Calinou Any updates on this? My .material file sizes were too big. I realized it was the textures that were too big in size and I had to go through every file and change the texture compression mode to lossless compression. By default textures imported from .gltf material files are uncompressed. If textures were lossless compressed by default this wouldn't be a huge problem.

image

Doing this reduced file sizes by 10 Mbs which also reduced scene loading times. My project size reduced by 1GB too after doing this for every material file in my project. There is no way of changing this in Import Defaults too. Sorry if I am missing something.

@KoBeWi
Copy link
Member

KoBeWi commented Dec 21, 2022

There is no way of changing this in Import Defaults too. Sorry if I am missing something.

Profile -> Set as Default in Import dock.

@abrasivetroop
Copy link

@KoBeWi I am sorry can't find the setting you are talking about

@abrasivetroop
Copy link

abrasivetroop commented Dec 21, 2022

image
@KoBeWi Are you talking about this? If so, you can't set a import default for materials that are imported with .gltf files from the import menu.

@KoBeWi
Copy link
Member

KoBeWi commented Dec 21, 2022

You mean these textures ignore defaults? Do the defaults work correctly for regular textures?

@abrasivetroop
Copy link

Yes .gltf material files import texture with no compression and they ignore the import defaults for textures. I had to manually set the textures for each material to lossless compression and I will need to do this every time I import a gltf model with embedded textures. Unless there is a way to set an import default for this :/

@fire
Copy link
Member

fire commented Dec 21, 2022

Work for this was being done in #62499

It's blocked on astc support being merged

@abrasivetroop
Copy link

@fire Awesome! When do you think this fix will be released?

@Calinou
Copy link
Member

Calinou commented Dec 21, 2022

When do you think this fix will be released?

There is no ETA, but note that ASTC support will only be added in Godot 4 – it won't be backported to 3.x.

@abrasivetroop
Copy link

There is no ETA, but note that ASTC support will only be added in Godot 4 – it won't be backported to 3.x.

I see, Godot setting built-in gltf textures to lossless compression would be enough for now. It is just a hassle manually setting all of them :/

And thanks for everyone informing me about this!

@lyuma lyuma changed the title Materials generated from .gltf file are too big in filesize 3.x: Materials generated from .gltf file are too big in filesize Dec 24, 2023
@lyuma
Copy link
Contributor

lyuma commented Dec 24, 2023

This issue was solved in time for the release of 4.0, by extracting textures from glb files. It still exists in 3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants