diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f3805a3c..a711c8944 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1124,6 +1124,7 @@ set (PCH_SOURCES r_data/voxels.cpp r_data/renderstyle.cpp r_data/r_interpolate.cpp + r_data/r_vanillatrans.cpp scripting/symbols.cpp scripting/types.cpp scripting/thingdef.cpp diff --git a/src/d_main.cpp b/src/d_main.cpp index 650d99ae8..b4b6947a6 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -116,6 +116,7 @@ #include "r_utility.h" #include "vm.h" #include "types.h" +#include "r_data/r_vanillatrans.h" EXTERN_CVAR(Bool, hud_althud) void DrawHUD(); @@ -2606,6 +2607,9 @@ void D_DoomMain (void) D_CheckNetGame (); } + // [SP] Force vanilla transparency auto-detection to re-detect our game lumps now + UpdateVanillaTransparency(); + // [RH] Lock any cvars that should be locked now that we're // about to begin the game. FBaseCVar::EnableNoSet (); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 8d053e81c..0c0513dde 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -39,6 +39,7 @@ #include "g_levellocals.h" #include "events.h" #include "actorinlines.h" +#include "r_data/r_vanillatrans.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -993,7 +994,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } - if (r_vanillatrans) + if (UseVanillaTransparency()) { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects, // and disable 'additive' translucency for certain objects from other games. diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index ba91f005b..fc866b4e7 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -28,6 +28,7 @@ #include "poly_sprite.h" #include "polyrenderer/poly_renderer.h" #include "polyrenderer/scene/poly_light.h" +#include "r_data/r_vanillatrans.h" EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) @@ -146,7 +147,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - if ((thing->renderflags & RF_ZDOOMTRANS) && r_vanillatrans) + if ((thing->renderflags & RF_ZDOOMTRANS) && UseVanillaTransparency()) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); diff --git a/src/r_data/r_vanillatrans.cpp b/src/r_data/r_vanillatrans.cpp new file mode 100644 index 000000000..3c40e9dea --- /dev/null +++ b/src/r_data/r_vanillatrans.cpp @@ -0,0 +1,67 @@ + +#include "templates.h" +#include "c_cvars.h" +#include "w_wad.h" +#ifdef _DEBUG +#include "c_dispatch.h" +#endif + +CVAR (Int, r_vanillatrans, 2, CVAR_ARCHIVE) + +namespace +{ + bool firstTime = true; + bool foundDehacked = false; + bool foundDecorate = false; + bool foundZScript = false; +} +#ifdef _DEBUG +CCMD (debug_checklumps) +{ + Printf("firstTime: %d\n", firstTime); + Printf("foundDehacked: %d\n", foundDehacked); + Printf("foundDecorate: %d\n", foundDecorate); + Printf("foundZScript: %d\n", foundZScript); +} +#endif + +void UpdateVanillaTransparency() +{ + firstTime = true; +} + +bool UseVanillaTransparency() +{ + if (firstTime) + { + int lastlump = 0; + Wads.FindLump("ZSCRIPT", &lastlump); // ignore first ZScript + if (Wads.FindLump("ZSCRIPT", &lastlump) == -1) // no loaded ZScript + { + lastlump = 0; + foundDehacked = Wads.FindLump("DEHACKED", &lastlump) != -1; + lastlump = 0; + foundDecorate = Wads.FindLump("DECORATE", &lastlump) != -1; + foundZScript = false; + } + else + { + foundZScript = true; + foundDehacked = false; + foundDecorate = false; + } + firstTime = false; + } + + switch (r_vanillatrans) + { + case 0: return false; + case 1: return true; + default: + if (foundDehacked) + return true; + if (foundDecorate) + return false; + return r_vanillatrans == 3; + } +} diff --git a/src/r_data/r_vanillatrans.h b/src/r_data/r_vanillatrans.h new file mode 100644 index 000000000..61d988074 --- /dev/null +++ b/src/r_data/r_vanillatrans.h @@ -0,0 +1,3 @@ + +void UpdateVanillaTransparency(); +bool UseVanillaTransparency(); \ No newline at end of file diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index d067b9007..7defbac4a 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -65,6 +65,7 @@ #include "swrenderer/r_memory.h" #include "swrenderer/r_renderthread.h" #include "a_dynlight.h" +#include "r_data/r_vanillatrans.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, gl_light_sprites) @@ -213,7 +214,7 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; - if (r_vanillatrans) + if (UseVanillaTransparency()) { if (thing->renderflags & RF_ZDOOMTRANS) vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 2e9a7f1f4..8863326e1 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -649,50 +649,14 @@ B68EB7CFB4CC481796E2919B9C16DFBD // Moc11.wad e1m6 } 1ED329858AB154C55878DA1C11A4F100 // unloved.pk3:unlovedmaps.wad map01 -{ - clipmidtex -} - FA23E72FA955E66EC68609F72C0BA71E // unloved.pk3:unlovedmaps.wad map02 -{ - clipmidtex -} - 41BEC1F643CFEEC997AF98276A05EC88 // unloved.pk3:unlovedmaps.wad map03 -{ - clipmidtex -} - AF9A6370BE562584BC11165ECF364713 // unloved.pk3:unlovedmaps.wad map04 -{ - clipmidtex -} - DC96228097DD004C40CCB1DB14A91EAA // unloved.pk3:unlovedmaps.wad map05 -{ - clipmidtex -} - 261E64897A572C8DB8DC041E64BE27AD // unloved2beta1.pk3:u2_new2maps2.wad map06 -{ - clipmidtex -} - 04800B1F35E8C036EBABC8C616402927 // unloved2beta1.pk3:u2_new2maps2.wad map07 -{ - clipmidtex -} - 9E54F70648A77BBD090FF78A3AA05367 // unloved2beta1.pk3:u2_new2maps2.wad map08 -{ - clipmidtex -} - 72E9E0F41F691B7F956E62F35B4A617F // unloved2beta1.pk3:u2_new2maps2.wad map09 -{ - clipmidtex -} - 3D3FE412E87AD8B2316DAEC9E25F2E5D // unloved2beta1.pk3:u2_new2maps2.wad map10 { clipmidtex diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index dcc7c4068..49501628b 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2369,6 +2369,10 @@ OPTVAL_SWDOOM = "Doom Software Renderer"; OPTVAL_DEDICATED = "High-Performance"; OPTVAL_INTEGRATED = "Power-Saving"; OPTVAL_VANILLA = "Vanilla"; +OPTVAL_VTFZDOOM = "ZDoom (Forced)"; +OPTVAL_VTFVANILLA = "Vanilla (Forced)"; +OPTVAL_VTAZDOOM = "Auto (Vanilla Preferred)"; +OPTVAL_VTAVANILLA = "Auto (ZDoom Preferred)"; // Colors C_BRICK = "\cabrick"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index c6b610a5d..3f9307382 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -692,8 +692,10 @@ OptionValue Fuzziness OptionValue VanillaTrans { - 0.0, "$OPTVAL_ZDOOM" - 1.0, "$OPTVAL_VANILLA" + 0.0, "$OPTVAL_VTFZDOOM" + 1.0, "$OPTVAL_VTFVANILLA" + 0.0, "$OPTVAL_VTAZDOOM" + 1.0, "$OPTVAL_VTAVANILLA" } OptionValue GPUSwitch