Depending on the hardware some games do actually run on an Color Table or Index based graphics engine.
But it is not necessary to run in an indexed color mode (some graphics APIs such as OpenGL give you the option) as you can write your own code to handle color palettes.
You can totally alter image data using Pixel Shaders:
http://en.wikipedia.org/wiki/Shaderhttp://www.facewound.com/tutorials/shader1/Many different effects can be achieved including palette swaps.
How you write the Shader to handle the color swap is very flexible.
The data can be passed in as RGBA values or you could pass in a tiny texture that has your palette of choice lined up.
Then using some simple index math you can access each of the colors as if it were an array.
Conceptually it would be something like this:
But really you could pass in a texture with a single pixel of each color (I've made a 2x2 just for a bit more clarity):
So now that you have a base table if you pass in another palette as a texture:
you can compare them and make the color swaps inside the shader.
This is HLSL code:
float4 ColorSwap(InStruct data) : COLOR <-------- Pixel Shader function signature
{
float4 color = tex2D(image, data.texel); <-------- Get the image data of the current texel
if(color == colorTable1(0)) <-------- Compare current texel color to the "Base" Color Table's index 0
color = colorTable2(0); <-------- Swap the current texel color to the new Color Table's index 0
if(color == colorTable1(1)) <-------- Compare current texel color to the "Base" Color Table's index 1
color = colorTable2(1); <-------- Swap the current texel color to the new Color Table's index 1
.....for each index......
return color; <-------- Set the current texel color to be drawn
}
Of course if you're looking to do something like this it requires some prerequisites:
- C and C++ coding knowledge
- DirectX, OpenGL or some other graphics API
- HLSL or GLSL or other Shading language
- Basic game engine
If you are not a coder some of the more "Game Maker" type programs also support Shaders.
I know that MultimediaFuison2 HWA does. Not sure what other programs do.
There is a few decent packs of Shaders that you can download for MMF2.
But if you want to make your own you'd have to learn HLSL or some similar shading language.
I want to do another post about how to do quick palette swaps in Graphics Gale.
But I'm off to eat lunch.