D2X-XL Worklog
Notes on features and problems from the development of D2X-XL, newest first.
Better Palette And Color Handling |
|
To this day, D2X-XL has been plagued by miscolored menus and Descent 1 exit sequences. I had figured a solution for this problem a long time ago already, but since it required some major recoding of all color and palette handling in D2X-XL, it was only this week that I finally tackled that task. Some tech background. A palette is table containing 'real' (RGB) color values. It's main purpose is to save texture memory: If a texture only contains a limited set of colors (let's say: No more than 256), a palette is created containing these colors, and instead of storing the 4 byte RGBA color value for each pixel, a one byte index into the palette is stored. Backdraws of this method are:
Since memory was more precious when Descent 1 and 2 were created, Parallax chose to go this way. So far so good. Parallax however chose to use several palettes, depending on image type (one for color fonts, one for backgroundimages, one for wall and object textures ...), and that is what the guys porting D2 to OpenGL stumbled over. Each texture had to be temporarily converted to an RGBA image for rendering by OpenGL. Instead of keeping several palettes and assigning a reference to its palette to each image, the D2X makers chose to use one global palette. To makeimages being based on another than the current global palette work with it, they created code that remapped suchimages' colors to the global palette. Now go figure how easy it is to foul up that remapping process. The entire palette handling introduced by Parallax/the D2X team was a mess. D2X-XL v1.6.178 and up now keeps track of all palettes used in the program, and assigns a reference to the palette its based on to each (palettized) image in the game. That means that there is no (time consuming and error prone) color remapping any more. A nice side effect of this is that Descent 1 textures are now being rendered using the original Descent 1 game palette, and are not being remapped to Descent 2's groupa palette. Above that, palette and color selection operations are now significantly faster than before (you won't notice that speedup though, as it's already in the 'supersonic' realm.). A second measure I took to steer clear of palette problems was to use true RGB colors wherever applicable (e.g. in-game index and automap). This removes color changes due to use of different game palettes (as Descent 2 has). In the process of rebuilding this code I had to change a lot. If you notice any miscolored stuff in D2X-XL, please file a bug report on SF.net and attach a screenshot showing the problem. |


