Cosmetic changes to some blend/alpha related code.

git-svn-id: https://svn.eduke32.com/eduke32@5886 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-10-09 07:55:13 +00:00
parent d7328f738d
commit 4d08f4d433
4 changed files with 17 additions and 17 deletions

View file

@ -4724,15 +4724,15 @@ static void setup_globals_sprite1(const uspritetype *tspr, const usectortype *se
static uint8_t falpha_to_blend(float alpha, int32_t *cstatptr, int32_t transbit1, int32_t transbit2)
{
int32_t blendidx, cstat = *cstatptr;
int32_t cstat = *cstatptr;
if (cstat&transbit1)
alpha = 1.0f - (1.0f - alpha) * ((cstat&transbit2) ? 0.33f : 0.66f);
alpha = 1.0f - (1.0f - alpha) * ((cstat&transbit2) ? (1.f/3.f) : (2.f/3.f));
cstat |= transbit1;
cstat &= ~transbit2;
blendidx = max(1, (int32_t)(alpha * (2*numalphatabs))); // [1 .. 2*numalphatabs-1]
int32_t blendidx = max(1, Blrintf(alpha * (2*numalphatabs))); // [1 .. 2*numalphatabs-1]
if (blendidx > numalphatabs)
{
blendidx = 2*numalphatabs - blendidx;
@ -4784,21 +4784,22 @@ static void drawsprite_classic(int32_t snum)
if (numalphatabs != 0)
{
blendidx = falpha_to_blend(alpha, &cstat, 2, 512);
tspr->cstat = cstat;
}
else if (alpha >= 0.33f)
else if (alpha >= 1.f/3.f)
{
cstat &= ~512;
if ((cstat&2) && alpha >= 0.5f) // this covers the multiplicative aspect used in the Polymodes
cstat |= 512;
cstat |= 2;
if (alpha >= 0.66f)
if (alpha >= 2.f/3.f)
cstat |= 512;
}
tspr->cstat = cstat;
}
}
tilenum = tspr->picnum;
@ -6634,6 +6635,8 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
}
else if (daalpha > 84)
{
dastat &= ~RS_TRANS2;
if ((dastat & RS_TRANS1) && daalpha > 127) // this covers the multiplicative aspect used in the Polymodes
dastat |= RS_TRANS2;

View file

@ -2202,9 +2202,9 @@ static int32_t polymost_md3draw(md3model_t *m, const uspritetype *tspr)
if (have_basepal_tint())
hictinting_apply(pc, MAXPALOOKUPS-1);
if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66f; else pc[3] = 0.33f; }
else pc[3] = 1.0f;
pc[3] = (tspr->cstat&2) ? !(tspr->cstat&512) ? (2.f/3.f) : (1.f/3.f) : 1.0f;
pc[3] *= 1.0f - sext->alpha;
if (m->usesalpha) //Sprites with alpha in texture
{
// bglEnable(GL_BLEND);// bglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
@ -2220,7 +2220,8 @@ static int32_t polymost_md3draw(md3model_t *m, const uspritetype *tspr)
}
else
{
if ((tspr->cstat&2) || sext->alpha > 0.f || pc[3] < 1.0f) bglEnable(GL_BLEND); //else bglDisable(GL_BLEND);
if ((tspr->cstat&2) || sext->alpha > 0.f || pc[3] < 1.0f)
bglEnable(GL_BLEND); //else bglDisable(GL_BLEND);
}
bglColor4f(pc[0],pc[1],pc[2],pc[3]);
//if (MFLAGS_NOCONV(m))

View file

@ -125,7 +125,7 @@ int32_t r_downsizevar = -1;
static float fogresult, fogresult2;
coltypef fogcol, fogtable[MAXPALOOKUPS];
static const float float_trans[4] = { 1.0f, 1.0f, 0.66f, 0.33f };
static const float float_trans[4] = { 1.0f, 1.0f, 2.f/3.f, 1.f/3.f };
char ptempbuf[MAXWALLSB<<1];

View file

@ -978,11 +978,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, const uspritetype *tspr)
(float)(numshades-min(max((globalshade * shadescale)+m->shadeoff, 0), numshades)) / (float)numshades;
hictinting_apply(pc, globalpal);
if (tspr->cstat&2)
pc[3] = !(tspr->cstat&512) ? 0.66f : 0.33f;
else
pc[3] = 1.0f;
pc[3] = (tspr->cstat&2) ? !(tspr->cstat&512) ? (2.f/3.f) : (1.f/3.f) : 1.0f;
pc[3] *= 1.0f - spriteext[tspr->owner].alpha;
if ((tspr->cstat&2) || spriteext[tspr->owner].alpha > 0.f || pc[3] < 1.0f)