From 6a77175ac5391b9585e5e1b817009dcddc7a0d6d Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Fri, 26 Jan 2018 04:35:15 +0000 Subject: [PATCH] New def token "shadefactor" shadefactor Controls the level of shading in GL modes. Normally it is set to the shade at which all colors are pitch black. The default value calculated from Duke 3D's palette is 30, but most other Build games with a different palette are calculate to 31. This token is for GL mods without a palette. Patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@6592 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/defs.cpp | 6 ++++++ source/build/src/palette.cpp | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 9dca37f0b..ef8e5c74f 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -118,6 +118,7 @@ enum scripttoken_t T_DST_ALPHA, T_ONE_MINUS_DST_ALPHA, T_DST_COLOR, T_ONE_MINUS_DST_COLOR, T_SHADERED, T_SHADEGREEN, T_SHADEBLUE, + T_SHADEFACTOR, }; static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0; @@ -401,6 +402,7 @@ static int32_t defsparser(scriptfile *script) { "undefbasepaletterange", T_UNDEFBASEPALETTERANGE }, { "undefpalookuprange", T_UNDEFPALOOKUPRANGE }, { "undefblendtablerange", T_UNDEFBLENDTABLERANGE }, + { "shadefactor", T_SHADEFACTOR }, }; while (1) @@ -635,6 +637,10 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getnumber(script,&j)) break; } break; + case T_SHADEFACTOR: + scriptfile_getnumber(script, &realmaxshade); + frealmaxshade = (float)realmaxshade; + break; case T_ARTFILE: { char *blockend, *fn = NULL; diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index 2a24cd16b..6de6fd50b 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -314,20 +314,23 @@ void E_PostLoadPalette(void) PostLoad_NotFullbright: ; } - uint8_t const * const blackcolor = &palette[blackcol*3]; - size_t s; - for (s = numshades < 2 ? 0 : numshades-2; s > 0; --s) + if (realmaxshade == 0) { - for (size_t c = s*256, c_end = c+255; c < c_end; ++c) // skipping transparent color + uint8_t const * const blackcolor = &palette[blackcol*3]; + size_t s; + for (s = numshades < 2 ? 0 : numshades-2; s > 0; --s) { - uint8_t const index = palookup0[c]; - uint8_t const * const color = &palette[index*3]; - if (!IsPaletteIndexFullbright(index) && memcmp(blackcolor, color, sizeof(rgb24_t))) - goto PostLoad_FoundShade; + for (size_t c = s*256, c_end = c+255; c < c_end; ++c) // skipping transparent color + { + uint8_t const index = palookup0[c]; + uint8_t const * const color = &palette[index*3]; + if (!IsPaletteIndexFullbright(index) && memcmp(blackcolor, color, sizeof(rgb24_t))) + goto PostLoad_FoundShade; + } } + PostLoad_FoundShade: ; + frealmaxshade = (float)(realmaxshade = s+1); } - PostLoad_FoundShade: ; - frealmaxshade = (float)(realmaxshade = s+1); } void E_ReplaceTransparentColorWithBlack(void)