ref: 9ce925452bc4b22c27133ea3bc26ad7b191d37e0
parent: f112dfc381355fea03cb81b3c71f04e07760dca4
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Nov 1 08:00:25 EDT 2023
.alpha: part 7 - fix alpha blending on .mdl
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -86,7 +86,7 @@
int skinwidth;
byte *skinstart;
-void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage);
+void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage, byte alpha);
void D_PolysetCalcGradients (int skinwidth);
void D_DrawSubdiv (void);
void D_DrawNonSubdiv (void);
@@ -561,7 +561,7 @@
D_PolysetDrawSpans8
================
*/
-void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage)
+void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage, byte alpha)
{
int lcount;
byte *lpdest;
@@ -598,11 +598,18 @@
do
{
- if ((lzi >> 16) >= *lpz)
- {
- *lpdest = ((byte *)acolormap)[*lptex + (llight & 0xFF00)];
-// gel mapping *lpdest = gelmap[*lpdest];
- *lpz = lzi >> 16;
+ if ((lzi >> 16) >= *lpz){
+ if(r_drawflags & DRAW_BLEND){
+ *lpdest = blendalpha(
+ ((byte *)acolormap)[*lptex + (llight & 0xFF00)],
+ *lpdest,
+ alpha
+ );
+ }else{
+ *lpdest = ((byte *)acolormap)[*lptex + (llight & 0xFF00)];
+ // gel mapping *lpdest = gelmap[*lpdest];
+ *lpz = lzi >> 16;
+ }
}
lpdest++;
lzi += r_zistepx;
@@ -854,7 +861,7 @@
d_countextrastep = ubasestep + 1;
originalcount = a_spans[initialrightheight].count;
a_spans[initialrightheight].count = Q_MININT; // mark end of the spanpackages
- D_PolysetDrawSpans8 (a_spans);
+ D_PolysetDrawSpans8 (a_spans, currententity->alpha);
// scan out the bottom part of the right edge, if it exists
if (pedgetable->numrightedges == 2)
@@ -878,7 +885,7 @@
d_countextrastep = ubasestep + 1;
a_spans[initialrightheight + height].count = Q_MININT;
// mark end of the spanpackages
- D_PolysetDrawSpans8 (pstart);
+ D_PolysetDrawSpans8 (pstart, currententity->alpha);
}
}