In the past I’ve used simple 16 or 256-colour palette-indexed images as a simple way to store and edit map (or in my case voxel) data but any attempts to import a 16-colour palette-indexed image in Godot converts it to a RGB8 version. Is there any way to do this (other than writing some custom class).
Did you try importing as an Image instead of a Texture2D? That may keep the format. Not sure what it does to the palette. Godot does not have a concept of a palette by default.
I’ve been using Image (I did try Texture2D as well) - it seems to hard-code convert it to RGB8. Have also set to ‘Keep File’ and done Image.LoadFromFile which does the same thing. Looks like some kind of custom loader then :).
Yeah, the reason behind this is there’s barely any benefit in modern machines to use indexed color. Think of it as an ancient compression method. The GPU can use such an image, but you’d need to figure out how to pass the palette to the shader, and currently godot doesn’t have buffer textures, so that’s gonna be a bit complicated unless you use a fixed number of color indices.
It is for sure much easier and memory efficient to use RGB8 textures, because then they can be atlased together. If you want to do palette swapping, an easier way is to have a regular texture, but interpret certain color ranges in the shader, so you can do, for example, the thing Left4Dead2 did with clothes, where the lower half of the colors were a layer and the upper half another layer, all rebuilt in the shader. But that’s as complicated as writing a custom importer, so
Makes total sense but I’m not using them as actual displayed images, its just a convenient way to specify 2d tilemap style data (e.g. colour 1 = a block of rock, colour 2 = a block of metal etc.) without writing some kind of custom editor (I could just use a regular Tilemap ofc). I ended up importing System.Drawing.Common and using GDI to load it in.
For that usage it’d be much easier to write a simple parser that read the image colors in whatever format it was imported and the indexed palette from a text file. That way you don’t lose the meaning of your indices to palette ordering changes.
(tho remember godot can import Tiled maps)