Search the Community
Showing results for tags 'ktx-parse'.
-
Hi I'm getting black textures when I'm trying to load KTX2 files using loaders.gl and use the UInt8Array to load a texture with from or fromBuffer and create a Pixi sprite with it. It doesn't matter if I make a BaseTexture first or not. Code with BasisLoader & Texture.fromBuffer: import { BasisLoader } from '@loaders.gl/textures'; import { load } from '@loaders.gl/core'; import * as Pixi from 'pixi.js'; ... const loadOptions = { format: 'auto', containerFormat: 'ktx2', module: 'encoder', }; const resources = await load(filename, BasisLoader, loadOptions); const textureData = resources[0][0]; const texture = Pixi.Texture.fromBuffer(textureData.data, textureData.width, textureData.height); const sprite = new Pixi.Sprite(texture); Code with CompressedTextureLoader & Texture.from with BaseTexture: import { CompressedTextureLoader } from '@loaders.gl/textures'; import { load } from '@loaders.gl/core'; import * as Pixi from 'pixi.js'; ... const loadOptions = { useBasis: true, }; const resources = await load(filename, CompressedTextureLoader, loadOptions); const textureData = resources[0]; const baseTexture = new Pixi.BaseTexture( new BufferResource(textureData.data, { width: textureData.width, height: textureData.height, }) ); const texture = Pixi.Texture.from(baseTexture); const sprite = new Pixi.Sprite(texture); Log output: I also tried Pixi's CompressedTextureResource: const baseTexture = new Pixi.BaseTexture( new Pixi.CompressedTextureResource(textureData.data, { format: textureData.format, width: textureData.width, height: textureData.height, }) ); But got this: KTX2 Container is not (yet) implemented into pixi, that is why I had to try other ways to get it loaded into a pixi sprite. I'm not fully understanding all of the compression stuff yet, so I'm probably forgetting something. To be sure you get enough information: I used KTXSoftware's toktx tool to create a KTX2 file from a png: https://github.com/KhronosGroup/KTX-Software I tried these commands and have loaded them all in: ETC1S .\toktx.exe --t2 --encode etc1s --clevel 5 --qlevel 255 book.ktx2 book.png ASTC .\toktx.exe --t2 --encode uastc --uastc_quality 4 book.ktx2 book.png UASTC .\toktx.exe --t2 --encode astc --astc_blk_d 4x4 --astc_quality 100 book.ktx2 book.png So if someone could point me in the right direction, that would be awesome. Thanks in advance!
- 5 replies
-
- typescript
- loaders.gl
-
(and 5 more)
Tagged with: