From 16b617114c86dbd1463b7b63cb420f3fed2fa03d Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 11 Jan 2015 04:51:41 +0000 Subject: [PATCH] Replace hightile grayscale method (usually combined with tints to produce replacements for the first handful of palette lookups) w8th superior "luma" method. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4889 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/hightile.h | 4 ++++ polymer/eduke32/build/src/mdsprite.c | 9 ++++----- polymer/eduke32/build/src/polymost.c | 7 ++----- 3 files changed, 10 insertions(+), 10 deletions(-) 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);