I was able to port Bisqwit’s NES palette generator to a shader, utilizing the the ‘raw’ palette in Nestopia and FCEUmm cores that encodes the NES PPU’s raw chroma, level, and emphasis bits into a RGB pixel. If you use any other palette beside ‘raw’, it will not work.
I ported the shader to each of the shader formats supported by RetroArch:
Cg: https://github.com/libretro/common-shaders/blob/master/misc/nes-color-decoder.cg GLSL: https://github.com/hizzlekizzle/glsl-shaders/blob/master/misc/nes-color-decoder.glsl Slang: https://github.com/libretro/slang-shaders/blob/master/misc/nes-color-decoder.slang
The are three versions of the shader in each repo that have different YIQ to RGB conversion matrices that can result in different color outputs. The different YIQ to RGB conversion matrices are now included in a single shader, with a runtime parameter to toggle the Sony matrix.
See: http://hitmen.c02.at/temp/palstuff/ under YIQ (NTSC) for the conversion matrices used. The non-Sony ones seem to generate almost the same colors in most instances but I included both anyway.
I included presets for this shader in the cgp directory (or presets directory in slang), of which nes-color-decoder+pixellate should provide the simplest image.
The shader has parameters to adjust saturation, hue, brightness, contrast, and gamma so you will be able to adjust the color output to how your TV is configured. Keep in mind that there are some colors that can be shown on real hardware that will get clipped on sRGB at higher saturation, particularly the blue colors. There is a parameter to change the method by which out-of-gamut colors are clipped.
Screenshots:
Input with ‘raw’ palette:
nes-color-decoder output (FCC matrix):
nes-color-decoder output (Sony CXA2025AS US matrix)
nes-color-decoder output (Popular non-FCC matrix)