|
@@ -21,6 +21,8 @@ export class KhronosTextureContainer2 {
|
|
* URLConfig.jsDecoderModule
|
|
* URLConfig.jsDecoderModule
|
|
* URLConfig.wasmUASTCToASTC
|
|
* URLConfig.wasmUASTCToASTC
|
|
* URLConfig.wasmUASTCToBC7
|
|
* URLConfig.wasmUASTCToBC7
|
|
|
|
+ * URLConfig.wasmUASTCToRGBA_UNORM
|
|
|
|
+ * URLConfig.wasmUASTCToRGBA_SRGB
|
|
* URLConfig.jsMSCTranscoder
|
|
* URLConfig.jsMSCTranscoder
|
|
* URLConfig.wasmMSCTranscoder
|
|
* URLConfig.wasmMSCTranscoder
|
|
* You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
|
|
* You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
|
|
@@ -29,8 +31,10 @@ export class KhronosTextureContainer2 {
|
|
jsDecoderModule: "https://preview.babylonjs.com/babylon.ktx2Decoder.js",
|
|
jsDecoderModule: "https://preview.babylonjs.com/babylon.ktx2Decoder.js",
|
|
wasmUASTCToASTC: null,
|
|
wasmUASTCToASTC: null,
|
|
wasmUASTCToBC7: null,
|
|
wasmUASTCToBC7: null,
|
|
|
|
+ wasmUASTCToRGBA_UNORM: null,
|
|
|
|
+ wasmUASTCToRGBA_SRGB: null,
|
|
jsMSCTranscoder: null,
|
|
jsMSCTranscoder: null,
|
|
- wasmMSCTranscoder: null
|
|
|
|
|
|
+ wasmMSCTranscoder: null,
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -140,7 +144,7 @@ export class KhronosTextureContainer2 {
|
|
reject({ message: message.data.msg });
|
|
reject({ message: message.data.msg });
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
- this._createTexture(message.data.decodedData, internalTexture);
|
|
|
|
|
|
+ this._createTexture(message.data.decodedData, internalTexture, options);
|
|
resolve();
|
|
resolve();
|
|
} catch (err) {
|
|
} catch (err) {
|
|
reject({ message: err });
|
|
reject({ message: err });
|
|
@@ -187,9 +191,16 @@ export class KhronosTextureContainer2 {
|
|
delete KhronosTextureContainer2._WorkerPoolPromise;
|
|
delete KhronosTextureContainer2._WorkerPoolPromise;
|
|
}
|
|
}
|
|
|
|
|
|
- protected _createTexture(data: any /* IDecodedData */, internalTexture: InternalTexture) {
|
|
|
|
|
|
+ protected _createTexture(data: any /* IDecodedData */, internalTexture: InternalTexture, options?: any) {
|
|
this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D, internalTexture);
|
|
this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D, internalTexture);
|
|
|
|
|
|
|
|
+ if (options) {
|
|
|
|
+ // return back some information about the decoded data
|
|
|
|
+ options.transcodedFormat = data.transcodedFormat;
|
|
|
|
+ options.isInGammaSpace = data.isInGammaSpace;
|
|
|
|
+ options.transcoderName = data.transcoderName;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (data.transcodedFormat === 0x8058 /* RGBA8 */) {
|
|
if (data.transcodedFormat === 0x8058 /* RGBA8 */) {
|
|
internalTexture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
|
|
internalTexture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
|
|
internalTexture.format = Constants.TEXTUREFORMAT_RGBA;
|
|
internalTexture.format = Constants.TEXTUREFORMAT_RGBA;
|
|
@@ -267,6 +278,12 @@ function workerFunc(): void {
|
|
if (urls.wasmUASTCToBC7 !== null) {
|
|
if (urls.wasmUASTCToBC7 !== null) {
|
|
KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = urls.wasmUASTCToBC7;
|
|
KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = urls.wasmUASTCToBC7;
|
|
}
|
|
}
|
|
|
|
+ if (urls.wasmUASTCToRGBA_UNORM !== null) {
|
|
|
|
+ KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = urls.wasmUASTCToRGBA_UNORM;
|
|
|
|
+ }
|
|
|
|
+ if (urls.wasmUASTCToRGBA_SRGB !== null) {
|
|
|
|
+ KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = urls.wasmUASTCToRGBA_SRGB;
|
|
|
|
+ }
|
|
if (urls.jsMSCTranscoder !== null) {
|
|
if (urls.jsMSCTranscoder !== null) {
|
|
KTX2DECODER.MSCTranscoder.JSModuleURL = urls.jsMSCTranscoder;
|
|
KTX2DECODER.MSCTranscoder.JSModuleURL = urls.jsMSCTranscoder;
|
|
}
|
|
}
|