Tiled palette quantization tool

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.
Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
93143
Posts: 1916
Joined: Fri Jul 04, 2014 9:31 pm

Re: Tiled palette quantization tool

Post by 93143 »

turboxray wrote: Tue Nov 04, 2025 12:32 pmYeah, but it's not really two palettes. It just interprets both the highest bit as priority while still acting on the indexed color value. You have the full range of 256 colors.. just that now a certain range of colors also has priority attached to it.
If that were true, an experiment I tried recently wouldn't have worked. The top bit on BG2 really is interpreted as a priority bit instead of an index bit.

Which does end up meaning that you can't use the top half of CGRAM (the sprite half, incidentally) unless you've put BG1 and BG2 on different screens or windowed off part of BG2, because otherwise the high-priority BG2 pixels from the bottom half of CGRAM will cover up the BG1 pixels from the top half. Of course, the whole point of using EXTBG with BG1 and BG2 on the same screen is so you can have per-pixel priority vs. sprites, and this way you don't have to eat into the available sprite palettes to get decent colour depth on the high-priority stuff.

And of course, direct colour mode (which in Mode 7 is just R3G3B2, since the map has no palette selector bits) applies to BG1 but not BG2.
turboxray wrote: Tue Nov 04, 2025 12:32 pmThe CPS-1 has a similar system (IIRC).. lower 0-7 colors of a 4bit indexed value in a tile can have different priority to the sprite than the upper 8-15 colors.
Sounds like multiple palettes per tile to me... of course, this would be hard to automate without a mask of some sort.
turboxray wrote: Tue Nov 04, 2025 9:38 am(I'm not even sure there exists a system where you can assign multiple palettes to a tile.. and how that would even work).
You could overlay two layers and have them combine to produce a single image, Mega Man-style.
turboxray
Posts: 390
Joined: Thu Oct 31, 2019 12:56 am

Re: Tiled palette quantization tool

Post by turboxray »

93143 wrote: Tue Nov 04, 2025 3:13 pm
turboxray wrote: Tue Nov 04, 2025 12:32 pmThe CPS-1 has a similar system (IIRC).. lower 0-7 colors of a 4bit indexed value in a tile can have different priority to the sprite than the upper 8-15 colors.
Sounds like multiple palettes per tile to me... of course, this would be hard to automate without a mask of some sort.
But it's not tho. Palettes are 16 color entries and assigned to 4bit tiles in the tilemap. It's just that you can also set pixels to have different priorities. I don't see how you would view that as two palettes. It's just a mechanism to allow you to sandwich sprite pixels in between pixels of a single tile.
You could overlay two layers and have them combine to produce a single image, Mega Man-style.
Yeah, but that's still two tiles. But you can do this in TQ! If you set the colors per tile to 30 (or 31 if you're including the backdrop color) and reduce the total number of palettes in half - you can easily sort this in your own conversion script. I did this for Genesis with TQ that required two layers (which I split out into two, after TQ produces the single image). It's a bit wasteful on vram tho, but it works.

If want to do raster tricks to get 8x4, or 8x2, or even 8x1 palette association per tile, TQ supports that too.
93143
Posts: 1916
Joined: Fri Jul 04, 2014 9:31 pm

Re: Tiled palette quantization tool

Post by 93143 »

turboxray wrote: Thu Nov 06, 2025 9:07 amIt's just that you can also set pixels to have different priorities.
The way you described it, it sounds like it's different indices (rather than pixels) that have different priorities. Which means that if a certain pixel is supposed to have a certain priority, it can't use a colour from the other half of the 4bpp palette even if it fits perfectly, because it would show up on the wrong side of the in-between sprites. Practically speaking, that's two 3bpp palettes per tile.

And because the distinction between the two 3bpp palettes cannot (in the general case) be deduced from the raw image itself, you'd need some way to convey the depth information to the quantizer.
But you can do this in TQ! If you set the colors per tile to 30 (or 31 if you're including the backdrop color) and reduce the total number of palettes in half
But then you're locked into one set of palette pairings; you can't mix and match.

And you can't solve this by using enough 5bpp palettes to cover all the possible pairings, either, because the 5bpp metapalettes are not uncoupled; you really only have n 4bpp palettes in nC2 (or n-1+n-2+...+1) useful unique combinations. The only way to use the full potential of this scheme is to actually support multiple palettes per tile.