Skip to content
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

Fix ktx2 texture support #1829

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions packages/loader/src/ktx2/KTX2Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,21 @@ export class KTX2Loader extends Loader<Texture2D | TextureCube> {

private static _detectSupportedFormat(renderer: any, priorityFormats: KTX2TargetFormat[]): KTX2TargetFormat | null {
for (let i = 0; i < priorityFormats.length; i++) {
const capabilities = this._supportedMap[priorityFormats[i]];
for (let j = 0; j < capabilities.length; j++) {
if (renderer.canIUse(capabilities[j])) {
return priorityFormats[i];
const format = priorityFormats[i];
const capabilities = this._supportedMap[format];
if (capabilities) {
for (let j = 0; j < capabilities.length; j++) {
if (renderer.canIUse(capabilities[j])) {
return format;
}
}
} else {
switch (priorityFormats[i]) {
case KTX2TargetFormat.R8G8B8A8:
return format;
case KTX2TargetFormat.R8:
case KTX2TargetFormat.R8G8:
if (renderer.isWebGL2) return format;
}
}
}
Expand Down Expand Up @@ -202,17 +213,7 @@ export class KTX2Loader extends Loader<Texture2D | TextureCube> {
);
}

private _isKhronosSupported(
priorityFormats: KTX2TargetFormat[] = [
KTX2TargetFormat.ASTC,
KTX2TargetFormat.ETC,
KTX2TargetFormat.BC7,
KTX2TargetFormat.BC1_BC3,
KTX2TargetFormat.PVRTC,
KTX2TargetFormat.R8G8B8A8
],
engine: any
): boolean {
private _isKhronosSupported(priorityFormats: KTX2TargetFormat[], engine: any): boolean {
return !!KhronosTranscoder.transcoderMap[
KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats)
];
Expand Down