Skip to content

Decode sprites packed in a 6000.6 SpriteAtlas #229

Description

@fatal10110

Package: packages/texture (npm unity-asset-reader-texture), sprite.ts / image.ts

Description

Follow-up of #155 / PR #228. From Unity 6000.6 a SpriteAtlas no longer has m_PackedSprites / m_PackedSpriteNamesToIndex; every m_RenderDataMap entry holds its sprite itself as *spriteInstanceData (name, rect, pivot, border, pixels per unit, vertex data, indices). PR #228 made the core read that layout (SpriteAtlasFields.renderDataMap[i][1].spriteInstanceData). In real 6000.6 bundles the packed sprites are no longer Sprite objects (the 6000.6.4f1 sprite/sprites fixture has 5 Sprites where the 6000.3 build of the same project has 22), so images(), imageInfo, decodeImage and decodeSprite never see them, and a Sprite object pointing at a 6000.6 atlas is refused with UnsupportedError (kind "Unity version").

Tasks

  • Make each packed sprite of a 6000.6 atlas addressable through the existing image API (smallest public addition consistent with images() / imageInfo / decodeImage / decodeSprite and the Core: TypeScript-style data shapes for asset.data (camelCase, no m_) #184 naming), and list it in images().
  • Cut it out of the atlas texture with the entry's textureRect / textureRectOffset / settingsRaw (packing flip/rotation undone), with the existing split-alpha merge (Sprites with an alpha texture (ETC1 split alpha) #152) and variant downscale (Sprites of a variant atlas (downscaleMultiplier) #153) paths; with tightMesh, mask it with the instance data's mesh (vertices / indices).
  • Keep R9 refusals for what is still unsupported (index formats or layouts the fixtures do not show), narrowing the 6000.6 refusal only where this handles it.
  • Goldens for the packed sprites from the oracle (R12): UnityPy 1.25.4 through scripts/make-modern-goldens.py, or, where UnityPy cannot export them, an independent reference already in the repo (the section 12 source-pixel recipe, the 6000.3 goldens of the same source images); record the oracle and its limits. Decide per fixtures/BUILDING.md section 13 whether the 6000.6 fixtures can move into the main golden set.
  • Docs: support tables and limits (root and texture README), CHANGELOG texture Unreleased, fixtures/BUILDING.md section 13, JSDoc @throws.

Port

No upstream port: AssetStudio (rev c37af7d) has no 6000.6 SpriteAtlas reader, and UnityPy 1.25.4 exports Sprite objects only. Cutting follows AssetStudio.Utility/SpriteHelper.cs CutImage as already ported in sprite.ts.

Acceptance

  • Every packed sprite of the 6000.6.4f1 sprite, variant, sprite-v2 and sprite-v2-rect fixtures is listed by images() and decodes to its oracle golden (or the verdict recorded next to it, plan §6).
  • With tightMesh, packed tight sprites are masked by their instance-data mesh and match the recorded reference.
  • The 6000.6 variant atlas's half-scale entries are resized before the cut; how they are checked is recorded.
  • What stays unsupported throws UnsupportedError with what was found.

Plan: docs/unity-asset-reader-plan.md. Behavior source of truth: Razviar/assetstudio (MIT). Golden oracle: UnityPy (MIT). MIT-derivative port: keep upstream copyright notices. Do not copy or import @arkntools/unity-js (AGPL-3.0), tests included. No C# compiled to WASM - C# is reference only, hand-ported to TS; WASM is built from C/C++ only (plan D2). Layout: npm-workspaces monorepo under packages/; dependencies point feature package -> core only (plan D7/D8, rules R13/R14).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:textureTexture and sprite decodingbacklogOn-demand, no named consumer yet

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions