Closed ultraq closed 3 years ago
Having now played around with this, I'm finding the changes needed to make uses of palettes wherever they are, isn't making for the best design IMO. Some image formats already contain palettes so should only ever make use of those, and writing code to know which is which is making things messy. Also, in those cases of 1-to-1 relationships between indexed data and a palette, using up more VRAM to store a complete image and then pull it up with a simpler shader instead of doing colour table lookup jazz is actually much faster!
With these images being not that large, and VRAM a plenty on the machines I'm targeting (and pretty much any computer nowadays), I think limiting the paletted texture shader to only those images that really need it from the design perspective (eg: units/structures which need to change colour based on sides) will be the best use of that kind of shader. Not sure where animations based on palette swaps fits in just yet, but I think that's one that needs it too (eg: map tiles with "glowing water").
Branch: https://github.com/ultraq/redhorizon/tree/palette-shader
For future reference: so I came back to this because I wanted to be able to faction/palette swap in the unit viewer at the press of a button. So now there's a palette shader for units 😁
Learning modern OpenGL, I'm starting to think I can perform palette-swapping operations in a fragment shader as a massive performance improvement:
I'm still making my way up to textures across various tutorials so I can then drop the legacy renderer, but this should be a neat way to perform palette swaps which for classic games like C&C!
https://gamedev.stackexchange.com/questions/43294/creating-a-retro-style-palette-swapping-effect-in-opengl