Today I have an idea for a new project. Create an SNES ROM that generates a color palette using math. Since the SNES has 256 palette entries, I'll try using a palette that uses 5 lumas, 24 hues, and 2 saturations, plus 7 shades of grey. This gives me 5*24*2+7=247 colors. Hue and Saturation would be adjusted using the D-pad.
The way the colors are going to be generated are the following:
-First it will calculate the magnitude of 2 color axis using the hue and saturation information. We'll call them A and B.
-Then it will calculate the R-Y, G-Y and B-Y with the following formula:
R-Y = -2(A+B)
G-Y = A
B-Y = 5B
-Then it will add the color differences to 5 8-bit luma values. The luma values have a gamma curve of y=x^2.
-Then it will detect clipping, and adjust saturation accordingly.
-Then it will reduce the bit depth to 5 bits per color channel, with a gamma curve of y=sqrt(x).
Sounds pretty cool. This'd be mostly useful for graphical modes that does indeed allow to use the 256 colours, I believe it's mode 3, 4 and 7 (correct me if I'm wrong).
Anyone know how to clip the saturation of a color? It appears a lot harder than I thought.
What do you mean exactly by "clip the saturation of a colour" ?
I assume it refers to situations where applying the transformation from YUV or YIQ to RGB would produce component intensity less than 0 or greater than full scale.
As for greater than full scale: Try not making white ($20/$30) full scale. Make it #F0F0F0 or something to give headroom for colors that exceed that value.
As for less than zero: Many TVs during the NES era weren't perfectly adjusted. The misleading names of "brightness" and "contrast" knobs (really black level and signal amplification) didn't help matters. Try making black #0F0F0F and seeing if that helps.
tepples wrote:
The misleading names of "brightness" and "contrast" knobs (really black level and signal amplification) didn't help matters.
Oooooh so
that is how they worked. Nice to know. So wait, this means the best setting would be 0% brightness and 100% contrast? o.o (actually probably not 0% brightness since CRT response is not linear)
On a CRT, you should set "contrast" the way you'd set "backlight brightness" on an LCD, so that neither the TV nor room lighting overpowers the other.
The "brightness" knob exists for two reasons. One is that the NTSC signal doesn't contain a reliable reference for black level. Set it too low, and the black level adjustment will end up producing negative luma levels, crushing shadows. The other is that TV screens aren't completely black; they reflect some room light even when luma is 0. Leaving black level at minimum may cause room light to overpower shadows in that case as well. On displays whose black level is set too low, some parts of Haunted: Halloween '85 will be nearly invisible because the artist insisted on using a lot of $06, $07, and $08.
I was looking up different colorspaces and found it looks like Hunter-Lab decreases saturation towards black. It's something similar to this:
Y = L^2
X = a*L + Y
Z = b*L + Y
The weird thing about Lab color space is that blue is placed in a weird spot. In my opinion it's too far from cyan, and too close to red.