-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental KTX support #40
Conversation
This now includes the state from #61 (so that one should probably be merged first), and a fix to resolve the main issue that prevented this from being merged: The
Under the hood, this uses the Basis Encoder from https://github.com/BinomialLLC/basis_universal/tree/ad9386a4a1cf2a248f7bbd45f543a7448db15267/webgl/encoder , which is built into a JS+WASM bundle and included here in the I tested this by creating a glTF asset with different encodings of the same texture. Here's an example with the Dragging-and-dropping this into https://gltf.report/ and selecting the 'Textures' tab shows an overview of the textures, their encodings, and their memory requirements: I also tested this with a 2048x2048 texture (although certain settings cause the encoding to become pretty slow then...), and it seems to work as expected. |
The last commit adds a convenience layer around the KTX encoding, so that it is possible to encode all textures in glTF tiles with something like import { TileContentProcessing } from "./src/tilesetProcessing/TileContentProcessing";
import { TileContentProcessorsTextures } from "./src/tilesetProcessing/TileContentProcessorsTextures";
import { KtxEtc1sOptions } from "./src/ktx/KtxEtc1sOptions";
import { KtxUastcOptions } from "./src/ktx/KtxUastcOptions";
async function runDemo() {
const tilesetSourceName = "./data/input/tileset.json";
const tilesetTargetName = "./data/output/tileset.json";
const overwrite = true;
// Create a `TileContentProcessor` that encodes textures
// to KTX, with the given options for ETC1S or UASTC
const etc1sOptions: KtxEtc1sOptions = {
compressionLevel: 2,
qualityLevel: 96,
};
const uastcOptions: KtxUastcOptions = {};
const tileContentProcessor = TileContentProcessorsTextures.encodeToKtx(
etc1sOptions,
uastcOptions
);
// Process the tileset source, and write it to the tileset target,
// applying each `TileContentProcessor` to all tile contents
await TileContentProcessing.process(
tilesetSourceName,
tilesetTargetName,
overwrite,
tileContentProcessor
);
}
runDemo(); The functionality for encoding textures may still be added at the command line. |
Builds upon #39Merged with a more recent state, now based on #61