|
|
|
@ -27,6 +27,7 @@ Keep in mind that the coordinates will be rounded down to the next lowest textur |
|
|
|
|
|
|
|
// A straight conversion of the Quake palette colors comes out looking rather over-saturated.
|
|
|
|
// So we desaturate the palette ahead of time to more closely match the original Quake's look.
|
|
|
|
// Yoinked from: https://stackoverflow.com/questions/13328029/how-to-desaturate-a-color
|
|
|
|
static void desaturate(const unsigned char inColor[3], unsigned char outColor[3]) |
|
|
|
{ |
|
|
|
double f = 0.1; // desaturate by 10%
|
|
|
|
@ -125,6 +126,7 @@ struct ColorAccumulate |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// Dominant color algorithm yoinked from: https://github.com/fast-average-color/fast-average-color
|
|
|
|
static void analyze_texture(unsigned char* texBytes, int numBytes, const Color palette[PALETTE_SIZE], TextureDescriptor& outTexture) |
|
|
|
{ |
|
|
|
uint64_t rSum = 0, gSum = 0, bSum = 0; |
|
|
|
|