From 1407c18f8b740630d5113edc8e6f125d05b449f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 10 Oct 2019 19:40:33 +0200 Subject: [PATCH] - cleaned out some remains of the non-indexed render path. All of this will be redone in the backend. --- source/build/include/polymost.h | 23 ----------------------- source/build/src/polymost.cpp | 29 +++++++++++++---------------- source/glbackend/gl_shader.cpp | 1 + source/glbackend/gl_shader.h | 3 ++- source/glbackend/glbackend.cpp | 4 ++++ source/glbackend/glbackend.h | 1 + source/sw/src/mytypes.h | 2 +- 7 files changed, 22 insertions(+), 41 deletions(-) diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index 07e8a0af9..d614b1952 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -77,29 +77,6 @@ extern int32_t polymostcenterhoriz; extern int16_t globalpicnum; -// Compare with polymer_eligible_for_artmap() -static FORCE_INLINE int32_t eligible_for_tileshades(int32_t const picnum, int32_t const pal) -{ - return !usehightile || !hicfindsubst(picnum, pal, hictinting[pal].f & HICTINT_ALWAYSUSEART); -} - -static inline float getshadefactor(int32_t const shade) -{ - // 8-bit tiles, i.e. non-hightiles and non-models, don't get additional - // shading with r_usetileshades! - if (videoGetRenderMode() == REND_POLYMOST && !(globalflags & GLOBAL_NO_GL_TILESHADES) && eligible_for_tileshades(globalpicnum, globalpal)) - return 1.f; - - if (r_usenewshading == 4) - return max(min(1.f - (shade * shadescale / frealmaxshade), 1.f), 0.f); - - float const shadebound = (float)((shadescale_unbounded || shade>=numshades) ? numshades : numshades-1); - float const scaled_shade = (float)shade*shadescale; - float const clamped_shade = min(max(scaled_shade, 0.f), shadebound); - - return ((float)(numshades-clamped_shade))/(float)numshades; -} - #define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \ ((fogpal) ? (fogpal) : (pal)) static FORCE_INLINE int32_t get_floor_fogpal(usectorptr_t const sec) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index d4932242c..97f61146a 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -371,8 +371,6 @@ FileReader GetBaseResource(const char* fn); // one-time initialization of OpenGL for polymost void polymost_glinit() { - //globalflags |= GLOBAL_NO_GL_TILESHADES; // This re-enables the old fading logic without re-adding the r_usetileshades variable. The entire thing will have to be done on a more abstract level anyway. - for (int basepalnum = 0; basepalnum < MAXBASEPALS; ++basepalnum) { uploadbasepalette(basepalnum); @@ -758,12 +756,17 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp bool onebitalpha = texture->isMasked(); pth->glpic->LoadTexture(image); + +#if 0 // I don't really think this is a good idea. The hightile should look indistinguishable to the game compared to the regular one. vec2_t tsiz = { texture->GetWidth(), texture->GetHeight() }; // precalculate scaling parameters for replacement if (facen > 0) pth->scale = { (float)tsiz.x * (1.0f/64.f), (float)tsiz.y * (1.0f/64.f) }; else pth->scale = { (float)tsiz.x / (float)tilesiz[dapic].x, (float)tsiz.y / (float)tilesiz[dapic].y }; +#else + pth->scale = { 1.f,1.f }; +#endif polymost_setuptexture(pth->glpic, dameth, (hicr->flags & HICR_FORCEFILTER) ? TEXFILTER_ON : -1); @@ -775,7 +778,6 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp ((hicr->flags & HICR_FORCEFILTER) ? PTH_FORCEFILTER : 0); pth->skyface = facen; pth->hicr = hicr; - pth->siz = tsiz; if (facen > 0) pth->siz = { 64, 64 }; else pth->siz = { tilesiz[dapic].x, tilesiz[dapic].y }; return 0; @@ -1060,7 +1062,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 { texmat.loadIdentity(); texmat.scale(pth->hicr->scale.x, pth->hicr->scale.y, 1.0f); - GLInterface.SetMatrix(Matrix_ModelView, &texmat); + GLInterface.SetMatrix(Matrix_Texture, &texmat); } #ifdef USE_GLEXT @@ -1149,14 +1151,10 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 float pc[4]; - { - polytint_t const & tint = hictinting[globalpal]; - float shadeFactor = (pth->flags & PTH_INDEXED) && - !(globalflags & GLOBAL_NO_GL_TILESHADES) ? 1.f : getshadefactor(globalshade); - pc[0] = (1.f-(tint.sr*(1.f/255.f)))*shadeFactor+(tint.sr*(1.f/255.f)); - pc[1] = (1.f-(tint.sg*(1.f/255.f)))*shadeFactor+(tint.sg*(1.f/255.f)); - pc[2] = (1.f-(tint.sb*(1.f/255.f)))*shadeFactor+(tint.sb*(1.f/255.f)); - } + polytint_t const& tint = hictinting[globalpal]; + pc[0] = (1.f - (tint.sr * (1.f / 255.f))) + (tint.sr * (1.f / 255.f)); + pc[1] = (1.f - (tint.sg * (1.f / 255.f))) + (tint.sg * (1.f / 255.f)); + pc[2] = (1.f - (tint.sb * (1.f / 255.f))) + (tint.sb * (1.f / 255.f)); // spriteext full alpha control pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha); @@ -1352,6 +1350,7 @@ do if (pth->hicr) { VSMatrix identity(0); + GLInterface.SetMatrix(Matrix_Texture, &identity); GLInterface.SetMatrix(Matrix_Detail, &identity); } @@ -6146,19 +6145,17 @@ void polymost_fillpolygon(int32_t npoints) polymost_updatePalette(); - float const f = getshadefactor(globalshade); - uint8_t const maskprops = (globalorientation>>7)&DAMETH_MASKPROPS; handle_blend(maskprops > DAMETH_MASK, 0, maskprops == DAMETH_TRANS2); if (maskprops > DAMETH_MASK) { GLInterface.EnableBlend(true); - GLInterface.SetColor(f, f, f, float_trans(maskprops, 0)); + GLInterface.SetColor(1.f, 1.f, 1.f, float_trans(maskprops, 0)); } else { GLInterface.EnableBlend(false); - GLInterface.SetColor(f, f, f); + GLInterface.SetColor(1.f, 1.f, 1.f); } tessectrap((float *)rx1,(float *)ry1,xb1,npoints); diff --git a/source/glbackend/gl_shader.cpp b/source/glbackend/gl_shader.cpp index 2a092e5f0..abdce6c65 100644 --- a/source/glbackend/gl_shader.cpp +++ b/source/glbackend/gl_shader.cpp @@ -163,6 +163,7 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char ProjectionMatrix.Init(hShader, "u_projectionMatrix"); DetailMatrix.Init(hShader, "u_detailMatrix"); GlowMatrix.Init(hShader, "u_glowMatrix"); + TextureMatrix.Init(hShader, "u_textureMatrix"); glUseProgram(hShader); diff --git a/source/glbackend/gl_shader.h b/source/glbackend/gl_shader.h index f7ec1a1d6..e08abc78a 100644 --- a/source/glbackend/gl_shader.h +++ b/source/glbackend/gl_shader.h @@ -57,7 +57,8 @@ public: FUniformMatrix4f ProjectionMatrix; FUniformMatrix4f DetailMatrix; FUniformMatrix4f GlowMatrix; - + FUniformMatrix4f TextureMatrix; + public: PolymostShader() = default; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index cb710eaa8..b8ef0fb52 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -290,6 +290,10 @@ void GLInstance::SetMatrix(int num, const VSMatrix *mat) case Matrix_Glow: polymostShader->GlowMatrix.Set(mat->get()); break; + + case Matrix_Texture: + polymostShader->TextureMatrix.Set(mat->get()); + break; } } diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 4bf06c8c4..d4c4ef9f4 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -138,6 +138,7 @@ enum EMatrixType Matrix_ModelView, Matrix_Detail, Matrix_Glow, + Matrix_Texture, // These are the only ones being used. NUMMATRICES }; diff --git a/source/sw/src/mytypes.h b/source/sw/src/mytypes.h index 5da37f85e..39273e337 100644 --- a/source/sw/src/mytypes.h +++ b/source/sw/src/mytypes.h @@ -32,7 +32,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #define OFF 0 -#define ON (!OFF) +#define ON 1 typedef unsigned char SWBOOL;