Possible alternate colorspaces for video game palettes.

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Possible alternate colorspaces for video game palettes.
by on (#165160)
I was thinking about colorspaces today, and I came up with a decent idea for a color space that can easily be converted to low-bit rgb, that should be a little more visually uniform than rgb.

I think I'll call it Yab, just because the Y works like the Y in YUV and YIQ, and the A and B work sort've like the A and B in Lab. So here's my formula.

R = Y + 2a + b
G = Y - a
B = Y - 3b

Any advice to improve upon this. I'm thinking there should be a way to compensate for the not-so-predictable luminance value of highly saturated colors.
Re: Possible alternate colorspaces for video game palettes.
by on (#165162)
This doesn't really look all that much more useful than RGB?

Here's a simple cube, 0≤Y≤7, -4≤a,b≤3:
Attachment:
yab.png
yab.png [ 615 Bytes | Viewed 5313 times ]
Lots of out-of-gamut colors too.

No yellows, and lackluster reds and purples.
Re: Possible alternate colorspaces for video game palettes.
by on (#165163)
Maybe A/B range from 0 to 7, not -4 to 3?
Re: Possible alternate colorspaces for video game palettes.
by on (#165164)
Or try -7 to 7. BTW, why is everything so dark?
Re: Possible alternate colorspaces for video game palettes.
by on (#165235)
Sounds very similar to YCgCo, but not quite the same.
Re: Possible alternate colorspaces for video game palettes.
by on (#165266)
Dwedit wrote:
Sounds very similar to YCgCo, but not quite the same.


I never heard of that before, but it sounds awesome.
Re: Possible alternate colorspaces for video game palettes.
by on (#165297)
I made a 12-bit YCoCg color palette. It's cool how it ended up being exactly 1024 colors. That means if I make a 15-bit version, it will come out with 8192 colors.
Re: Possible alternate colorspaces for video game palettes.
by on (#165299)
I always wondered how having 6bit RGB with 2 extra bits to reduce the value of the color for every channel. Because your eyes are supposedly better at seeing shades of color than different colors or something like that, I wonder if it might even look better than 9bit RGB despite only being half the colors.
Re: Possible alternate colorspaces for video game palettes.
by on (#165300)
That's a form of RGBI, with 2 bits per channel. It's the componentwise sum of the Cartesian product of four 2-bit palettes:

Red: #000, #400, #800, #C00
Green: #000, #040, #080, #0C0
Blue: #000, #004, #008, #00C
Intensity: #000, #111, #222, #333

Fortunately, GIMP makes componentwise sums easy using the Addition blend mode.
Re: Possible alternate colorspaces for video game palettes.
by on (#165309)
May as well compare it against my colorspace:

Image

RGB 3.3.3, but red and blue share the LSB (so it fits in 8-bit). I came up with it because I honestly hate how little resolution blue has in RGB 3.3.2, which wouldn't be much of an issue except because it seems new "retro" hardware insists on using that (argh!).
Re: Possible alternate colorspaces for video game palettes.
by on (#165314)
I thought I'd try seeing how Sik's palette looks:

Attachment:
Sik's Palette.png
Sik's Palette.png [ 13.58 KiB | Viewed 5092 times ]
Re: Possible alternate colorspaces for video game palettes.
by on (#165318)
I thought of a different kind of colorspace: 3-bits high-voltage, 3-bits low-voltage, 3-bits phase. The phase only covers half, because you can get the rest of the phases by inverting it which is done by switching the voltage. If high-voltage and low-voltage is same then the picture will be gray.
Re: Possible alternate colorspaces for video game palettes.
by on (#165319)
Espozo wrote:
I always wondered how having 6bit RGB with 2 extra bits to reduce the value of the color for every channel.
tepples wrote:
It's the componentwise sum of the Cartesian product of four 2-bit palettes:
I assumed that Espozo meant something with a multiplier, not RGBI.

Here's the equivalent palette where I parse the last two bits as a all-channels multiplier that ranges from 1 to 4:
Attachment:
rgbmult.png
rgbmult.png [ 1.24 KiB | Viewed 5059 times ]


It's really lacking in pastels, though, so the parrot doesn't look so good:
Attachment:
File comment: left: plain
right: floyd-steinberg dithering

rgbmultparrot.png
rgbmultparrot.png [ 29.77 KiB | Viewed 5059 times ]
Re: Possible alternate colorspaces for video game palettes.
by on (#165320)
Actually his description sounds more like reverse RGBI, where I substracts instead of adding (you could achieve that just by passing I through a NOT). But yeah it's not very clear honestly.
Re: Possible alternate colorspaces for video game palettes.
by on (#165321)
Yeah, I didn't mean multiplying. I meant what Sik is talking about. I'm not sure how different than would look than tepples's though.
Re: Possible alternate colorspaces for video game palettes.
by on (#165324)
zzo38 wrote:
I thought of a different kind of colorspace: 3-bits high-voltage, 3-bits low-voltage, 3-bits phase. The phase only covers half, because you can get the rest of the phases by inverting it which is done by switching the voltage. If high-voltage and low-voltage is same then the picture will be gray.

That'd be HSL-ish, sort of like NES except including more desaturated midtones. It'd be simple to implement a composite output circuit for (assuming an 8*CB crystal), but I can't so easily show the parrot for this one because it has 8*8*8-8*7 = 456 colors, and GIMP won't quantize to palettes with more than 256 colors.

Sik's suggestion to subtract the intensity instead of adding it would be mathematically equivalent to the purely additive RGBI if defined as follows:

Red: #300, #700, #B00, #F00
Green (add): #030, #070, #0B0, #0F0
Blue (add): #003, #007, #00B, #00F
Intensity (subtract): #333, #222, #111, #000
Re: Possible alternate colorspaces for video game palettes.
by on (#165329)
Really the only difference is that the order of the colors has changed, but the available colors are pretty much the same. May as well just go with additive at that point and make everybody's lives easier.

Somebody should go and glue two EGAs together...
Re: Possible alternate colorspaces for video game palettes.
by on (#165396)
Something I remembered: I know some LCDs work by shifting hues instead of shifting luminance. What about a colorspace where you layer both kind of LCDs on top of each other? Would it have been a reliable way to get color on early handhelds without eating battery like hell? Biggest problem (aside from the obvious blurring) is that saturation would be always at max. Still, would be a fun experiment to think about.
Re: Possible alternate colorspaces for video game palettes.
by on (#165399)
So-called "Electronically Controlled Birefringence" Displays are achievable (scroll down to "COF LCD module"). They have a rather peculiar color palette, though.

There was a Pokemon-themed pedometer that used it. (video)
Re: Possible alternate colorspaces for video game palettes.
by on (#165403)
So wait, their range can be stretched to do more than just a hue shift? Because that actually seems more useful. (my original idea was to use that for hue and then another display on top that was monochrome for luminance)
Re: Possible alternate colorspaces for video game palettes.
by on (#165489)
Here's another idea: HSL 4.2.2

  • When bits 7-4 are 0000, the color is grayscale and bits 3-0 are the luminance.
  • Otherwise, bits 7-4 specify hue (in steps of 24º), bits 3-2 the saturation (25%,50%,75%,100%) and bits 1-0 the luminance (20%,40%,60%,80%).

EDIT: fixed my HSL algorithm and ditched the old image

Image

Still leaves a lot to be desired.
Re: Possible alternate colorspaces for video game palettes.
by on (#165503)
Sik wrote:
Image

I like the colors, but fading in this color space looks complicated, especially since grays are treated differently.
Re: Possible alternate colorspaces for video game palettes.
by on (#165517)
I think that fading is hell with most of the colorspaces mentioned here though =P Would make for a good default 256 colors palette though.

I'm not happy with how coarse luminance turns out to be, though =/
Re: Possible alternate colorspaces for video game palettes.
by on (#165540)
Why does the highest luminance level also lower saturation? Saturation increases perceptual brightness, so that seems counterproductive, not to mention redundant.
Re: Possible alternate colorspaces for video game palettes.
by on (#165556)
That's how HSL works, maybe you were thinking on HSV instead?
Re: Possible alternate colorspaces for video game palettes.
by on (#165594)
I was thinking purely in terms of getting the most usable colors out of the palette. Now that you mention it though, HSV is probably what I was suggesting.
Re: Possible alternate colorspaces for video game palettes.
by on (#165603)
OK giving a try to HSV (same format otherwise), assuming I got the calculation right (was expecting this to be harder):

Image
Re: Possible alternate colorspaces for video game palettes.
by on (#165607)
So, in order to fade to black you'd alternate between decreasing V and increasing S, and to fade to white you'd alternate between decreasing S and increasing V?
Re: Possible alternate colorspaces for video game palettes.
by on (#166952)
Last time I tried making an 8-bit color space with a good luminance range I ended up with this quite arbitrary palette:

Image

I found that the RGBI palette that tepples posted earlier could be rearranged to emphasize grayscales but still have all the same colors.

Attachment:
2016-03-27_2bit-BRGI.png
2016-03-27_2bit-BRGI.png [ 948 Bytes | Viewed 3036 times ]

Code:
Index: bbrrgggg
R = gggg + rr00
G = gggg
B = gggg + bb00

This would be the palette I would use if I was designing another Uzebox or something. Maybe replace the additions with XORs to simplify circuit design.
Re: Possible alternate colorspaces for video game palettes.
by on (#166962)
JRoatch wrote:
Index: bbrrgggg
R = gggg + rr00
G = gggg
B = gggg + bb00
If the digital values are just converted linearly there's no greens at all:
Attachment:
bbrrgggg_addition.png
bbrrgggg_addition.png [ 1.24 KiB | Viewed 2999 times ]

If you normalize green so it's the same range (i.e. scale up from 0-15 up to R and B's 0-27), it's ... ok?
Attachment:
bbrrgggg_addition_normalized.png
bbrrgggg_addition_normalized.png [ 1.32 KiB | Viewed 2999 times ]

Quote:
replace the additions with XORs

That produces an interesting set of colors:
Attachment:
bbrrgggg_xor.png
bbrrgggg_xor.png [ 1.35 KiB | Viewed 2999 times ]
Re: Possible alternate colorspaces for video game palettes.
by on (#166969)
Ahh sorry lidnariq, my mistake. I was implying 4 bit values and results with those modular additions, and I see that I accidentally swapped my red and blue in that pseudocode.

A small python 3 program that correctly generates it as a GIMP Palette is:
Code:
print("""GIMP Palette
Name: RGBI Arranged.
Columns: 16
#""")
for i in range(256):
    print(((((i>>4)&0xc)+i)&0xf)*17, (i&0xf)*17, ((((i>>2)&0xc)+i)&0xf)*17)