Max colour output

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Molive
Posts: 50
Joined: Sat Apr 07, 2018 7:39 pm
Location: EN

Max colour output

Post by Molive »

Hey guys.

I've been trying to think about what the limits are on colours on the snes, and I couldn't quite work it out.
Using just colour math, and possibly hdma, what is the limit on the colours per frame on snes?
I worked out maybe 4096 colours was possible, but can you hit the 32768 colour limit?

Thanks,
Molive.
SNES demos are great
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Max colour output

Post by lidnariq »

GoodSNES has a "32768 Color Demo by Joshua Cain".

Clever abuse probably could invent a few more colors using the display brightness control, since reportedly that has its own 4 bit DAC that multiplies the RGB channels' 5 bit DACs in analog.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Max colour output

Post by tepples »

Combining color math with pseudo-hires can generate (2*sub+main+COLDATA)/4 and (3*sub+main)/4, in theory allowing for even more intermediate colors.
Molive
Posts: 50
Joined: Sat Apr 07, 2018 7:39 pm
Location: EN

Re: Max colour output

Post by Molive »

That 32768 colour demo seems to use hdma to force the same R colour per scanline, which means that it can't be used for arbitrary images :/
Is there other ways?
SNES demos are great
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Max colour output

Post by tepples »

The biggest limit you'll hit in full screen is VRAM. An 8 bit per pixel 256x224 pixel image with all unique tiles already takes 58K of the 64K of VRAM: 56K for the tiles and 2K for the map.

If you letterbox to 256x160, you can go 12 bits per pixel (4 bits per channel) by using color math in mode 3 to add an 8bpp "direct color" image (3 bits red, 3 bits green, 2 bits blue) with a 4bpp low bits image (1 bit red, 1 bit green, 2 bits blue). This takes 60K for the tiles and 4K for the map, leaving nothing for sprites. You can use software sprites. If you want a larger image or some VRAM for hardware sprite tiles (which are limited to 4bpp), you can repeat tiles in the tilemap.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Max colour output

Post by lidnariq »

There's the DMA hack that 93143 invented, allowing displaying a 64x224x15bpp image (4x1 pixel blocks).

Basically the SNES analog of the equivalent Genesis DMA hack (that displays 160x224x9bpp).

But honestly, you're going to get perfectly adequate results with just an 8bpp paletted image; you might need to hunt down a good quantizer. (Bisqwit's animmerger includes a wide variety)
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Max colour output

Post by psycopathicteen »

Normal circumstances it's 256 colors. It can be up to 32768 colors if using transparency, or HDMA tricks.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Max colour output

Post by dougeff »

I feel like with color math, you should be able to push an additional 3 bits of color variation onto a max palette of 256.

256x2x2x2 = 2048.

Then adjust the screen brightness 16 times a frame.

2048x16=32768...

actually, screen brightness zero = black so... 15

2048x15+black=30721
Last edited by dougeff on Sat Sep 22, 2018 5:02 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Max colour output

Post by lidnariq »

That's basically the method that tepples pointed out. Start out with a R3G3B2 image, use color math to add a R1G1B2 layer on top to get R4G4B4. But you run out of data to store pixel data: 65536 bytes is only enough to store 43k pixels at 12bpp. Hence his comment about letterboxing it.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Max colour output

Post by dougeff »

Thought. If someone makes a retro console in the future.

5 bits per color is really more than the human eye can differentiate. They should have gone 4 bits per color, and used the extra 4 bits for alpha (transparency). Then they could have eliminated all that color math difficulty.
nesdoug.com -- blog/tutorial on programming for the NES
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Max colour output

Post by psycopathicteen »

I could still can tell shades between colors in 15-bit colors most of of the time.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Max colour output

Post by lidnariq »

In the Not-Quite-So-Bad-Old-Days, image viewing software often had an option to dither its output for 15- or 16- bit displays. Color banding is really obvious otherwise.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Max colour output

Post by tepples »

As an experiment, I scaled "Nethil and Sarah's bunny", a photo of two plushies, to 256x224 pixels and bit-crushed it using twelve settings: six depths (R5G5B5, R4G4B4, R3G3B3, R3G3B2, 8bpp with optimized palette, and 4bpp with optimized palette) and two dithering types (off or Bayer). I can see the banding on R5G5B5, particularly on the white area in the background.

In my subjective opinion, the 8bpp with optimized palette version looks as good as R4G4B4. The 4bpp version doesn't look quite as good as the R3G3B2 version, but better is possible by choosing different 15-color palettes for different parts of the picture. (My software doesn't do that.)


If you're curious about the lore behind this photo, let me know and I'll explain the back story of Nethil (the one in the yellow shirt).
Attachments
allbig.png
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Max colour output

Post by 93143 »

dougeff wrote:Then they could have eliminated all that color math difficulty.
The N64 tried replacing "color math" with alpha, and look where it got them. They had to shove in additive blending at the last second, and it ended up basically useless anyway because they hadn't bothered to clamp the output of the blender, on the grounds that alpha blending with clamped sources can't overflow. This is why glow effects sucked on the N64.

Also, with alpha blending you still have to worry about what you're blending it with. The SNES could do exactly one blend operation per pixel. By "retro console" I assume you mean something with a linear constant-time renderer like the S-PPU, as opposed to a framebuffer blitter like the RCP; in that context it seems to me you'd have to devote a fair amount of silicon to pixel blending if you wanted to avoid the main screen/subscreen limitation and blend anything with anything else.

I wonder if it would have been feasible to allow individual sprites to be sent to either the main screen or the subscreen (basically having two linebuffers). It's a pretty harsh limitation to never be able to blend sprites with each other at all, ever... It would probably have cost more silicon than they wanted to spend on a feature that was already way beyond anything their competition could do...
psycopathicteen wrote:I could still can tell shades between colors in 15-bit colors most of of the time.
Even with 24-bit colour you can see banding under certain circumstances. The human eye is way better at telling the difference between shades when they're right next to one another.
Molive
Posts: 50
Joined: Sat Apr 07, 2018 7:39 pm
Location: EN

Re: Max colour output

Post by Molive »

Tepples:

That image may be quite good under just 256 colours: I think it looks better even, as you're in a 5-5-5 colour space compared to the 4-4-4.
However if you really wanted to show off the 4-4-4 colour space you'd have to use a really high colour image which ends up using more than 256 colours from that space. Currently the bunny one probably uses less than the one from the pallette mode.

That's why this scene from Overdrive looks so weird, there's a huge colour range in it.
Attachments
512C.png
SNES demos are great
Post Reply