Changing colour palettes is possible? (Game Boy Color style)

Hello everyone!

I’m working in a game that tries to emulate a Game Boy game (4 colors only, resolution…). I was thinking that I would like to do something like it was possible in GBColor, changing palettes (I mean, maybe making a shader or something like that that changes the 4 shades of grey I use in my project to already defined 4 colour palettes).

Something like this:

Is this possible? (I don’t know anything about shaders, was searching for info, but only found something like this for Game Maker Studio). And if it is, any tips on how to make a workarround for it?

Thanks in advance!

I think I’d do this on the CPU side. Just using color indices (0 to 3) in the game itself and fetching the color from the active palette. Though remapping colors in a shader by rounding them down and indexing into an array is possible too.

I have done emulation of early 80’s arcade machines in XNA, and we created a virtual frame buffer in memory, such as Color[] frameBuffer = new Color[Width * Height]. We constructed the frame into this virtual frame buffer before calling frameBufferTexture.SetData(frameBuffer) where frameBuffer is a Texture2D of the same width and height. We would take the current palette into account when building the frame into the virtual frame buffer, so it was all done by the CPU.