Description
Describe the project you are working on
The Godot editor 🙂
Describe the problem or limitation you are having in your project
When exporting a project for dedicated servers, textures are currently stripped, which greatly reduces the PCK size compared to a client export. However, there's still significant room for optimization, especially in games that include lots of audio such as soundtrack and voice clips.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Strip audio from dedicated server exports to reduce PCK size.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
- Add PlaceholderAudioStream, which is the audio equivalent of the PlaceholderTexture* classes.
- This resource only implements a
get_length()
method to retrieve its length in seconds, which is set on export according to the original resource.- This length is then used to make signals such as
AudioStreamPlayer.finished
work as they would do with an actual audio file.
- This length is then used to make signals such as
- This resource only implements a
- Rename Strip Visuals in the Export dialog to Strip Audiovisuals, so that it matches its updated behavior.
I've made a testing project for anyone looking into implementing this: test_dedicated_server_export.zip
Exported project data as ZIP: out.zip
When running godot --main-pack out.zip
, this is what I get:
Texture size: 256×384
WAV length: 2.25 seconds
OGG length: 2.25 seconds
MP3 length: 2.25 seconds
Thanks to PlaceholderTexture* classes, even though the texture data isn't actually included in the PCK/ZIP, it's still able to retrieve the texture's size in pixels. This size may be relied upon in server-side game logic for various purposes, such as positioning elements in the scene (especially in 2D games).
If this enhancement will not be used often, can it be worked around with a few lines of script?
It's possible for projects to manually exclude specific resources, but their scenes and game logic must then be modified to account for this as the resource won't exist in the exported project in dedicated server mode. For large projects, this can be a time-consuming effort requiring lots of maintenance.
In contrast, this proposal allows to export any existing project as a dedicated server with no code changes needed.
Is there a reason why this should be core and not an add-on in the asset library?
This is about optimizing PCK/ZIP file size for dedicated server exports, which will benefit all projects that export as a dedicated server.