top of page
LogoScaled.png

PALETTE INDEXING

FUTURE PLANS:

As mentioned, the Sprite Editor (and Tile Map Editor) save images to multiple files:

NandiFrontFiles.png

"Master sprite" on the left containing colored pixels; separate textures for each unique color containing only white pixels are used in palette indexing

This allows the engine to create unique texture IDs for each individual color in a sprite. This is necessary for palette indexing (unless there's something I haven't thought of), but there's a more efficient way to save the data.

​

Internally, the editors use custom types Color Buffers and Texture Buffers to store and modify image data.

Texture Buffers
 store pixel data that can be sent to the graphics system to create textures. They contain a buffer for each unique color in the texture, and pixels are either white or transparent like those shown in the image above.


Color Buffers simply store the data as an array of color indices - this is the most efficient way to store the data. We don't need RGBA values for a sprite - those get assigned by the palette manager.

​

Color Buffers can be converted to Texture Buffers and vice versa, and both can write to disk - their data is combined with a palette to create a "master sprite" containing all the colors in the texture

TextureDiagram.png

Color Buffer on the left containing an array of color indices (stored as chars); Texture Buffer on the right containing arrays of pixel data for each unique color. Both can write colored image files to disk.

Rather than saving multiple image files for each sprite, I could just save the master sprite and a custom binary file format that contains the color buffer data. Internally, the color buffer can have its data converted and sent to the graphics system to create textures; they don't need to be read directly from disk.

bottom of page