Scripts
Helper scripts that automate asset conversion, validation, and data syncing.
They live in scripts/ at the repo root and require Python 3.10+.
Most scripts that produce KTX2 files need
KTX-Software (toktx) on
PATH.
bake_blender_material
Convert a Blender PBR texture folder into engine-ready KTX2 textures and a material JSON.
Prerequisites: toktx, Pillow (pip install Pillow)
python scripts/bake_blender_material.py \
--input_dir plans/materials/grainy-concrete-bl \
--output_dir engine_defaults
Expects the standard Blender naming convention (*_albedo.png,
*_roughness.png, *_metallic.png, *_normal-ogl.png, *_ao.png,
*_height.png). The folder name is used as the material name — a trailing
-bl suffix is stripped automatically. Override with --name.
Texture mapping
| Input | Output | Encoding |
|---|---|---|
*_albedo.png | textures/<name>/albedo.ktx2 | sRGB |
*_roughness.png + *_metallic.png | textures/<name>/metalRough.ktx2 | linear |
*_normal-ogl.png | textures/<name>/normal.ktx2 | linear |
*_ao.png | textures/<name>/ao.ktx2 | linear |
*_height.png | textures/<name>/displacement.ktx2 | linear |
The metalRough texture packs roughness into the G channel and metallic
into the B channel (glTF convention).
The material JSON is written to materials/<name>.json in the
v2 flat format.
bake_glitterpak
Pack a directory tree into a .glitterpak archive.
python scripts/bake_glitterpak.py <input_dir> <output.glitterpak>
python scripts/bake_glitterpak.py resources/testGame testGame.glitterpak
bake_lut
Build the combined outputLUT.ktx2 for the PBR pipeline.
Channel packing: R = GGX split-sum scale, G = GGX split-sum bias, B = Charlie sheen BRDF.
python scripts/bake_lut.py # auto-detect sibling clone
python scripts/bake_lut.py <path/to/glTF-Sample-Viewer>
Requires the Khronos glTF-Sample-Viewer repo cloned alongside this one (or pass the path explicitly).
bake_prototype_textures
Re-encode prototype PNG textures to KTX2 (UASTC + mipmaps).
python scripts/bake_prototype_textures.py # all themes
python scripts/bake_prototype_textures.py dark red # specific themes only
Valid themes: dark, green, light, orange, purple, red.
check_shaders_json
Validate that every .json file under engine_defaults/shaders/ is
well-formed JSON. Exits non-zero on any parse error — useful in CI.
python scripts/check_shaders_json.py
sync_physicallybased
Fetch the latest materials, lights, and cameras from
physicallybased.info and write engine JSON
files to engine_defaults/.
python scripts/sync_physicallybased.py # sync all
python scripts/sync_physicallybased.py --lights --cameras # subset
python scripts/sync_physicallybased.py --dry-run # preview