pixijs / assetpack

A configurable asset pipeline for the web
http://pixijs.io/assetpack/
MIT License
105 stars 25 forks source link

feat: Add compressed textures support #72

Closed ddenisyuk closed 2 months ago

ddenisyuk commented 3 months ago

The image compression extension has been enhanced with the ability to generate ASTC, BC7, and supercompressed Basis textures.

Zyie commented 3 months ago

hey @ddenisyuk just back from holiday so will review this soon!

norflin321 commented 3 months ago

hey guys do you have an example of loading a spritesheet compressed with astc (either inside ktx container or not) in pixi 8? i recently was trying to implement it, and encounter some issues:

  1. i am unable to load a astc texture or spritesheet without ktx container
  2. texture loaded from astc.ktx, looks dark and oversaturated
  3. i was able to load and render astc.ktx astc-4x4, but rendering astc-12x12 gives the following error: [.WebGL-0x138005ba100] GL_INVALID_VALUE: Compressed texture dimensions must exactly match the dimensions of the data passed in. I am using pixi@8.3.0, and TexturePacker. Maybe these issues is not relevant to AssetPack?

also it it possible to specify either 4x4 or 12x12 astc pixel format, in implementation from this PR?) default 4x4 is mostly useless because textures takes more space than PNG, and ASTC usually used for mobile where game size is really important

ddenisyuk commented 2 months ago

Hey @norflin321, it's hard to help you without examples, but you can check the test file to see how to load textures: https://github.com/pixijs/pixijs/blob/dev/tests/compressed/CompressedTextures.test.ts. Pixi, by default, expects a specific naming format for compressed textures: {name}.{format}.{extension/container}, like my-texture.astc.ktx.

Regarding item # 2, it could be related to a misconfiguration of 'Premultiplied Alpha' and/or 'Colorspace'.

also it it possible to specify either 4x4 or 12x12 astc pixel format, in implementation from this PR?) default 4x4 is mostly useless because textures takes more space than PNG, and ASTC usually used for mobile where game size is really important

yes, you can define preferable blocksize:

 compress({  
      png: true,
      webp: true,
      astc: {
          blocksize: "12x12"
       },
  }),
ddenisyuk commented 2 months ago

hey @ddenisyuk just back from holiday so will review this soon!

hey @Zyie, any updates?