Affine brightmaps

This commit is contained in:
yamamama 2026-03-05 14:29:07 -05:00
parent 5a648dd91a
commit 0ebe6f2f4d
4 changed files with 36 additions and 13 deletions

View file

@ -210,6 +210,11 @@ void R_DrawTranslatedAffineColumn(drawcolumndata_t* dc);
void R_DrawTranslucentAffineColumn(drawcolumndata_t* dc);
void R_DrawTranslatedTranslucentAffineColumn(drawcolumndata_t* dc);
void R_DrawAffineColumn_Brightmap(drawcolumndata_t* dc);
void R_DrawTranslatedAffineColumn_Brightmap(drawcolumndata_t* dc);
void R_DrawTranslucentAffineColumn_Brightmap(drawcolumndata_t* dc);
void R_DrawTranslatedTranslucentAffineColumn_Brightmap(drawcolumndata_t* dc);
void R_DrawColumn_Brightmap(drawcolumndata_t* dc);
void R_DrawTranslucentColumn_Brightmap(drawcolumndata_t* dc);
void R_DrawTranslatedColumn_Brightmap(drawcolumndata_t* dc);

View file

@ -135,11 +135,19 @@ FUNCINLINE static ATTRINLINE constexpr UINT16 R_DrawColumnAffinePixel(drawcolumn
if constexpr (Type & DrawColumnType::DC_BRIGHTMAP)
{
if (dc->brightmap[bit] == BRIGHTPIXEL)
// For affine drawers, dc->brightmap points to a *flat*, and not a *column*.
// Keep that in mind before you do something that causes a bunch of segfaults!
if (dc->brightmap)
{
// Pixel is part of the brightmap
col = dc->fullbright[col];
was_brightmapped = true;
const UINT16 bmpixel = reinterpret_cast<UINT16 *>(dc->brightmap)[bit];
if ((bmpixel & 0xff) == BRIGHTPIXEL)
{
// Pixel is part of the brightmap
col = dc->fullbright[col];
was_brightmapped = true;
}
}
}
@ -703,7 +711,8 @@ static void R_DrawAffineColumnTemplate(drawcolumndata_t *dc)
// Replace with DEFINE_AFFINE_COLUMN_COMBO down the line
#define DEFINE_AFFINE_COLUMN_SETUP(name, flags) \
DEFINE_AFFINE_COLUMN_FUNC(name, flags|DC_DIRECT)
DEFINE_AFFINE_COLUMN_FUNC(name, flags|DC_DIRECT) \
DEFINE_AFFINE_COLUMN_FUNC(name ## _Brightmap, flags|DC_DIRECT|DC_BRIGHTMAP)
DEFINE_AFFINE_COLUMN_SETUP(R_DrawAffineColumn, DC_BASIC);
DEFINE_AFFINE_COLUMN_SETUP(R_DrawTranslatedAffineColumn, DC_COLORMAP);

View file

@ -1041,27 +1041,28 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (vis->cut & SC_AFFINE)
{
// Specialized affine drawing functions, primarily for player sprites.
boolean affinebrightmap = (bmpatch != NULL);
if (dc.translation) // translate green skin to another color
{
if (vis->transmap)
{
R_SetColumnFunc(COLDRAWFUNC_AFFINETRANSTRANS, false);
R_SetColumnFunc(COLDRAWFUNC_AFFINETRANSTRANS, affinebrightmap);
dc.transmap = vis->transmap;
}
else
{
R_SetColumnFunc(COLDRAWFUNC_AFFINETRANS, false);
R_SetColumnFunc(COLDRAWFUNC_AFFINETRANS, affinebrightmap);
}
}
else if (vis->transmap)
{
R_SetColumnFunc(COLDRAWFUNC_AFFINEFUZZY, false);
R_SetColumnFunc(COLDRAWFUNC_AFFINEFUZZY, affinebrightmap);
dc.transmap = vis->transmap;
}
else
{
R_SetColumnFunc(COLDRAWFUNC_AFFINE, false);
R_SetColumnFunc(COLDRAWFUNC_AFFINE, affinebrightmap);
}
}
// Hack: Use a special column function for drop shadows that bypasses
@ -1172,6 +1173,14 @@ static void R_DrawVisSprite(vissprite_t *vis)
dc.source = static_cast<UINT8 *>(patch->flats[0]);
dc.sourcelength = patch->width;
if (bmpatch)
{
Patch_GenerateFlat(bmpatch, static_cast<pictureflags_t>(0));
// The column is a flat because fuck you
dc.brightmap = static_cast<UINT8 *>(bmpatch->flats[0]);
}
dc.affine.a = vis->affine.transform.a;
dc.affine.b = vis->affine.transform.b;
dc.affine.c = vis->affine.transform.c;

View file

@ -153,10 +153,10 @@ void SCR_SetDrawFuncs(enum columncontext_e _columncontext)
// Affine brightmap functions; needed but I don't care at the moment
colfuncs_bm[COLDRAWFUNC_AFFINE] = NULL;
colfuncs_bm[COLDRAWFUNC_AFFINETRANS] = NULL;
colfuncs_bm[COLDRAWFUNC_AFFINEFUZZY] = NULL;
colfuncs_bm[COLDRAWFUNC_AFFINETRANSTRANS] = NULL;
colfuncs_bm[COLDRAWFUNC_AFFINE] = R_DrawAffineColumn_Brightmap;
colfuncs_bm[COLDRAWFUNC_AFFINETRANS] = R_DrawTranslatedAffineColumn_Brightmap;
colfuncs_bm[COLDRAWFUNC_AFFINEFUZZY] = R_DrawTranslucentAffineColumn_Brightmap;
colfuncs_bm[COLDRAWFUNC_AFFINETRANSTRANS] = R_DrawTranslatedTranslucentAffineColumn_Brightmap;
spanfuncs[BASEDRAWFUNC] = R_DrawSpan;
spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan;