#131
Posted Yesterday, 03:15 PM
First, a short explanation on how colors on Duke3D and most DOS FPS worked. Unlike a modern computer game, where the framebuffer is stored with separate red green and blue channels, the framebuffer instead contained indices into a 256 color palette. This allows some neat tricks such as tinting the entire screen by just updating those 256 entries, rather than 64 000 or more pixels. Another trick is shading. Instead of doing 3 multiplies (very expensive on the CPUs at the time, and forget about SIMD) for each pixel, you use a lookup table. Lookup tables could also be used for blending different colors (for semitransparency effects) or having different color variants of an enemy such as the liztroop.
Now fast forward twenty or so years, hardware rendering is now the norm and multiplies are cheap. But the result doesn't look the same. The solution is to store the texture in the original 256 color palette, then do the lookup in a shader as it's drawn, just like original game did on the CPU. Works great until you turn on texture filtering then it falls apart.
Why does it work when you're not using upscaled graphics? Well, EDuke32 does the lookup in advance on the CPU for the different palette variations (this was a necessity for older versions of Polymost, which were written for old fixed function hardware)
3