godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.79k stars 3.08k forks source link

.tscn's are not imported as .scn despite documentation stating otherwise #4289

Open USBDongleGoblin opened 3 years ago

USBDongleGoblin commented 3 years ago

Godot version: 3.2.3

OS/device including version: Windows 10

Issue description: The Godot docs state that any .tscn is imported as .scn to save space and decrease load times. This only seems to be true for .escn.

Steps to reproduce: I've tested this by exporting a project. Once with a comically large .tscn (thanks BakedLightmap) and again with a .scn counterpart. The one with the .tscn was larger than the one with the .scn. I've included that here. (You'll have to manually export it yourself as GitHub doesn't like files bigger than 10mb [preferably with export all])

Minimal reproduction project: BigScene.zip

KoBeWi commented 3 years ago

The Godot docs state that any .tscn is imported as .scn to save space and decrease load times. This only seems to be true for .escn.

Where? Please give link to the doc. This is not true, only escns are imported, because it's a scene format specifically for 3D models. But it's true about exports, tscns are converted to scn on project export.

smix8 commented 3 years ago

I think this could be the doc part that is not clear enough. https://docs.godotengine.org/en/latest/development/file_formats/tscn.html

The TSCN (text scene) file format represents a single scene tree inside Godot. TSCN files have the advantage of being mostly human-readable and easy for version control systems to manage. During import, TSCN files are compiled into binary .scn files stored inside the .import folder. This reduces the data size and speeds up loading.

It never converts the entire (slow and large) TSCN file to SCN to reduce filesize and loading times while developing with the editor. Also only (sub) resources are saved optimized in the .import folder but not the TSCN file. I think this is the important part of information that is missing for users.

This is not very noticeable on small 2D scenes but very noticeable with more detailed 3D models where a lot of (inspector) data is saved directly in the TSCN file and not in the .import (sub)resources. The same asset as a TSCN file can be 10x+ larger than SCN and take a few seconds extra to load in both editor and ingame while testing the game.

Also "Convert Text Resources to Binary on Export" is turned off by default in the Godot 3.2.3 editor. It should be on by default to protect the common user.

KoBeWi commented 3 years ago

Ok so this doc page is either wrong or outdated (and wrong). Also it's not class reference issue, so I'm transferring it.

akien-mga commented 3 years ago

It seems to be a typo, if you replace "import" by "export" it's correct (as long as the export preset is configured to converted scenes to binary on export, which it should be by default).

USBDongleGoblin commented 3 years ago

Enabling "Convert Text Resources to Binary on Export" does cut down on file size, but it's not quite as small as .scn.

Using godotdec.exe to extract the files, I was able to peek inside both the converted scene and the .scn using HxD:

Spatial.tscn.converted.res: HxD_NFaG9A4q9E

Spatial.scn: HxD_8yrCWtz8Iz

It appears that .scn files are also compressed, where as converted .tscns are not. Even the headers are different. Should this also be mentioned?