It is currently Mon Dec 18, 2017 9:49 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: NES color palette - why?
PostPosted: Fri Mar 28, 2014 10:28 pm 
Offline

Joined: Wed Dec 04, 2013 5:29 pm
Posts: 6
The NES has a 64 color palette, but 9 of those colors are black. Does anyone know why? Was it due to hardware limitations or poor design? It's a simple question but Google couldn't tell me.

Also, why does the NES have more blues than greens or reds? It seems like a strange choice.


Top
 Profile  
 
PostPosted: Fri Mar 28, 2014 10:55 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10173
Location: Rio de Janeiro - Brazil
The NES palette wasn't designed in the sense that someone picked a nice set of colors that artists would like to use in their games, it was designed to be easily generated by simple hardware. If you have to put it this way, yes, it's a hardware limitation.

I can't explain the specifics (I'm sure someone else who understands PAL and NTSC signals in great detail will), but NES colors are generated by square waves of different frequencies, and I'm sure Nintendo was as cheap as possible when deciding how to calculate these waves.

This page explains a bit about how the video signal is generated (I can't understand most of it!).


Top
 Profile  
 
PostPosted: Fri Mar 28, 2014 11:02 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
The color video signal is generated by 12 different possible square waves, each is delayed 0 to 11 master clock cycles. They can be at 4 different brightness levels. So that's 48 colors there.
Then the first column has no color and is only gray, it has three different brightness levels, then a second copy of white.
Then there's that column that has weird black (blacker than black), black, and two gray levels.
Then the rest of the colors are all black for some reason.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Fri Mar 28, 2014 11:13 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6540
Location: Seattle
The NES palette is natively generated in the YIQ color space: one choice of hue or saturation, and one choice of brightness. A lot of the nitty-gritty is described on our wiki.

Why only twelve angles, in contrast to the 2600's fifteen? The 2600 generates its colors using a series of inverters and RC delays to produce a series of angles around the color wheel. This process is analog, and so comparatively sensitive to noise, voltage rail fluctuations, and process variation. The NES, on the other hand, uses a series of clock dividers for an all-digital color signal until the final output DAC; in this manner a master clock of 6× the color subcarrier for the region (NTSC: 3.58MHz; PAL: 4.43MHz) can produce 12 different hues.

So why not a 7× crystal? Dividing by odd numbers is more complicated (while maintaining a 50% duty cycle) than dividing by even numbers. It would also have made the pixel clock different, and so implied a different number of pixels horizontally on screen (240 or 300 instead of 256). Nintendo may have started with the width (inherited from many of its predecessors, including the ColecoVision) and worked from there; at this point they would have to pick some multiple of 10.7MHz to both generate the (5.4MHz) pixel clock and the color subcarrier (3.6MHz).

How did they choose the specific brightnesses they did, and why did they not provide more? That I can't say. There's a lot of room within the same fundamental structure (selecting one of 12 different clock phases, driving different taps on a DAC) for a much wider range of brightnesses and saturations then they provided. Without any other changes at all, they could have added a single wire to provide four extra shades of grey (the average of the $x0 and $xD greys, even though those would be fairly close to the five greys already provided).


Top
 Profile  
 
PostPosted: Sat Mar 29, 2014 8:49 pm 
Offline
User avatar

Joined: Fri Aug 23, 2013 2:14 am
Posts: 264
So would that be the reason why the NES doesn't have a proper yellow? Unless this was considered a normal way to generate colors, it seems quite awkward using square waves.


Top
 Profile  
 
PostPosted: Sat Mar 29, 2014 9:30 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6540
Location: Seattle
OneCrudeDude wrote:
Unless this was considered a normal way to generate colors, it seems quite awkward using square waves.
The square waves is actually just a red herring. (The difference between a square wave and the sine wave that it's supposed to be, as far as NTSC is concerned, will only be visible with neighboring pixels of differing colors. By the Fourier transform, a square wave is made of a set of sine waves of odd multiples of the fundamental, but the first overtone at 3×3.6MHz is well above the 5-7MHz bandwidth of NTSC).
OneCrudeDude wrote:
So would that be the reason why the NES doesn't have a proper yellow?
The lackluster color set is because the NES's phases are evenly spaced around the YIQ colorspace (every 30°). The only colors (per the vectorscopes that were used to diagnose NTSC color woes) that happened to align to the 2C02's output were purple (+120°) and green(-60°).

The PAL NES's colorspace is rotated by 15° relative to the NTSC NES, and so provides a comparatively nice red (+75°), yellow (+15°), blue (-165°) and cyan (-105°), at the cost of less satisfying purple and green. The lack of control over saturation is still unfortunate.


Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 12:30 pm 
Offline

Joined: Wed Dec 04, 2013 5:29 pm
Posts: 6
Thanks for picking up my question so quickly! You guys are great :)

OK, so my understanding so far is that the NES can generate 12 hues (actually delayed square waves?) at 4 different brightness levels, 12 * 4 = 48 colors. These hues (and colors) are not hand-picked but are evenly spaced along the YIQ color wheel. The hardware could have supported another 2 hues (thus 8 more colors) but this would require dividing 7 by 2 and would have made programming more complicated, so they didn't do it. Uh, why not an 8x crystal then? 16 * 4 = 64, which seems perfect... Anyway this is the reason those colors are unused, just copies of black.

If I'm not getting it could you explain it to me like I'm five? I think I need a more intuitive understanding before I can get into things like vectorscopes.


Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 1:38 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19356
Location: NE Indiana, USA (NTSC)
An 8x crystal would have meant no grays.


Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 2:12 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6540
Location: Seattle
seven wrote:
Uh, why not an 8x crystal then? 16 * 4 = 64, which seems perfect...
Well, two possible things:
1- That doesn't leave any space for any greys. Retaining the greys would have required omitting some phase, which .. while doable, I'm not certain what they'd pick. (If you had to omit a column of color from the 2600's palette, how would you choose?)
2- That still implies a different number of pixels horizontally on a line. The two closest possible on-screen widths would be 272 (×8÷5) or ≈224 (×8÷6) (instead of 256 (×6÷4))

I'm also under the impression, based on what people have said when they've talked about drawing for the NES, that the set of hues the NES provides, while restrictive, isn't really the problem; they usually wish they had access to more varied choices of brightness (and occasionally saturation).

As a (hopefully not misleading?) example, the Wikipedia articles on color palettes use a picture of a parrot and a color test chart. If I quantize each of hue/saturation/brightness to the 12 hues/boolean saturation/4 brightnesses the NES can provide, while letting the other properties vary continuously, I get the following pictures:
Attachment:
color-test-chart-quantized.png
color-test-chart-quantized.png [ 7.83 KiB | Viewed 3054 times ]
(The color test chart doesn't have a "yes/no saturation" demonstration because the image is fully saturated)
Attachment:
parrot-quantized.jpg
parrot-quantized.jpg [ 65.35 KiB | Viewed 3054 times ]


Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 3:00 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19356
Location: NE Indiana, USA (NTSC)
lidnariq wrote:
2- That still implies a different number of pixels horizontally on a line. The two closest possible on-screen widths would be 272 (×8÷5) or ≈224 (×8÷6) (instead of 256 (×6÷4))

At least CB×8÷5 would have been closer to square pixels. (Exact square pixels are CB×12÷7.)


Top
 Profile  
 
PostPosted: Wed Apr 02, 2014 11:52 am 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1248
I think, all things considered, the NES's palette is extremely capable; it's mostly the limited number of simultaneous colors that tends to be the wrench, at least for me.

At least, when you work with limited RGB based palettes (like R, G, and B all being 2 bits), it's hard to get the color you want because red, green, and blue all have different luminosities, and to get the brightness you want, you often have to skew the hue or deal with desaturating it, and although RGB is a simpler concept to grasp, the NES's luma/chroma system offers a better selection of colors that are more balanced overall, so I tend to prefer that. Yeah, not having finer control over saturation is a pain sometimes, but with a little practice, any pixel artist should be able to overcome it.


Top
 Profile  
 
PostPosted: Thu Apr 03, 2014 6:30 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2433
I always wondered how an extended version of the NES color palette would've looked like.

Maybe have it in the format:
Code:
ppppllllhhhh
p: phase
l: lower bound (0 is -.333, 15 is 1.333)
w: higher bound (0 is -.333, 15 is 1.333)


and have a ROM table lookup of the best 256 colors, with the first 64 colors from the original palette.


Last edited by psycopathicteen on Thu Apr 03, 2014 8:17 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Apr 03, 2014 7:24 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6540
Location: Seattle
For NTSC, it turns out that if you have a N-bit DAC clocked at exactly 3×CB, you can map each of the three samples in sequence to an R, G, and B component. You don't even need a real modulator; just the right choice of RGB to produce hue -U for colorburst.

In any case, the problem with the NES is mostly figuring out how to represent a useful palette and pack it into 8 bits. Above 8 bits, I figure you may as well provide a TrueColor representation, even with the caveats that Drag mentioned.

The 2600's 3 bits of luma, 4 bits of hue is pretty good. If I were going to extend the NES's master palette, I'd probably use that, and maybe add a bit for high/low saturation.

Using a 7× crystal has the nifty property that 7/4 is very very close to 12/7: the pixel aspect ratio is 48/49. It'd be ~300 pixels wide at that dotclock.

I might also try something a little more like what the NES provides, but not coupling high and low lumas together.
- three bits of phase information (none, 6 from a half of the NES palette, one for averages of luma for extra greys)
- three bits of luma_1 (maybe 0,2,4,6,8,10,12,14)
- two bits of luma_2 (maybe 1,5,9,13)
You only need half the phase information here because part of it's encoded in whether luma_1 > luma_2 or vice versa.


Top
 Profile  
 
PostPosted: Sat Apr 05, 2014 1:38 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2433
Wouldn't you need luma values over 100% for a fully saturated yellow?


Top
 Profile  
 
PostPosted: Sat Apr 05, 2014 4:50 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6540
Location: Seattle
Yeah. We're kinda hamstrung by the standards inadvertently specifying the intersection of the RGB colorspace with the YIQ colorspace. And if we generate the video natively in HSL (phase/amplitude/DC), that's a third colorspace constraint, leading to either a lot of desaturated colors or a lot of out of gamut ones.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group