diff --git a/source/build/include/build.h b/source/build/include/build.h index 9f0a7e8f4..b7cd2aeac 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1395,7 +1395,6 @@ extern int32_t r_vbocount; extern int32_t r_animsmoothing; extern int32_t r_parallaxskyclamping; extern int32_t r_parallaxskypanning; -extern int32_t r_fullbrights; extern int32_t r_downsize; extern int32_t r_downsizevar; extern int32_t mdtims, omdtims; diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index d614b1952..c775c142b 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -71,8 +71,7 @@ extern float shadescale; extern int32_t shadescale_unbounded; extern uint8_t alphahackarray[MAXTILES]; -extern int32_t r_usenewshading; -extern int32_t r_brightnesshack; +extern int32_t r_scenebrightness; extern int32_t polymostcenterhoriz; extern int16_t globalpicnum; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 1fd020a37..5464701c1 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -8412,30 +8412,11 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, case REND_CLASSIC: globalvisibility = mulscale16(g_visibility,i); break; -#ifdef USE_OPENGL case REND_POLYMOST: // NOTE: In Polymost, the fragment depth depends on the x screen size! - if (r_usenewshading == 4) - globalvisibility = g_visibility * xdimen; - else if (r_usenewshading >= 2) - globalvisibility = scale(g_visibility<<2, xdimen, 1680); - else - globalvisibility = scale(g_visibility<<2, xdimen, 1100); + globalvisibility = g_visibility * xdimen; globalvisibility2 = mulscale16(g_visibility, i); break; -# ifdef POLYMER - case REND_POLYMER: - if (r_usenewshading == 4) - globalvisibility = g_visibility<<5; - else if (r_usenewshading > 1) - /* 0.65127==150/230, another constant found out by experiment. :/ - * (150 is Polymost's old FOGDISTCONST.) */ - globalvisibility = (g_visibility<<2) * 150 / (230 * 35); - else - globalvisibility = (g_visibility<<2) / 35; - break; -# endif -#endif } globalhisibility = mulscale16(globalvisibility,xyaspect); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 97f61146a..830acbc0e 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -55,7 +55,6 @@ float shadescale = 1.0f; int32_t shadescale_unbounded = 0; int32_t r_pogoDebug = 0; -int32_t r_usenewshading = 4; int32_t polymostcenterhoriz = 100; static float gviewxrange; @@ -108,18 +107,10 @@ static FHardwareTexture *polymosttext = 0; int32_t glrendmode = REND_POLYMOST; int32_t r_shadeinterpolate = 1; -// This variable, and 'shadeforfullbrightpass' control the drawing of -// fullbright tiles. Also see 'fullbrightloadingpass'. - -int32_t r_fullbrights = 1; -#ifdef USE_GLEXT -//POGOTODO: we no longer support rendering without VBOs -- update any outdated pre-GL2 code that renders without VBOs -int32_t r_vbocount = 64; -#endif int32_t r_animsmoothing = 1; int32_t r_downsize = 0; int32_t r_downsizevar = -1; -int32_t r_brightnesshack = 0; +int32_t r_scenebrightness = 0; int32_t r_rortexture = 0; int32_t r_rortexturerange = 0; @@ -384,154 +375,58 @@ void polymost_glinit() ////////// VISIBILITY FOG ROUTINES ////////// -// only for r_usenewshading < 2 (not preferred) -static void fogcalc_old(int32_t shade, int32_t vis) -{ - float f; - - if (r_usenewshading == 1) - { - f = 0.9f * shade; - f = (vis > 239) ? (float)(gvisibility * (vis - 240 + f)) : - (float)(gvisibility * (vis + 16 + f)); - } - else - { - f = (shade < 0) ? shade * 3.5f : shade * .66f; - f = (vis > 239) ? (float)(gvisibility * ((vis - 240 + f) / (klabs(vis - 256)))) : - (float)(gvisibility * (vis + 16 + f)); - } - - fogresult = clamp(f, 0.001f, 100.0f); -} - // For GL_LINEAR fog: -#define FOGDISTCONST 600 -#define FULLVIS_BEGIN 2.9e30f -#define FULLVIS_END 3.0e30f - -static inline void fogcalc(int32_t shade, int32_t vis, int32_t pal) -{ - fogcol = fogtable[pal]; - - if (r_usenewshading < 2) - { - fogcalc_old(shade, vis); - return; - } - - float combvis = (float) globalvisibility * (uint8_t) (vis+16); - - if (combvis == 0.f) - { - if (r_usenewshading == 2 && shade > 0) - { - // beg = -D*shade, end = D*(NUMSHADES-1-shade) - // => end/beg = -(NUMSHADES-1-shade)/shade - fogresult = -FULLVIS_BEGIN; - fogresult2 = FULLVIS_BEGIN * (float)(numshades-1-shade) / shade; - } - else - { - fogresult = FULLVIS_BEGIN; - fogresult2 = FULLVIS_END; - } - } - else if (r_usenewshading == 3 && shade >= numshades-1) - { - fogresult = -1; - fogresult2 = 0; - } - else - { - combvis = 1.f/combvis; - fogresult = (r_usenewshading == 3 && shade > 0) ? 0.f : -(FOGDISTCONST * shade) * combvis; - fogresult2 = (FOGDISTCONST * (numshades-1-shade)) * combvis; - } -} - #define GL_FOG_MAX 1.0e37f void calc_and_apply_fog(int32_t shade, int32_t vis, int32_t pal) { if (nofog) return; - if (r_usenewshading == 4) + fogresult = 0.f; + fogcol = fogtable[pal]; + + if (((uint8_t)(vis + 16)) > 0 && globalvisibility > 0) + { + constexpr GLfloat glfogconstant = 262144.f; + GLfloat fogrange = (frealmaxshade * glfogconstant) / (((uint8_t)(vis + 16)) * globalvisibility); + + fogresult = 0.f - (((min(shade, 0) - 0.5f) / frealmaxshade) * fogrange); // min() = subtract shades from fog + fogresult2 = fogrange - (((shade - 0.5f) / frealmaxshade) * fogrange); + } + else { fogresult = 0.f; - fogcol = fogtable[pal]; - - if (((uint8_t)(vis + 16)) > 0 && globalvisibility > 0) - { - constexpr GLfloat glfogconstant = 262144.f; - GLfloat fogrange = (frealmaxshade * glfogconstant) / (((uint8_t)(vis + 16)) * globalvisibility); - - fogresult = 0.f - (((min(shade, 0) - 0.5f) / frealmaxshade) * fogrange); // min() = subtract shades from fog - fogresult2 = fogrange - (((shade - 0.5f) / frealmaxshade) * fogrange); - } - else - { - fogresult = 0.f; - fogresult2 = -GL_FOG_MAX; // hide fog behind the camera - } - - GLInterface.SetFogLinear((float*)&fogcol, fogresult, fogresult2); - return; + fogresult2 = -GL_FOG_MAX; // hide fog behind the camera } - fogcalc(shade, vis, pal); - - if (r_usenewshading < 2) - { - GLInterface.SetFogExp2((float*)& fogcol, fogresult); - } - else - { - GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2); - } + GLInterface.SetFogLinear((float*)&fogcol, fogresult, fogresult2); } void calc_and_apply_fog_factor(int32_t shade, int32_t vis, int32_t pal, float factor) { if (nofog) return; - if (r_usenewshading == 4) + fogcol = fogtable[pal]; + + if (((uint8_t)(vis + 16)) > 0 && ((((uint8_t)(vis + 16)) / 8.f) + shade) > 0) { - fogcol = fogtable[pal]; + GLfloat normalizedshade = (shade - 0.5f) / frealmaxshade; + GLfloat fogrange = (((uint8_t)(vis + 16)) / (8.f * frealmaxshade)) + normalizedshade; - if (((uint8_t)(vis + 16)) > 0 && ((((uint8_t)(vis + 16)) / 8.f) + shade) > 0) - { - GLfloat normalizedshade = (shade - 0.5f) / frealmaxshade; - GLfloat fogrange = (((uint8_t)(vis + 16)) / (8.f * frealmaxshade)) + normalizedshade; + // subtract shades from fog + if (normalizedshade > 0.f && normalizedshade < 1.f) + fogrange = (fogrange - normalizedshade) / (1.f - normalizedshade); - // subtract shades from fog - if (normalizedshade > 0.f && normalizedshade < 1.f) - fogrange = (fogrange - normalizedshade) / (1.f - normalizedshade); - - fogresult = -(GL_FOG_MAX * fogrange); - fogresult2 = GL_FOG_MAX - (GL_FOG_MAX * fogrange); - } - else - { - fogresult = 0.f; - fogresult2 = -GL_FOG_MAX; // hide fog behind the camera - } - - GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2); - return; + fogresult = -(GL_FOG_MAX * fogrange); + fogresult2 = GL_FOG_MAX - (GL_FOG_MAX * fogrange); + } + else + { + fogresult = 0.f; + fogresult2 = -GL_FOG_MAX; // hide fog behind the camera } - // NOTE: for r_usenewshading >= 2, the fog beginning/ending distance results are - // unused. - fogcalc(shade, vis, pal); - if (r_usenewshading < 2) - { - GLInterface.SetFogExp2((float*)& fogcol, fogresult*factor); - } - else - { - GLInterface.SetFogLinear((float*)& fogcol, FULLVIS_BEGIN, FULLVIS_END); - } + GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2); } //////////////////// @@ -623,7 +518,6 @@ void uploadbasepalette(int32_t basepalnum, bool transient) // transient palettes return; } - //POGO: this is only necessary for GL fog/vertex color shade compatibility, since those features don't index into shade tables uint8_t basepalWFullBrightInfo[4*256]; for (int i = 0; i < 256; ++i) { @@ -808,10 +702,7 @@ static uint8_t drawpoly_blend = 0; static inline pthtyp *our_texcache_fetch(int32_t dameth) { - if (r_usenewshading == 4) - return texcache_fetch(globalpicnum, globalpal, getpalookup(!(globalflags & GLOBAL_NO_GL_TILESHADES), globalshade), dameth); - - return texcache_fetch(globalpicnum, globalpal, getpalookup(!(globalflags & GLOBAL_NO_GL_TILESHADES) ? globvis>>3 : 0, globalshade), dameth); + return texcache_fetch(globalpicnum, globalpal, getpalookup(1, globalshade), dameth); } int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall) @@ -1020,16 +911,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 GLInterface.SetColorMask(false); //Hack to update Z-buffer for invalid mirror textures } - static int32_t fullbright_pass = 0; - - if (pth->flags & PTH_HASFULLBRIGHT && r_fullbrights) - { - if (!fullbright_pass) - fullbright_pass = 1; - else if (fullbright_pass == 2) - pth = pth->ofb; - } - Bassert(pth); // If we aren't rendmode 3, we're in Polymer, which means this code is @@ -1140,7 +1021,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 vec2_t tsiz2 = tsiz; - if (method & DAMETH_MASKPROPS || fullbright_pass == 2) + if (method & DAMETH_MASKPROPS) { float const al = alphahackarray[globalpicnum] != 0 ? alphahackarray[globalpicnum] * (1.f/255.f) : (pth->hicr && pth->hicr->alphacut >= 0.f ? pth->hicr->alphacut : 0.f); @@ -1367,29 +1248,8 @@ do // restore palette usage if we were just rendering a non-indexed color texture GLInterface.UsePaletteIndexing(true); } - if (fullbright_pass == 1) - { - int32_t const shade = globalshade; - globalshade = -128; - fullbright_pass = 2; - - GLInterface.SetFogEnabled(false); - - GLInterface.SetDepthFunc(Depth_Equal); - - polymost_drawpoly(dpxy, n, method_); - - GLInterface.SetDepthFunc(Depth_LessEqual); - - if (!nofog) - GLInterface.SetFogEnabled(true); - - globalshade = shade; - fullbright_pass = 0; - } - - if (skyzbufferhack && skyzbufferhack_pass == 0) + if (skyzbufferhack && skyzbufferhack_pass == 0) { vec3d_t const bxtex = xtex, bytex = ytex, botex = otex; xtex = xtex2, ytex = ytex2, otex = otex2; @@ -4222,7 +4082,7 @@ void polymost_drawrooms() GLInterface.EnableDepthTest(true); GLInterface.SetDepthFunc(Depth_Always); - GLInterface.SetBrightness(r_brightnesshack); + GLInterface.SetBrightness(r_scenebrightness); gvrcorrection = viewingrange*(1.f/65536.f); if (glprojectionhacks == 2) @@ -6261,7 +6121,6 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba GLInterface.EnableAlphaTest(false); GLInterface.SetDepthMask(false); - // XXX: Don't fogify the OSD text in Mapster32 with r_usenewshading >= 2. GLInterface.SetFogEnabled(false); // We want to have readable text in wireframe mode, too: GLInterface.SetWireframe(false); @@ -6458,7 +6317,6 @@ void polymost_initosdfuncs(void) { "r_animsmoothing","enable/disable model animation smoothing",(void *) &r_animsmoothing, CVAR_BOOL, 0, 1 }, { "r_anisotropy", "changes the OpenGL texture anisotropy setting", (void *) &glanisotropy, CVAR_INT|CVAR_FUNCPTR, 0, 16 }, - { "r_fullbrights","enable/disable fullbright textures",(void *) &r_fullbrights, CVAR_BOOL, 0, 1 }, { "r_hightile","enable/disable hightile texture rendering",(void *) &usehightile, CVAR_BOOL, 0, 1 }, { "r_models", "enable/disable model rendering", (void *)&usemodels, CVAR_BOOL, 0, 1 }, { "r_nofog", "enable/disable GL fog", (void *)&nofog, CVAR_BOOL, 0, 1}, @@ -6474,9 +6332,6 @@ void polymost_initosdfuncs(void) { "r_texfilter", "changes the texture filtering settings (may require restart)", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, { "r_useindexedcolortextures", "enable/disable indexed color texture rendering", (void *) &r_useindexedcolortextures, CVAR_INT, 0, 1 }, - { "r_usenewshading", - "visibility/fog code: 0: orig. Polymost 1: 07/2011 2: linear 12/2012 3: no neg. start 03/2014 4: base constant on shade table 11/2017", - (void*)& r_usenewshading, CVAR_INT | CVAR_FUNCPTR, 0, 4}, { "r_yshearing", "enable/disable y-shearing", (void*) &r_yshearing, CVAR_BOOL, 0, 1 }, { "r_flatsky", "enable/disable flat skies", (void*)& r_flatsky, CVAR_BOOL, 0, 1 }, { "fixpalette", "", (void*)& fixpalette, CVAR_INT, 0, 256 }, @@ -6496,7 +6351,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype) // while sprites are clamped if (videoGetRenderMode() < REND_POLYMOST) return; - if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (palookup[dapalnum] == NULL)) return;//dapalnum = 0; + if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (palookup[dapalnum] == NULL)) return;//dapalnum = 0; //OSD_Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); hicprecaching = 1; diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 19cc7cc49..7d0e6bec5 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1332,7 +1332,7 @@ void sdlayer_setvideomode_opengl(void) GLInterface.Deinit(); GLInterface.Init(); - GLInterface.InitGLState(r_usenewshading, glmultisample); + GLInterface.InitGLState(4, glmultisample); GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy); } diff --git a/source/build/src/tiles.cpp b/source/build/src/tiles.cpp index 53579343e..b821c76d0 100644 --- a/source/build/src/tiles.cpp +++ b/source/build/src/tiles.cpp @@ -786,8 +786,7 @@ void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, x1++; if (x1 >= xsiz1) x1 = 0; } } - if (playing_rr) - tileInvalidate(tilenume2, -1, -1); + tileInvalidate(tilenume2, -1, -1); } void Buninitart(void) diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 25f76c9b6..a2e416753 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -689,15 +689,6 @@ static void G_PrintCoords(int32_t snum) printcoordsline("rendmode = %d", videoGetRenderMode()); printcoordsline("r_ambientlight = %.03f", r_ambientlight); - if (rendmode >= 3) - { - if (rendmode==3) - printcoordsline("r_usenewshading = %d", r_usenewshading); -# ifdef POLYMER - else - printcoordsline("r_pr_artmapping = %d", pr_artmapping); -#endif - } } #endif } diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index b8ef0fb52..7a65ddddd 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -356,14 +356,6 @@ void GLInstance::SetFogLinear(float* color, float start, float end) memcpy(renderState.FogColor, color, 4 * sizeof(float)); }; -void GLInstance::SetFogExp2(float* color, float coefficient) -{ - renderState.Fog[0] = - renderState.Fog[1] = 0.f; - renderState.Fog[2] = coefficient; - memcpy(renderState.FogColor, color, 4 * sizeof(float)); -} - void GLInstance::SetColorMask(bool on) { glColorMask(on, on, on, on); diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index d4c4ef9f4..cad7ba045 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -263,7 +263,6 @@ public: void SetDepthFunc(int func); void SetFogLinear(float* color, float start, float end); - void SetFogExp2(float* color, float coefficient); void SetColorMask(bool on); void SetDepthMask(bool on); void SetBlendFunc(int src, int dst); diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index f8e18a578..6818756d1 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -684,16 +684,6 @@ static void G_PrintCoords(int32_t snum) printcoordsline("rendmode = %d", videoGetRenderMode()); printcoordsline("r_ambientlight = %.03f", r_ambientlight); - - if (rendmode >= 3) - { - if (rendmode==3) - printcoordsline("r_usenewshading = %d", r_usenewshading); -# ifdef POLYMER - else - printcoordsline("r_pr_artmapping = %d", pr_artmapping); -#endif - } } #endif }