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

Bug: Asset format is not resolved correctly #10215

Open
ddenisyuk opened this issue Feb 14, 2024 · 0 comments
Open

Bug: Asset format is not resolved correctly #10215

ddenisyuk opened this issue Feb 14, 2024 · 0 comments

Comments

@ddenisyuk
Copy link

ddenisyuk commented Feb 14, 2024

Current Behavior

Textures whose format differs from their file extension are not resolved correctly. File extension is always used as a format.

Compressed textures:

When multiple texture variants are defined, compressed textures (such as ASTC, S3TC, etc.) are neither resolved nor used.
In cases where PNG and/or WEBP formats are defined, they will always be used, and compressed textures will be ignored.

 {
      "name": "images/pause-overlay",
      "assets": [
        {
          "name": [
            "images/pause-overlay/pause-panel.png"
          ],
          "srcs": [
            "images/pause-overlay/pause-panel.atc.ktx",
            "images/pause-overlay/pause-panel.astc.ktx",
            "images/pause-overlay/pause-panel.s3tc.ktx",
            "images/pause-overlay/pause-panel.png",
            "images/pause-overlay/pause-panel.webp",
          ]
        }
      ]
    }

If PNG and/or WEBP formats are not defined, the texture will be selected according to the order of definition, even if it is not supported.
atc will be selected in case of the following definition:

 {
      "name": "images/pause-overlay",
      "assets": [
        {
          "name": [
            "images/pause-overlay/pause-panel.png"
          ],
          "srcs": [
            "images/pause-overlay/pause-panel.atc.ktx",
            "images/pause-overlay/pause-panel.astc.ktx",
            "images/pause-overlay/pause-panel.s3tc.ktx"
          ]
        }
      ]
    }

Sprite sheets:

First one is always used.

{
      "name": "images/game-screen",
      "assets": [
        {
          "name": [
            "images/game-screen/game-screen.json"
          ],
          "srcs": [
            "images/game-screen/game-screen@1x.png.json",
            "images/game-screen/game-screen@1x.webp.json",
            "images/game-screen/game-screen@1x.avif.json"
          ]
        }
      ]
    }

Expected Behavior

The texture file is selected based on user-defined or default priorities and system compatibility.

Steps to Reproduce

Load the manifest.json with the following bundle:

{
      "name": "images/pause-overlay",
      "assets": [
        {
          "name": [
            "images/pause-overlay/pause-panel.png"
          ],
          "srcs": [
            "images/pause-overlay/pause-panel.atc.ktx",
            "images/pause-overlay/pause-panel.astc.ktx",
            "images/pause-overlay/pause-panel.s3tc.ktx",
            "images/pause-overlay/pause-panel.png",
            "images/pause-overlay/pause-panel.webp",
          ]
        }
      ]
    }

Expected images/pause-overlay/pause-panel.s3tc.ktx file requested.
Current: images/pause-overlay/pause-panel.webp file requested.

Environment

  • pixi.js version: 7.4.0
  • Browser & Version: Chrome 121.0.6167.160 (Official Build) (arm64)
  • OS & Version: macOS Sonoma 14.2
  • Running Example: https://jsfiddle.net/dovcj6we/8/

Possible Solution

  1. Use detected format in the Resolver.ts: formattedAsset.format = format ?? formattedAsset.format ?? utils.path.extname(formattedAsset.src).slice(1);
  2. Update resolveCompressedTextureUrl.ts parse method to return valid formats
  3. Update documentation of compressed textures with the naming convention
  4. (Optional as out of scope of this issue) Extend validImages with the list of supported compressed textures formats

Additional Information

  • Fixed in v8 - 76437e9
  • Explicit format definition works as expected.

ASTC will be selected:

{
      "name": "images/game-screen",
      "assets": [
        {
          "name": [
            "images/game-screen/game-screen.json"
          ],
          "srcs": [
           {
              "format": "png",
              "src":  "images/game-screen/game-screen@1x.png.json"
            },
            {
              "format": "avif",
              "src":  "images/game-screen/game-screen@1x.avif.json"
            },
            {
              "format": "astc",
              "src":  "images/game-screen/game-screen@1x.astc.json"
            }
          ]
        }
      ]
    }
@ddenisyuk ddenisyuk changed the title Bug: Compressed textures are not resolved correctly Bug: Asset format is not resolved correctly Feb 14, 2024
@ddenisyuk ddenisyuk mentioned this issue Feb 15, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant