-
Notifications
You must be signed in to change notification settings - Fork 164
Description
Problem
Currently 8-bit games may be run by Direct3D/OpenGL renderers pretty much fine, so long as they don't have any dynamic palette changes. Dynamic palette changes may not get reflected on screen in time, because there's no proper mechanism for forcing object texture update when this happens.
Potential solutions
Palette is changed in script using functions: CyclePalette and SetPalRGB , and also by directly editing palette array and then calling UpdatePalette() which syncs that array with the internal palette. Because in any case there will be a function call, these may serve as a trigger for update.
The most straightforward approach may be forcing every current texture to update from the source sprite when the palette change is detected. All the textures prepared for the game objects has to be redrawn from the sprites and corresponding cached bitmaps (for objects and characters).
However, this may not be the most efficient method. While some games may have occasional color change, others feature continuous palette cycling as a way to create full-screen animations. In the second case every single one of the currently displayed textures would have to be repainted over with the new palette every frame for this to work.
An alternate and more interesting approach is to implement a palette-emulating shader. If this is done, then only the shader has to be recreated (or nothing at all - if the shader accepts a palette array as an argument). This supposedly will have many times better perfomance, and easier to maintain, as the shader will be applied to everything uniformly so no changes are going to be required if we introduce more object textures.