mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Polymodes: Add a new pthtyp flag to mark textures that should not be processed by the fixtransparency() hack (which avoids the transparent color blending into a sprite when texture filtering is enabled), such as non-(T)ROR-masking floors and ceilings, white- and mask-walls, paper-skies, and rotatesprite with orientation flag 64. This commit makes sure the flag's status always fits the situation.
This fixes the remaining issue with WWII GI's LOGO.ANM: Color index #255 is used as the dominant white color (not as a transparent index) and fixtransparency() was mangling the image as a result. git-svn-id: https://svn.eduke32.com/eduke32@5465 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
56f331574d
commit
38dfb0a2b2
5 changed files with 56 additions and 37 deletions
|
@ -352,7 +352,7 @@ void polymer_loadboard(void);
|
|||
void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum);
|
||||
void polymer_drawmasks(void);
|
||||
void polymer_editorpick(void);
|
||||
void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade);
|
||||
void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade, int32_t method);
|
||||
void polymer_postrotatesprite(void);
|
||||
void polymer_drawmaskwall(int32_t damaskwallcnt);
|
||||
void polymer_drawsprite(int32_t snum);
|
||||
|
|
|
@ -145,7 +145,6 @@ enum {
|
|||
DAMETH_TRANS2 = 3,
|
||||
|
||||
DAMETH_MASKPROPS = 3,
|
||||
DAMETH_TEXPROPS = ~3,
|
||||
|
||||
DAMETH_CLAMPED = 4,
|
||||
|
||||
|
@ -160,8 +159,9 @@ enum {
|
|||
DAMETH_NOFIX = 16384,
|
||||
};
|
||||
|
||||
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
|
||||
#define TO_PTH_CLAMPED(dameth) (((dameth)&DAMETH_CLAMPED)>>2)
|
||||
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
||||
EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_MASKPROPS) == DAMETH_MASK);
|
||||
EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_CLAMPED) == DAMETH_CLAMPED);
|
||||
|
||||
// Do we want a NPOT-y-as-classic texture for this <dameth> and <ysiz>?
|
||||
static inline int polymost_want_npotytex(int32_t dameth, int32_t ysiz)
|
||||
|
@ -171,7 +171,7 @@ static inline int polymost_want_npotytex(int32_t dameth, int32_t ysiz)
|
|||
}
|
||||
|
||||
// pthtyp pth->flags bits
|
||||
enum {
|
||||
enum pthtyp_flags {
|
||||
PTH_CLAMPED = 1,
|
||||
PTH_HIGHTILE = 2,
|
||||
PTH_SKYBOX = 4,
|
||||
|
@ -181,6 +181,8 @@ enum {
|
|||
PTH_FORCEFILTER = 64,
|
||||
|
||||
PTH_INVALIDATED = 128,
|
||||
|
||||
PTH_NOTRANSFIX = 256, // fixtransparency() bypassed
|
||||
};
|
||||
|
||||
typedef struct pthtyp_t
|
||||
|
@ -194,13 +196,22 @@ typedef struct pthtyp_t
|
|||
vec2_t siz;
|
||||
int16_t picnum;
|
||||
|
||||
uint16_t flags; // see pthtyp_flags
|
||||
char palnum;
|
||||
char shade;
|
||||
char effects;
|
||||
char flags; // 1 = clamped (dameth&4), 2 = hightile, 4 = skybox face, 8 = hasalpha, 16 = hasfullbright, 128 = invalidated
|
||||
char skyface;
|
||||
} pthtyp;
|
||||
|
||||
// DAMETH -> PTH conversions
|
||||
#define TO_PTH_CLAMPED(dameth) (((dameth)&DAMETH_CLAMPED)>>2)
|
||||
EDUKE32_STATIC_ASSERT(TO_PTH_CLAMPED(DAMETH_CLAMPED) == PTH_CLAMPED);
|
||||
#define TO_PTH_NOTRANSFIX(dameth) ((((~(dameth))&DAMETH_MASK)<<8)&(((~(dameth))&DAMETH_TRANS1)<<7))
|
||||
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_NOMASK) == PTH_NOTRANSFIX);
|
||||
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_MASK) == 0);
|
||||
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_TRANS1) == 0);
|
||||
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_MASKPROPS) == 0);
|
||||
|
||||
extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t);
|
||||
extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char);
|
||||
|
||||
|
|
|
@ -1427,11 +1427,11 @@ void polymer_editorpick(void)
|
|||
searchit = 0;
|
||||
}
|
||||
|
||||
void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade)
|
||||
void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade, int32_t method)
|
||||
{
|
||||
_prmaterial rotatespritematerial;
|
||||
|
||||
polymer_getbuildmaterial(&rotatespritematerial, tilenum, pal, shade, 0, DAMETH_CLAMPED);
|
||||
polymer_getbuildmaterial(&rotatespritematerial, tilenum, pal, shade, 0, method);
|
||||
|
||||
rotatespritematerialbits = polymer_bindmaterial(&rotatespritematerial, NULL, 0);
|
||||
}
|
||||
|
@ -2798,7 +2798,7 @@ attributes:
|
|||
!Bmemcmp(&s->ceilingstat, &sec->ceilingstat, offsetof(sectortype, visibility) - offsetof(sectortype, ceilingstat)))
|
||||
goto finish;
|
||||
|
||||
s->floor.bucket = polymer_getbuildmaterial(&s->floor.material, floorpicnum, sec->floorpal, sec->floorshade, sec->visibility, DAMETH_NOMASK);
|
||||
s->floor.bucket = polymer_getbuildmaterial(&s->floor.material, floorpicnum, sec->floorpal, sec->floorshade, sec->visibility, (sec->floorstat & 384) ? DAMETH_MASK : DAMETH_NOMASK);
|
||||
|
||||
if (sec->floorstat & 256) {
|
||||
if (sec->floorstat & 128) {
|
||||
|
@ -2808,7 +2808,7 @@ attributes:
|
|||
}
|
||||
}
|
||||
|
||||
s->ceil.bucket = polymer_getbuildmaterial(&s->ceil.material, ceilingpicnum, sec->ceilingpal, sec->ceilingshade, sec->visibility, DAMETH_NOMASK);
|
||||
s->ceil.bucket = polymer_getbuildmaterial(&s->ceil.material, ceilingpicnum, sec->ceilingpal, sec->ceilingshade, sec->visibility, (sec->ceilingstat & 384) ? DAMETH_MASK : DAMETH_NOMASK);
|
||||
|
||||
if (sec->ceilingstat & 256) {
|
||||
if (sec->ceilingstat & 128) {
|
||||
|
@ -3348,7 +3348,7 @@ static void polymer_updatewall(int16_t wallnum)
|
|||
(s->ceil.buffer[wal->point2 - sec->wallptr].y > ns->ceil.buffer[nwallnum - nsec->wallptr].y))
|
||||
overwall = 1;
|
||||
|
||||
if ((overwall) || (wal->cstat & 16) || (wal->cstat & 32))
|
||||
if ((overwall) || (wal->cstat & 48))
|
||||
{
|
||||
if (w->over.buffer == NULL) {
|
||||
w->over.buffer = (_prvert *)Xmalloc(4 * sizeof(_prvert));
|
||||
|
@ -3370,10 +3370,10 @@ static void polymer_updatewall(int16_t wallnum)
|
|||
|
||||
w->over.bucket = polymer_getbuildmaterial(&w->over.material, curpicnum, wal->pal, wal->shade, sec->visibility, DAMETH_WALL);
|
||||
|
||||
if ((wal->cstat & 16) || (wal->cstat & 32))
|
||||
if (wal->cstat & 48)
|
||||
{
|
||||
// mask
|
||||
w->mask.bucket = polymer_getbuildmaterial(&w->mask.material, walloverpicnum, wal->pal, wal->shade, sec->visibility, DAMETH_WALL);
|
||||
w->mask.bucket = polymer_getbuildmaterial(&w->mask.material, walloverpicnum, wal->pal, wal->shade, sec->visibility, DAMETH_WALL | ((wal->cstat & 48) == 48 ? DAMETH_NOMASK : DAMETH_MASK));
|
||||
|
||||
if (wal->cstat & 128)
|
||||
{
|
||||
|
@ -3877,7 +3877,7 @@ void polymer_updatesprite(int32_t snum)
|
|||
}
|
||||
|
||||
polymer_getbuildmaterial(&s->plane.material, curpicnum, tspr->pal, tspr->shade,
|
||||
sector[tspr->sectnum].visibility, DAMETH_CLAMPED);
|
||||
sector[tspr->sectnum].visibility, DAMETH_MASK | DAMETH_CLAMPED);
|
||||
|
||||
if (tspr->cstat & 2)
|
||||
{
|
||||
|
@ -5010,7 +5010,7 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
|||
}
|
||||
|
||||
// PR_BIT_GLOW_MAP
|
||||
if (hicfindsubst(tilenum, GLOWPAL) && (pth = texcache_fetch(tilenum, GLOWPAL, 0, DAMETH_NOMASK)) &&
|
||||
if (hicfindsubst(tilenum, GLOWPAL) && (pth = texcache_fetch(tilenum, GLOWPAL, 0, DAMETH_MASK)) &&
|
||||
pth->hicr && (pth->hicr->palnum == GLOWPAL))
|
||||
material->glowmap = pth->glpic;
|
||||
|
||||
|
|
|
@ -593,6 +593,9 @@ static void resizeglcheck(void)
|
|||
|
||||
static void fixtransparency(coltype *dapic, vec2_t dasiz, vec2_t dasiz2, int32_t dameth)
|
||||
{
|
||||
if (!(dameth & DAMETH_MASKPROPS))
|
||||
return;
|
||||
|
||||
vec2_t doxy = { dasiz2.x-1, dasiz2.y-1 };
|
||||
|
||||
if (dameth & DAMETH_CLAMPED) { doxy.x = min(doxy.x, dasiz.x); doxy.y = min(doxy.y, dasiz.y); }
|
||||
|
@ -946,7 +949,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
|
|||
npoty = PTH_NPOTWALL;
|
||||
}
|
||||
|
||||
uploadtexture(doalloc, siz, hasalpha ? GL_RGBA : GL_RGB, GL_RGBA, pic, tsiz, dameth);
|
||||
uploadtexture(doalloc, siz, hasalpha ? GL_RGBA : GL_RGB, GL_RGBA, pic, tsiz, dameth | DAMETH_NOFIX);
|
||||
|
||||
Bfree(pic);
|
||||
|
||||
|
@ -956,7 +959,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
|
|||
pth->palnum = dapal;
|
||||
pth->shade = dashade;
|
||||
pth->effects = 0;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) | (hasalpha*PTH_HASALPHA) | npoty;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) | (hasalpha*PTH_HASALPHA) | npoty;
|
||||
pth->hicr = NULL;
|
||||
|
||||
if (hasfullbright && !fullbrightloadingpass)
|
||||
|
@ -1257,7 +1260,9 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
|||
|
||||
pth->picnum = dapic;
|
||||
pth->effects = effect;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) | PTH_HIGHTILE | ((facen>0) * PTH_SKYBOX) | ((hasalpha != 255) ? PTH_HASALPHA : 0) |
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) |
|
||||
PTH_HIGHTILE | ((facen>0) * PTH_SKYBOX) |
|
||||
((hasalpha != 255) ? PTH_HASALPHA : 0) |
|
||||
(hicr->flags & HICR_FORCEFILTER ? PTH_FORCEFILTER : 0);
|
||||
pth->skyface = facen;
|
||||
pth->hicr = hicr;
|
||||
|
@ -1452,7 +1457,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
|
||||
if (skyclamphack) method |= DAMETH_CLAMPED;
|
||||
|
||||
pthtyp *pth = our_texcache_fetch(method & DAMETH_TEXPROPS);
|
||||
pthtyp *pth = our_texcache_fetch(method);
|
||||
|
||||
if (!pth)
|
||||
{
|
||||
|
@ -1505,7 +1510,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
if (r_detailmapping)
|
||||
{
|
||||
if (usehightile && !drawingskybox && hicfindsubst(globalpicnum, DETAILPAL) &&
|
||||
(detailpth = texcache_fetch(globalpicnum, DETAILPAL, 0, method & DAMETH_TEXPROPS)) &&
|
||||
(detailpth = texcache_fetch(globalpicnum, DETAILPAL, 0, method & ~DAMETH_MASKPROPS)) &&
|
||||
detailpth->hicr && detailpth->hicr->palnum == DETAILPAL)
|
||||
{
|
||||
polymost_setupdetailtexture(++texunits, detailpth ? detailpth->glpic : 0);
|
||||
|
@ -1529,7 +1534,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
if (r_glowmapping)
|
||||
{
|
||||
if (usehightile && !drawingskybox && hicfindsubst(globalpicnum, GLOWPAL) &&
|
||||
(glowpth = texcache_fetch(globalpicnum, GLOWPAL, 0, method & DAMETH_TEXPROPS)) &&
|
||||
(glowpth = texcache_fetch(globalpicnum, GLOWPAL, 0, method | DAMETH_MASK)) &&
|
||||
glowpth->hicr && (glowpth->hicr->palnum == GLOWPAL))
|
||||
polymost_setupglowtexture(++texunits, glowpth ? glowpth->glpic : 0);
|
||||
}
|
||||
|
@ -4978,16 +4983,6 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
const int32_t oldnormalmapping = pr_normalmapping;
|
||||
#endif
|
||||
|
||||
# ifdef POLYMER
|
||||
if (getrendermode() == REND_POLYMER)
|
||||
{
|
||||
pr_normalmapping = 0;
|
||||
polymer_inb4rotatesprite(picnum, dapalnum, dashade);
|
||||
r_detailmapping = 0;
|
||||
r_glowmapping = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t method = DAMETH_CLAMPED; //Use OpenGL clamping - dorotatesprite never repeats
|
||||
|
||||
if (!(dastat & RS_NOMASK))
|
||||
|
@ -4998,6 +4993,16 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
method |= DAMETH_MASK;
|
||||
}
|
||||
|
||||
#ifdef POLYMER
|
||||
if (getrendermode() == REND_POLYMER)
|
||||
{
|
||||
pr_normalmapping = 0;
|
||||
polymer_inb4rotatesprite(picnum, dapalnum, dashade, method);
|
||||
r_detailmapping = 0;
|
||||
r_glowmapping = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
drawpoly_alpha = daalpha * (1.0f / 255.0f);
|
||||
|
||||
vec2_t const siz = tilesiz[globalpicnum];
|
||||
|
@ -5840,7 +5845,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
|
|||
hicprecaching = 1;
|
||||
|
||||
|
||||
texcache_fetch(dapicnum, dapalnum, 0, (datype & 1)*DAMETH_CLAMPED);
|
||||
texcache_fetch(dapicnum, dapalnum, 0, (datype & 1)*(DAMETH_CLAMPED|DAMETH_MASK));
|
||||
hicprecaching = 0;
|
||||
|
||||
if (datype == 0 || !usemodels) return;
|
||||
|
|
|
@ -44,7 +44,8 @@ static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, i
|
|||
// load from art
|
||||
for (pth=texcache.list[j]; pth; pth=pth->next)
|
||||
if (pth->picnum == dapicnum && pth->palnum == dapalnum && pth->shade == dashade &&
|
||||
(pth->flags & (PTH_CLAMPED+PTH_HIGHTILE)) == TO_PTH_CLAMPED(dameth) &&
|
||||
(pth->flags & (PTH_CLAMPED | PTH_HIGHTILE | PTH_NOTRANSFIX)) ==
|
||||
(TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth)) &&
|
||||
polymost_want_npotytex(dameth, tilesiz[dapicnum].y) == !!(pth->flags&PTH_NPOTWALL)
|
||||
)
|
||||
{
|
||||
|
@ -84,7 +85,8 @@ pthtyp *texcache_fetchmulti(pthtyp *pth, hicreplctyp *si, int32_t dapicnum, int3
|
|||
{
|
||||
Bmemcpy(pth, pth2, sizeof(pthtyp));
|
||||
pth->picnum = dapicnum;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) |
|
||||
PTH_HIGHTILE | (drawingskybox>0)*PTH_SKYBOX;
|
||||
if (pth2->flags & PTH_HASALPHA)
|
||||
pth->flags |= PTH_HASALPHA;
|
||||
pth->hicr = si;
|
||||
|
@ -133,8 +135,9 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
|||
{
|
||||
if (pth->picnum == dapicnum && pth->palnum == checkcachepal &&
|
||||
(checktintpal > 0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
||||
(pth->flags & (PTH_CLAMPED + PTH_HIGHTILE + PTH_SKYBOX)) ==
|
||||
(TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox > 0) * PTH_SKYBOX) &&
|
||||
(pth->flags & (PTH_CLAMPED | PTH_HIGHTILE | PTH_SKYBOX | PTH_NOTRANSFIX)) ==
|
||||
(TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) |
|
||||
PTH_HIGHTILE | (drawingskybox > 0) * PTH_SKYBOX) &&
|
||||
(drawingskybox > 0 ? (pth->skyface == drawingskybox) : 1))
|
||||
{
|
||||
if (pth->flags & PTH_INVALIDATED)
|
||||
|
@ -442,7 +445,7 @@ static const char * texcache_calcid(char *cachefn, const char *fn, const int32_t
|
|||
struct texcacheid_t {
|
||||
int32_t len, method;
|
||||
char effect, name[BMAX_PATH+3]; // +3: pad to a multiple of 4
|
||||
} id = { len, dameth, effect, "" };
|
||||
} id = { len, DAMETH_NARROW_MASKPROPS(dameth), effect, "" };
|
||||
|
||||
Bstrcpy(id.name, fn);
|
||||
|
||||
|
|
Loading…
Reference in a new issue