Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Record the KTX2 formats, texture bytes, load time and score of AnisotropyBarnLamp (part of #304)

Nguyen Xuan Anaf716af6fedd
diff --git a/docs/gltf.md b/docs/gltf.md
index 69d1fd6f..3ed1272f 100644
--- a/docs/gltf.md
+++ b/docs/gltf.md
@@ -190,6 +190,20 @@ Color maps upload as sRGB and data maps as linear. A file with a partial mip cha
`asset.textureFormats` lists `{ format, width, height, colorSpace, bytes }` for each texture, with `format` set to `bc7`, `bc1-rgb`, `bc1-rgba`, `bc3`, `astc-4x4`, `etc2-rgb`, `etc2-rgba` or `rgba8`.
KTX2 dimensions count toward `maxTexturePixels` before decoding. KTX2 images are never scaled. When the loader's `workerConfig` allows a compressed format, a KTX2 image counts a quarter of its pixels, because it takes at most one byte a texel on the GPU. A KTX2-heavy file over the budget still fails.
+three's KTX2Loader picks the format from the context. For this file it chose ASTC 4x4 where ASTC is available and BC7 where it is not, and the renderer falls back to RGBA8 when the context offers none of the formats above. On the RTX 3060 (Direct3D 11 through ANGLE) the Khronos `AnisotropyBarnLamp` KTX2 variant loads as `bc7`. On Chrome's SwiftShader it loads as `astc-4x4`, because SwiftShader advertises ASTC, ETC2, S3TC and BPTC and decodes them on the CPU. Only a context with none of these extensions gets `rgba8`; the table above is the list.
+
+#### Measured 2026-11-04 (issue #304, `bench/ktx2/measure.mjs`)
+
+`AnisotropyBarnLamp` from [glTF-Sample-Assets](https://github.com/KhronosGroup/glTF-Sample-Assets) (CC BY 4.0, Analytical Graphics, Inc. and Wayfair, LLC), four 2048 x 2048 maps (base color, anisotropy, normal, occlusion-roughness-metal), PNG against `glTF-KTX-BasisU`, median of three loads:
+
+| | PNG, `rgba8` | KTX2, `bc7` |
+| --- | --- | --- |
+| Texture bytes the engine accounts for (computed from block size and mip count, not read from the driver) | 89,478,480 (85.3 MiB, with mips) | 16,777,216 (16.0 MiB, one level) |
+| Load time on the RTX 3060 | 0.12 s | 0.27 s |
+| Load time on SwiftShader | 0.15 s | 0.21 s |
+
+The Khronos KTX2 files hold no mip chain, so the 5.3x saving mixes the format (4 bytes to 1 a texel) with the missing mips; with a full chain BC7 would take 21.3 MiB, 4.2x less. WebGL does not report driver memory, so these are not driver readings. KTX2 loads slower because of the Basis transcode. Drawn through the reference suite's Khronos framing and scored against the stored Cycles array, the PNG variant gets FLIP 0.0386 over the whole frame and 0.3341 over the pixels the lamp covers; the KTX2 variant gets 0.0385 and 0.3330, a difference of 0.0001 and 0.0011.
+
### Instancing limits
`maxInstances` (default 4,096) caps the instances of one node, and `maxParts` still caps the total number of parts.