mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-17 23:21:22 +00:00
Fixed issue with vertical offsets being broken.
Add a vertical flip variant for the translucent column drawer. Translucency is now properly distributed: 0.00 leads to no render at all, 0.1 to TRANS10, ..., 0.9 to TRANS90, 1 to regular column drawer.
This commit is contained in:
parent
829be5bd43
commit
13dbe7d3a3
1 changed files with 45 additions and 7 deletions
52
src/r_data.c
52
src/r_data.c
|
@ -219,7 +219,7 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa
|
|||
{
|
||||
INT32 count, position;
|
||||
UINT8 *source, *dest;
|
||||
UINT8 *mytransmap = transtables + ((8*(originPatch->alpha)/255) << FF_TRANSSHIFT);
|
||||
UINT8 *mytransmap = transtables + ((8*(originPatch->alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); // The equation's not exact but it works as intended. I'll call it a day for now.
|
||||
INT32 topdelta, prevdelta = -1;
|
||||
INT32 originy = originPatch->originy;
|
||||
|
||||
|
@ -246,17 +246,53 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa
|
|||
dest = cache + position;
|
||||
if (count > 0)
|
||||
{
|
||||
for (; dest < cache + position + count; ++source)
|
||||
//*dest++ = transtables[(*source)<<8 + *dest];
|
||||
*dest++ = *(mytransmap + ((*source)<<8) + (*dest));
|
||||
//*dest++ = *source;
|
||||
for (; dest < cache + position + count; source++, dest++)
|
||||
*dest = *(mytransmap + ((*dest)<<8) + (*source));
|
||||
}
|
||||
|
||||
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void R_DrawTransFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight)
|
||||
{
|
||||
INT32 count, position;
|
||||
UINT8 *source, *dest;
|
||||
UINT8 *mytransmap = transtables + ((8*(originPatch->alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); // The equation's not exact but it works as intended. I'll call it a day for now.
|
||||
INT32 topdelta, prevdelta = -1;
|
||||
INT32 originy = originPatch->originy;
|
||||
|
||||
while (patch->topdelta != 0xff)
|
||||
{
|
||||
topdelta = patch->topdelta;
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
topdelta = patchheight-patch->length-topdelta;
|
||||
source = (UINT8 *)patch + 2 + patch->length; // patch + 3 + (patch->length-1)
|
||||
count = patch->length;
|
||||
position = originy + topdelta;
|
||||
|
||||
if (position < 0)
|
||||
{
|
||||
count += position;
|
||||
source += position; // start further UP the column
|
||||
position = 0;
|
||||
}
|
||||
|
||||
if (position + count > cacheheight)
|
||||
count = cacheheight - position;
|
||||
|
||||
dest = cache + position;
|
||||
if (count > 0)
|
||||
{
|
||||
for (; dest < cache + position + count; --source, dest++)
|
||||
*dest = *(mytransmap + ((*dest)<<8) + (*source));
|
||||
}
|
||||
|
||||
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// R_GenerateTexture
|
||||
|
@ -371,10 +407,12 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
|||
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
|
||||
{
|
||||
static void (*ColumnDrawerPointer)(column_t *, UINT8 *, texpatch_t *, INT32, INT32); // Column drawing function pointer.
|
||||
if (patch->style == AST_TRANSLUCENT)
|
||||
if ((patch->style == AST_TRANSLUCENT) && (patch->alpha <= (10*255/11))) // Alpha style set to translucent? Is the alpha small enough for translucency?
|
||||
{
|
||||
if (patch->alpha < 255/11) // Is the patch way too translucent? Don't render then.
|
||||
continue;
|
||||
if (patch->flip & 2)
|
||||
ColumnDrawerPointer = &R_DrawTransColumnInCache;
|
||||
ColumnDrawerPointer = &R_DrawTransFlippedColumnInCache;
|
||||
else
|
||||
ColumnDrawerPointer = &R_DrawTransColumnInCache;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue