Repository navigation
Sprite support to go with the networking update and psxsplash/psxsus - #40
Conversation
…e support to go with PSXSUS
rixnobis
left a comment
There was a problem hiding this comment.
One blocker, a handful of should-fix. Every new table in PSXSceneWriter (SpriteSheet 20B, SpriteAnim 12B, Tilemap 20B, TileCell 2B, TileObject 6B, AgentV2 28B, header 144B at v23) matches the reader in #28 field for field, and v20/v21 packs still load. The one mismatch is the CLUT X unit below. Not built in Unity; this is a read-through plus a symbol check.
Blocker: sprite and tile CLUT X is divided by 16 twice. PSXSpriteExporter.cs writes ClutX = tex.ClutPackingX, which TexturePacker already stores as x / 16. On the engine side, spritesystem.cpp and tilesystem.cpp build ClutIndex(Vertex{clutX, clutY}), and psyqo's ClutIndex(Vertex v) does v.x >> 4 again. Any 4bpp/8bpp sheet whose palette isn't at VRAM x=0 samples the wrong CLUT. The UI image path uses ClutIndex(x, y) and is fine. Fix it on either side: write ClutPackingX * 16 here, or use the two-argument constructor in #28.
Should-fix:
PSXSpriteExporter.cs: a sheet with noPackedTextureis skipped with a warning, but anims (Sheet = (byte)i) and the tilemap (sheetList.IndexOf) still index the unfiltered list, so everything after the gap points at the wrong sheet. Throw, or index intosheetData.PSXTexture2D.cs:cutoutonly affects the paletted path. A 16bpp sheet only gets transparency where the texel happens to pack to 0x0000, andalphaIsTransparency = truemakes that rarer.TexturePacker.cs: the dedup key is(instanceID, BitDepth)withoutcutout, so a texture shared between a sprite sheet and a mesh/UI image gets whichever quantization ran first.PSXSceneWriter.cs: an agent whose object isn't exported gets0xFFFF, andgameObjectIndex + 1inscenemanager.cppwraps that to actor 0. APSXAgenton a skinned object hits this, because itsPSXObjectExporteris skipped in favour of the skinned proxy.Utils.SetTextureImporterFormatnow forces no-mip/point/uncompressed/alphaIsTransparency on every texture it touches, including mesh textures, which rewrites project import settings without saying so.Editor/PSXUIMenuItems.cshasusing UnityEngine.UI;, but the Editor asmdef doesn't reference uGUI and nothing in the file uses it. Probably a compile error; delete the line.
Nits: waypoint Y isn't negated like object Y is; the ASCII pass left "(cycle)" in a 22px button, "yes Path is set and valid" and "Autov"; a Debug.Log fires per sheet on every export; there are // Added: comments in PSXSceneExporterEditor.cs; hash ^= (byte)c drops the high byte of non-ASCII scene ids.
Scope: besides sprites and tilemaps this carries agents, nav settings, the network scene hash, audio silence trimming, UI budget/layout/menus, the screen preview and a repo-wide Unicode-to-ASCII pass. I'm fine reviewing it as one since #28 depends on all of it, but the ASCII pass especially makes the diff harder to read than it needs to be.
…ng it Anims and the tilemap index sheets by their position in the unfiltered list, so a skipped sheet pointed everything after it at the wrong one. Also drop the per-sheet Debug.Log.
Only the paletted path applied it, so a 16bpp sheet was transparent only where a texel happened to pack to 0x0000.
A texture used both by a sprite sheet (cutout) and by a mesh or UI image was packed once, with whichever quantization ran first.
…t otherwise The writer fell back to 0xFFFF, which the runtime's gameObjectIndex + 1 wraps to actor 0, the player. A PSXAgent on a skinned object always hit this, because its PSXObjectExporter is skipped for the skinned proxy.
The Editor asmdef does not reference uGUI and nothing in the file uses it.
The refresh button, the path-OK label and the console's auto-scroll toggle read "(cycle)", "yes Path..." and "Autov".
|
Pushed six commits onto this branch for the review above: a sprite sheet with no Left for @CloudMracek: |
|
This is now an RFC: it cannot merge before 2026-10-06 09:40 UTC, so anyone who depends on what it changes has a week to comment. See RFC.md. |
rixnobis
left a comment
There was a problem hiding this comment.
Labeled rfc: the new components (PSXSprite, PSXSpriteSheet, PSXTilemap, PSXAgent, PSXUISprite) and the v22/v23 writer are contracts, and this pairs with #37.
I compared the writer on this head with the reader on #37 field by field. The 144-byte v23 header lines up with SPLASHPACKFileHeader in order and width, sceneLuaFileIndex written as -1 reads back as the reader's 0xFFFF, and the agent records (28 bytes), sprite sheets (20), sprite anims (12), tilemap header (20), cells (2) and tile objects (6) match the engine's structs. The sprite and tilemap offsets are backfilled into the header slots the engine reads.
What nobody has done yet is build this in Unity: the fixes pushed here were only checked against the symbols on the branch. @CloudMracek, once you've exported a scene with sprites and a tilemap from this head and run it, that plus the SetTextureImporterFormat question above is what's left before I approve.
Yes that is the correct approach. |
rixnobis
left a comment
There was a problem hiding this comment.
Fine by me. With the import settings intended, nothing I raised is open.
Sprites, tilemaps