It is currently Tue Oct 17, 2017 5:25 pm

 All times are UTC - 7 hours

### Forum rules

Related:
• For making cartridges of your Super NES games, see Reproduction.

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Color palette generatorPosted: Sun Jul 03, 2016 10:52 am

Joined: Wed May 19, 2010 6:12 pm
Posts: 2282
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).

Top

 Post subject: Re: Color palette generatorPosted: Sun Jul 03, 2016 11:45 pm

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7224
Location: Chexbres, VD, Switzerland
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).

Top

 Post subject: Re: Color palette generatorPosted: Wed Jul 06, 2016 2:09 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2282
Anyone know how to clip the saturation of a color? It appears a lot harder than I thought.

Top

 Post subject: Re: Color palette generatorPosted: Wed Jul 06, 2016 11:43 pm

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7224
Location: Chexbres, VD, Switzerland
What do you mean exactly by "clip the saturation of a colour" ?

Top

 Post subject: Re: Color palette generatorPosted: Thu Jul 07, 2016 5:31 am

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19091
Location: NE Indiana, USA (NTSC)
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.

Top

 Post subject: Re: Color palette generatorPosted: Thu Jul 07, 2016 7:51 am

Joined: Thu Aug 12, 2010 3:43 am
Posts: 1589
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)

Top

 Post subject: Re: Color palette generatorPosted: Thu Jul 07, 2016 8:31 am

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19091
Location: NE Indiana, USA (NTSC)
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.

Top

 Post subject: Re: Color palette generatorPosted: Fri Jul 08, 2016 5:05 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2282
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.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 8 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: Troglodyte, Yahoo [Bot] and 5 guests

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

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki