- cleaned out some remains of the non-indexed render path.

All of this will be redone in the backend.
This commit is contained in:
Christoph Oelckers 2019-10-10 19:40:33 +02:00
parent 46ffea94a4
commit 1407c18f8b
7 changed files with 22 additions and 41 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -57,7 +57,8 @@ public:
FUniformMatrix4f ProjectionMatrix;
FUniformMatrix4f DetailMatrix;
FUniformMatrix4f GlowMatrix;
FUniformMatrix4f TextureMatrix;
public:
PolymostShader() = default;

View file

@ -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;
}
}

View file

@ -138,6 +138,7 @@ enum EMatrixType
Matrix_ModelView,
Matrix_Detail,
Matrix_Glow,
Matrix_Texture,
// These are the only ones being used.
NUMMATRICES
};

View file

@ -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;