From 133c3598a79828bbf140f844e306517a9aa79725 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:45 -0400 Subject: [PATCH 1/2] Add fadestart/fadeend/fog to R_AddColormaps --- src/r_data.c | 32 +++++++++++++++++++++++++++++++- src/r_data.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 1de51fedd..53044bc2e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1901,6 +1901,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { @@ -1917,7 +1918,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex INT16 red, green, blue, alpha; + /////////////////// // base rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->rgba) + (subR ? -1 : 1) // subtract R @@ -1941,7 +1945,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - // fade rgba + /////////////////// + // fade/dark rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->fadergba) + (subFadeR ? -1 : 1) // subtract R @@ -1967,6 +1974,29 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + /////////////////// + // parameters + /////////////////// + + exc_augend->fadestart = max(min( + exc_augend->fadestart + + (subFadeStart ? -1 : 1) // subtract fadestart + * exc_addend->fadestart + , 31), 0); + + exc_augend->fadeend = max(min( + exc_augend->fadeend + + (subFadeEnd ? -1 : 1) // subtract fadeend + * exc_addend->fadeend + , 31), 0); + + if (!ignoreFog) // overwrite fog with new value + exc_augend->fog = exc_addend->fog; + + /////////////////// + // put it together + /////////////////// + if (!(exc = R_GetColormapFromList(exc_augend))) { exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; diff --git a/src/r_data.h b/src/r_data.h index df0fe75b3..3a7740c96 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -128,6 +128,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable); #ifdef EXTRACOLORMAPLUMPS From 87ad2a87f79cb9fbfabee5a8dc8550c1f3305f2e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:14:23 -0400 Subject: [PATCH 2/2] Smarter default fadergbaA and fadeend for relative calc --- src/r_data.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 53044bc2e..5a642f1b2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1968,7 +1968,7 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex , 255), 0); alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); - if (alpha == 25) + if (alpha == 25 && !useAltAlpha && !R_GetRgbaRGB(exc_addend->fadergba)) alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); @@ -1987,7 +1987,8 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadeend = max(min( exc_augend->fadeend + (subFadeEnd ? -1 : 1) // subtract fadeend - * exc_addend->fadeend + * (exc_addend->fadeend == 31 && !exc_addend->fadestart ? 0 : exc_addend->fadeend) + // HACK: fadeend defaults to 31, so don't add anything in this case , 31), 0); if (!ignoreFog) // overwrite fog with new value