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

Palette bank switching support for VrTexture.SetPalette #33

Open
PiKeyAr opened this issue Apr 25, 2021 · 0 comments
Open

Palette bank switching support for VrTexture.SetPalette #33

PiKeyAr opened this issue Apr 25, 2021 · 0 comments

Comments

@PiKeyAr
Copy link

PiKeyAr commented Apr 25, 2021

Sorry, please bear with me, here's another feature request related to textures with external palettes.

According to the documentation in Sega SDKs, a palette file can contain up to 1024 color entries, which can be used as up to 4 palette sets for Index8 textures or 64 palette sets for Index4 textures.
Some games use multiple palette sets in one PVP file to switch between different palettes. For example, Chao in Sonic Adventure DX and Sonic Adventure 2(B) use Index4 textures with 48-color palettes, and they switch between three 16-color palette banks in code. Some textures are only meant to be used with the second or the third bank. The intended bank ID can be specified in texture data (possibly the value at 0xA in the PVRT header), but the games just set the bank ID in code. The Gamecube version of SA2B and the PC version of SA2 have the same setup so it applies to GVP files too.

Since VrSharp's SetPalette always sets the first bank that begins at offset 0x10 in the PVP/GVP file, there is currently no way to preview other palette banks without manually altering the palette to remove the first bank. My simple suggestion is to add an optional parameter to SetPalette that would take in Bank ID, and offset the starting color in the palette by 16 * bankID for Index4 textures, and by 256 * bankID for Index8 textures before applying the colors to the texture. I think it would be a nice addition to allow more flexibility while working with indexed textures.

We also found this infomation below in the SDK. It isn't too critical to support and I haven't been able to find any games that use it that way, but I thought I should share it for research purposes.
Apparently PVP and GVP files can also have "offset bank" (short at 0xA) and "offset entry" (short at 0xC) values. Offset bank is probably irrelevant as far as texture editing goes, but offset entry indicates how many colors are skipped in the palette bank before the data begins. So if the offset entry is set to 50, for example, the palette's first 50 colors should be blank, and first color in the PVP file becomes the 51st in the actual palette. If the PVP/GVP contains multiple banks, this applies to all banks (e.g. the colors in all banks fill the palettes starting with the 51st color).

Hope this helps!

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

No branches or pull requests

2 participants