Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Godot compressed texture

From ReverseEngineering.wiki
Format
Versions format version 1
Magic 47 53 54 32 ("GST2"); layered: 47 53 54 4C ("GSTL")
Extensions .ctex (Godot 4, under .godot/imported/), .stex (Godot 3)
Endianness little endian
On this wiki Facts · Code · Notes · Topics

Imported texture containers of the Godot engine: GST2 (CompressedTexture2D, usually .ctex in Godot 4) and GSTL (layered textures: 3D, cube, arrays), each a small header followed by PNG, WebP, Basis Universal or raw image data per mipmap.

Overview

When Godot imports an image it writes a .import text file next to the source and puts the converted data under .godot/imported/ (Godot 4, file names like name.png-<md5>.ctex); exported games ship those converted files, not the original PNG. Source: scene/resources/compressed_texture.cpp and .h in godotengine/godot (MIT), read at commit 81ab961f91 (2026-10).

GST2 header (magic plus 7 uint32)

Field Notes
magic GST2 4 bytes
version uint32, the loader refuses a value above 1 ("Compressed texture file is too new.")
width, height uint32 each
data format / flags uint32; bits 23 has mipmaps, 24 detect 3D, 26 detect normal map, 27 detect roughness (bit 25 is a commented-out sRGB detect bit); the editor uses the detect bits, the runtime ignores them
mipmap limit uint32
3 reserved uint32

The image data follows immediately: uint32 data format (0 raw image, 1 PNG, 2 WebP, 3 Basis Universal), uint16 width, uint16 height, uint32 mipmap count, uint32 Image::Format. For PNG and WebP each of (mipmaps + 1) images is stored as uint32 size plus the complete PNG or WebP file, so the pixels can be recovered by cutting out the embedded files. Basis Universal has a single uint32 size plus data. Raw image data holds the pixel buffer of the given Image::Format (VRAM-compressed formats such as S3TC/BPTC/ETC2/ASTC are stored this way).

GSTL (layered textures)

Same idea with magic GSTL, version (max 1), then layer count, a layer type (2D array, cube, cube array, 3D), data format, mipmap limit and reserved fields, followed by one image block per layer as above. Unverified: exact field order for 3D textures (3D textures have their own depth/mipmap fields); read compressed_texture.cpp (CompressedTexture3D::_load_data, CompressedTextureLayered::_load_data) before parsing.

Godot 3

Unverified: Godot 3 stored the same idea as .stex files with magic GDST (StreamTexture) and .ctex as GST2 only from Godot 4; the Godot 3 layout was not read here.

Related

Format:Godot PCK, Format:Godot binary resource, Library:Godot Engine

Code & repositories

  • https://github.com/godotengine/godot @ 81ab961f91066a63bcbf3ec340962bb1a1ada558 · license: MIT
    Godot engine source (MIT). Useful without building: core/io/file_access_pack.cpp (PCK reader), core/io/resource_format_binary.cpp (RSRC), core/io/file_access_compressed.cpp (RSCC), core/io/file_access_encrypted.cpp, scene/resources/compressed_texture.cpp (GST2/GSTL), modules/gdscript/gdscript_tokenizer_buffer.cpp (GDSC).
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries