From dd0f16875fd31f820dd65299f1bdcdbe4f3f8af3 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 7 Mar 2016 11:22:02 +0000 Subject: [PATCH] Engine: Add one-bit alpha detection for hightile and model skins. git-svn-id: https://svn.eduke32.com/eduke32@5649 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/mdsprite.c | 6 ++++-- polymer/eduke32/build/src/polymost.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 1226868ea..a5c6d0b00 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -824,6 +824,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) int32_t b = (glinfo.bgra) ? hictinting[pal].b : hictinting[pal].r; char al = 255; + char onebitalpha = 1; for (int32_t y = 0, j = 0; y < tsiz.y; ++y, j += siz.x) { @@ -834,8 +835,8 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) tcol.b = cptr[rpptr[x].b]; tcol.g = cptr[rpptr[x].g]; tcol.r = cptr[rpptr[x].r]; - tcol.a = rpptr[x].a; - al &= rpptr[x].a; + al &= tcol.a = rpptr[x].a; + onebitalpha &= tcol.a == 0 || tcol.a == 255; if (effect & HICTINT_GRAYSCALE) { @@ -907,6 +908,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) TO_DAMETH_NODOWNSIZE(sk->flags) | TO_DAMETH_NOTEXCOMPRESS(sk->flags) | TO_DAMETH_ARTIMMUNITY(sk->flags) | + (onebitalpha ? DAMETH_ONEBITALPHA : 0) | (hasalpha ? DAMETH_HASALPHA : 0)); Bfree(pic); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index c50fb2ef6..bf9f3dd92 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -1189,6 +1189,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp int32_t b = (glinfo.bgra) ? hictinting[dapalnum].b : hictinting[dapalnum].r; char al = 255; + char onebitalpha = 1; for (int32_t y = 0, j = 0; y < tsiz.y; ++y, j += siz.x) { @@ -1199,8 +1200,8 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp tcol.b = cptr[rpptr[x].b]; tcol.g = cptr[rpptr[x].g]; tcol.r = cptr[rpptr[x].r]; - tcol.a = rpptr[x].a; - al &= rpptr[x].a; + al &= tcol.a = rpptr[x].a; + onebitalpha &= tcol.a == 0 || tcol.a == 255; if (effect & HICTINT_GRAYSCALE) { @@ -1284,6 +1285,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp TO_DAMETH_NODOWNSIZE(hicr->flags) | TO_DAMETH_NOTEXCOMPRESS(hicr->flags) | TO_DAMETH_ARTIMMUNITY(hicr->flags) | + (onebitalpha ? DAMETH_ONEBITALPHA : 0) | (hasalpha ? DAMETH_HASALPHA : 0)); Bfree(pic);