diff --git a/polymer/eduke32/build/include/hightile.h b/polymer/eduke32/build/include/hightile.h index a82bb1d2c..b2bfd1d18 100644 --- a/polymer/eduke32/build/include/hightile.h +++ b/polymer/eduke32/build/include/hightile.h @@ -90,6 +90,10 @@ enum HICEFFECTMASK = (1|2|4|8), }; +#define GRAYSCALE_COEFF_RED 0.3 +#define GRAYSCALE_COEFF_GREEN 0.59 +#define GRAYSCALE_COEFF_BLUE 0.11 + #ifdef __cplusplus } #endif diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index c45df8f36..e365e5636 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -622,20 +622,19 @@ static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t if (effect & HICTINT_GRAYSCALE) { - // greyscale - tcol.b = max(tcol.b, max(tcol.g, tcol.r)); - tcol.g = tcol.r = tcol.b; + tcol.g = tcol.r = tcol.b = (uint8_t)((tcol.r * GRAYSCALE_COEFF_RED) + (tcol.g * GRAYSCALE_COEFF_GREEN) + + (tcol.b * GRAYSCALE_COEFF_BLUE)); } + if (effect & HICTINT_INVERT) { - // invert tcol.b = 255-tcol.b; tcol.g = 255-tcol.g; tcol.r = 255-tcol.r; } + if (effect & HICTINT_COLORIZE) { - // colorize tcol.b = min((int32_t)(tcol.b)*b/64,255); tcol.g = min((int32_t)(tcol.g)*g/64,255); tcol.r = min((int32_t)(tcol.r)*r/64,255); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index f7e2a4ad2..360e385b4 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -1203,14 +1203,12 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp if (effect & HICTINT_GRAYSCALE) { - // greyscale - tcol.b = max(tcol.b, max(tcol.g, tcol.r)); - tcol.g = tcol.r = tcol.b; + tcol.g = tcol.r = tcol.b = (uint8_t) ((tcol.r * GRAYSCALE_COEFF_RED) + (tcol.g * GRAYSCALE_COEFF_GREEN) + + (tcol.b * GRAYSCALE_COEFF_BLUE)); } if (effect & HICTINT_INVERT) { - // invert tcol.b = 255-tcol.b; tcol.g = 255-tcol.g; tcol.r = 255-tcol.r; @@ -1218,7 +1216,6 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp if (effect & HICTINT_COLORIZE) { - // colorize tcol.b = min((int32_t)((tcol.b)*r)/64,255); tcol.g = min((int32_t)((tcol.g)*g)/64,255); tcol.r = min((int32_t)((tcol.r)*b)/64,255);