# Scenery assets and offline preparation

All new downloaded visual assets in `assets/scenery/` are **CC0 1.0**. They are served from this site's own static files. No asset host is contacted by the running simulator. Asset sources were checked on 7 October 2026.

`assets/scenery/manifest.json` records downloaded assets: every original download URL, source byte size, SHA-256, publisher MD5 where supplied, output byte size and output SHA-256. The generated trees have a separate [`assets/scenery/trees/manifest.json`](../assets/scenery/trees/manifest.json) with output sizes, hashes and provenance. The source archives and tools are kept only in the ignored `test-results/scenery-source/` working directory and are not deployed.

## Terrain materials

| Local material | Source | Author | Licence |
| --- | --- | --- | --- |
| grass | [Grass Ground](https://polyhaven.com/a/grass_ground) | Charlotte Baglioni | [CC0](https://polyhaven.com/license) |
| dry-grass | [Withered Grass](https://polyhaven.com/a/withered_grass) | Charlotte Baglioni | [CC0](https://polyhaven.com/license) |
| dirt | [Dirt](https://polyhaven.com/a/dirt) | Charlotte Baglioni | [CC0](https://polyhaven.com/license) |
| rock | [Rock Ground](https://polyhaven.com/a/rock_ground) | Rob Tuytel | [CC0](https://polyhaven.com/license) |
| sand | [Sand 01](https://polyhaven.com/a/sand_01) | Rob Tuytel | [CC0](https://polyhaven.com/license) |
| asphalt | [Asphalt 02](https://polyhaven.com/a/asphalt_02) | Rob Tuytel | [CC0](https://polyhaven.com/license) |

Each directory contains `albedo.ktx2` (1024 square, sRGB ETC1S), `normal.ktx2` (512 square, linear RGBA UASTC/Zstd) and optional `arm.ktx2` (512 square, linear ETC1S). The normal texture stores OpenGL XYZ normal in RGB and **roughness in alpha**, copied from the source ARM map's green channel. This packing supports five PBR terrain layers in ten texture samplers, leaving room for environment lighting and cascaded shadows on WebGL2. Do not interpret that alpha as transparency. The separate ARM maps retain ambient occlusion / roughness / metalness in R / G / B and are not needed for terrain startup. All textures contain mipmaps. Normals retain all three XYZ channels; they are not two-channel swizzled normals.

Original manifest endpoint: `https://api.polyhaven.com/files/ASSET_ID`. The script checks the publisher's MD5 before using downloaded maps.

The terrain also generates an original CC0 landscape mask locally at startup (512 square on low/medium, 1024 on high). Its four linear channels describe woodland understory, soil variation, broad moisture and field margins. Woodland placement and rotated field parameters are shared with the vegetation module in `landscape-layout.js`. This one additional sampler adds no download or external dependency and does not alter terrain heights or collisions.

## Procedural atmosphere data

Atmospheric lookup tables and cloud weather/shape textures are generated locally by the pinned Takram libraries; see [their code licences and rendering configuration](RENDERING-LIBRARIES.md). No remote atmosphere data or optional NVIDIA STBN texture dataset is loaded. The cloud ray-sampling texture is original deterministic data generated in `atmosphere.js`, dedicated to [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/): 64 by 64 spatial samples across 127 temporal slices, with a spatial high-pass rank distribution and a golden-ratio temporal offset. It is a locally generated sampling sequence, not a claim to reproduce the optional STBN dataset.

## Foliage

- `foliage/leaf-001.ktx2` through `leaf-004.ktx2`: cropped, opacity-masked leaf cutouts from [ambientCG LeafSet001](https://ambientcg.com/view?id=LeafSet001), [LeafSet002](https://ambientcg.com/view?id=LeafSet002), [LeafSet003](https://ambientcg.com/view?id=LeafSet003), and [LeafSet004](https://ambientcg.com/view?id=LeafSet004). Each is a 512 square RGBA sRGB KTX2 with mipmaps. Crop rectangles are recorded in the manifest. The transparent margin preserves each photographed leaf's aspect ratio.
- `foliage/bark/`: albedo, OpenGL normal and roughness maps derived from [ambientCG Bark001](https://ambientcg.com/view?id=Bark001), 512 square.
- Licence for all these assets: [ambientCG CC0](https://docs.ambientcg.com/license/).
- EZ-Tree's bundled leaf images are **not** included: its own texture licence labels them MIT, while this project requires CC0 visual assets.

## Generated trees and ground vegetation

`trees/` contains four generated species: hornbeam, poplar, ash and lime. Branch geometry is generated offline with [EZ-Tree 1.1.0](https://github.com/dgreenheck/ez-tree), with its [MIT code licence](render-licenses/dgreenheck-ez-tree-LICENSE.txt) preserved. Its bundled image loader is disabled during generation. Original leaf-cluster layouts combine the ambientCG CC0 cutouts above with generated twigs; bark uses the CC0 Bark001 maps.

The original generated branch geometry, cluster layouts, grass blades and impostor bakes are dedicated to [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). Near trees have full geometry, middle trees retain simplified branches and whole leaf cards, and distant trees use sixteen baked views spanning four azimuths and four elevations. Texture coordinates are retained during Meshopt compression because maps are assigned at runtime. Each species has a 512 square KTX2 leaf-cluster map and a 1024 square KTX2 impostor atlas, both with mipmaps. PNG bake sources are retained for reproducibility but are not loaded by the simulator.

Run `node scripts/generate-trees.mjs` after preparing the foliage sources. It uses `test-results/scenery-source/ktx/bin/toktx.exe`, or the `INTERCEPTOR_TOKTX` override. No network is needed for regeneration. The ten compressed tree runtime files total **1,550,572 bytes**; see the tree manifest for exact individual sizes and hashes. Deterministic woods, treelines and grass instances use these shared assets without extra runtime downloads.

## Models

- `models/rocks.glb` and `models/rocks-low.glb`: [Rock Moss Set 01](https://polyhaven.com/a/rock_moss_set_01), Kless Gyzen / Poly Haven, [CC0](https://polyhaven.com/license). Six scanned moss-covered rocks, simplified from 63,127 triangles to 22,081 and 5,674 triangles respectively. Root nodes are named `rock_moss_set_01_rock01` through `rock_moss_set_01_rock06`. Each GLB has embedded KTX2 PBR textures and Meshopt geometry compression.
- `models/buildings.glb`: selected parts from [Kenney Building Kit](https://kenney.nl/assets/building-kit), version 1.0, [CC0](https://creativecommons.org/publicdomain/zero/1.0/). 18 named modular pieces with windows, door openings, gutters, stairs, flat roofs and trim; 1,260 triangles in total. Select named root nodes when assembling buildings: the complete overlapping kit is not a finished house. Names are listed in the manifest. The original palette texture is embedded as KTX2.

The distant building facade atlas is original procedural artwork generated in `scenery.js` and dedicated to [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). Its 256 square texture depicts plaster variation, divided window glass, frames, sills and runoff. It replaces detailed modular facades beyond 500 m (200 m on low), while retaining the same building positions, dimensions and pitched roofs. It is generated locally and makes no network request.

All GLBs require `EXT_meshopt_compression`, `KHR_mesh_quantization` and `KHR_texture_basisu`. Use Three.js GLTFLoader with MeshoptDecoder and KTX2Loader, serving its Basis transcoder from the same host.

## Toolchain and reproduction

- [glTF Transform](https://gltf-transform.dev/) core, extensions and functions **4.5.1**, MIT.
- [meshoptimizer](https://github.com/zeux/meshoptimizer) **1.3.0**, MIT.
- [sharp](https://sharp.pixelplumbing.com/) **0.35.4**, Apache-2.0; its native dependency licences are included by the package.
- [KTX-Software](https://github.com/KhronosGroup/KTX-Software/releases/tag/v4.4.2) **4.4.2**, Apache-2.0 and included third-party notices, used only offline. The official Windows installer is downloaded and unpacked as an archive; it is never installed system-wide. The SHA-256 in the manifest matches the publisher's release API.
- [7-Zip](https://www.7-zip.org/) **26.04**, LGPL-2.1-or-later with bundled notices; the standalone `7zr.exe` is public domain. Used only in the ignored working directory to unpack the official tools and CC0 archives. No system installation is required.

After installing the project's pinned Node development dependencies, place `toktx.exe` and its associated files under `test-results/scenery-source/ktx/bin/` (or set `TOKTX_PATH`) and the portable archive tool at `test-results/scenery-source/7zip/7z.exe`. Run:

```sh
node scripts/prepare-scenery.mjs --download --textures --foliage --models
```

`--download` acquires, verifies and unpacks the CC0 sources. Other switches may be run separately without network access. The script writes only the compressed outputs and manifest into the deployed asset directory. The prepared payload is **5,180,004 bytes across 28 binary files**; the exact sizes are recorded in the manifest and actual first-flight transfer depends on which assets the current quality tier loads. Models are suitable for lazy loading.
