Truecolor questions

Post Reply
markanini
Posts: 213
Joined: Sat Jan 18, 2020 6:10 am

Truecolor questions

Post by markanini »

I'm trying to better understand the mechanics. Given that the games use 8 bit palette indexes, how are they mapped into 24 bit color from the original 256 color output?
What makes the colors appear different in true color mode? Could this suggest the colors have been hacked to replace 8 bit indexes with 24 bit colors?
User avatar
Phredreeke
Posts: 311
Joined: Tue Apr 10, 2018 8:14 am

Re: Truecolor questions

Post by Phredreeke »

Each color in the palette has its own RGB values. At some point the color indices have to be translated back to RGB values. On vintage hardware that was done on the graphics card itself. When using hardware rendering without palette emulation the translation happens as the texture is loaded. When using palette emulation I believe it occurs right after the texture is drawn. When using software rendering it occurs after the whole image finishes rendering

The colors are different without palette emulation because shading is done by multiplying with the shade level, while with palette emulation or using the software rendering shading is done using a look up table (for each of the 256 possible colors in the texture you have 32 or 64 entries, these entries are limited to the same 256 colors)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49229
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Truecolor questions

Post by Graf Zahl »

... and those color deviations come from these lookup tables being "optimized" (meaning they do not fade linearly - or at least as linearly as the palette allows - their makers took some creative licenses, which is the reason why some colors are visibly off at lower light levels - the most obvious examples are the sandy pathways in RR which are a lot more red in software, or the strong reddish tint throughout SW or as a particularly strange example, the house to the right of the starting point in World Tour's E5L1.
markanini
Posts: 213
Joined: Sat Jan 18, 2020 6:10 am

Re: Truecolor questions

Post by markanini »

Phredreeke wrote: The colors are different without palette emulation because shading is done by multiplying with the shade level, while with palette emulation or using the software rendering shading is done using a look up table (for each of the 256 possible colors in the texture you have 32 or 64 entries, these entries are limited to the same 256 colors)
How does the shade level work?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49229
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Truecolor questions

Post by Graf Zahl »

Quite simple: Shade 0 is fullbright, shade 31/63 is black, i.e. it's an inverse light scale.
User avatar
Phredreeke
Posts: 311
Joined: Tue Apr 10, 2018 8:14 am

Re: Truecolor questions

Post by Phredreeke »

How does this translate into a multiplier though? Something like 1 - (shade/max shades)?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49229
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Truecolor questions

Post by Graf Zahl »

1- shade/(maxshades-1), to be precise. If you got 32 shades, 31 is the darkest one.
That is, if the ramp was truly linear. None of Build's shade tables are truly linear so they need a small fudging factor. Some of Exhumed's even have a totally different falloff where this factor needs to be quite different.
Post Reply

Return to “General”