mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- Added additive blending for floors and ceilings.
SVN r3813 (trunk)
This commit is contained in:
parent
cb296a6660
commit
e2a018227f
4 changed files with 185 additions and 13 deletions
|
@ -1185,7 +1185,7 @@ void R_Subsector (subsector_t *sub)
|
||||||
frontsector->GetTexture(sector_t::floor),
|
frontsector->GetTexture(sector_t::floor),
|
||||||
floorlightlevel + r_actualextralight, // killough 3/16/98
|
floorlightlevel + r_actualextralight, // killough 3/16/98
|
||||||
frontsector->GetAlpha(sector_t::floor),
|
frontsector->GetAlpha(sector_t::floor),
|
||||||
!!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE),
|
!!(fakeFloor->flags && FF_ADDITIVETRANS),
|
||||||
frontsector->GetXOffset(position), // killough 3/7/98
|
frontsector->GetXOffset(position), // killough 3/7/98
|
||||||
frontsector->GetYOffset(position), // killough 3/7/98
|
frontsector->GetYOffset(position), // killough 3/7/98
|
||||||
frontsector->GetXScale(position),
|
frontsector->GetXScale(position),
|
||||||
|
@ -1250,7 +1250,7 @@ void R_Subsector (subsector_t *sub)
|
||||||
frontsector->GetTexture(sector_t::ceiling),
|
frontsector->GetTexture(sector_t::ceiling),
|
||||||
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
||||||
frontsector->GetAlpha(sector_t::ceiling),
|
frontsector->GetAlpha(sector_t::ceiling),
|
||||||
!!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE),
|
!!(fakeFloor->flags && FF_ADDITIVETRANS),
|
||||||
frontsector->GetXOffset(position), // killough 3/7/98
|
frontsector->GetXOffset(position), // killough 3/7/98
|
||||||
frontsector->GetYOffset(position), // killough 3/7/98
|
frontsector->GetYOffset(position), // killough 3/7/98
|
||||||
frontsector->GetXScale(position),
|
frontsector->GetXScale(position),
|
||||||
|
|
150
src/r_draw.cpp
150
src/r_draw.cpp
|
@ -79,6 +79,8 @@ void (*R_DrawSpan)(void);
|
||||||
void (*R_DrawSpanMasked)(void);
|
void (*R_DrawSpanMasked)(void);
|
||||||
void (*R_DrawSpanTranslucent)(void);
|
void (*R_DrawSpanTranslucent)(void);
|
||||||
void (*R_DrawSpanMaskedTranslucent)(void);
|
void (*R_DrawSpanMaskedTranslucent)(void);
|
||||||
|
void (*R_DrawSpanAddClamp)(void);
|
||||||
|
void (*R_DrawSpanMaskedAddClamp)(void);
|
||||||
void (STACK_ARGS *rt_map4cols)(int,int,int);
|
void (STACK_ARGS *rt_map4cols)(int,int,int);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1324,6 +1326,152 @@ void R_DrawSpanMaskedTranslucentP_C (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void R_DrawSpanAddClampP_C (void)
|
||||||
|
{
|
||||||
|
dsfixed_t xfrac;
|
||||||
|
dsfixed_t yfrac;
|
||||||
|
dsfixed_t xstep;
|
||||||
|
dsfixed_t ystep;
|
||||||
|
BYTE* dest;
|
||||||
|
const BYTE* source = ds_source;
|
||||||
|
const BYTE* colormap = ds_colormap;
|
||||||
|
int count;
|
||||||
|
int spot;
|
||||||
|
DWORD *fg2rgb = dc_srcblend;
|
||||||
|
DWORD *bg2rgb = dc_destblend;
|
||||||
|
|
||||||
|
xfrac = ds_xfrac;
|
||||||
|
yfrac = ds_yfrac;
|
||||||
|
|
||||||
|
dest = ylookup[ds_y] + ds_x1 + dc_destorg;
|
||||||
|
|
||||||
|
count = ds_x2 - ds_x1 + 1;
|
||||||
|
|
||||||
|
xstep = ds_xstep;
|
||||||
|
ystep = ds_ystep;
|
||||||
|
|
||||||
|
if (ds_xbits == 6 && ds_ybits == 6)
|
||||||
|
{
|
||||||
|
// 64x64 is the most common case by far, so special case it.
|
||||||
|
do
|
||||||
|
{
|
||||||
|
spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6));
|
||||||
|
DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest];
|
||||||
|
DWORD b = a;
|
||||||
|
|
||||||
|
a |= 0x01f07c1f;
|
||||||
|
b &= 0x40100400;
|
||||||
|
a &= 0x3fffffff;
|
||||||
|
b = b - (b >> 5);
|
||||||
|
a |= b;
|
||||||
|
*dest++ = RGB32k[0][0][a & (a>>15)];
|
||||||
|
xfrac += xstep;
|
||||||
|
yfrac += ystep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BYTE yshift = 32 - ds_ybits;
|
||||||
|
BYTE xshift = yshift - ds_xbits;
|
||||||
|
int xmask = ((1 << ds_xbits) - 1) << ds_ybits;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift);
|
||||||
|
DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest];
|
||||||
|
DWORD b = a;
|
||||||
|
|
||||||
|
a |= 0x01f07c1f;
|
||||||
|
b &= 0x40100400;
|
||||||
|
a &= 0x3fffffff;
|
||||||
|
b = b - (b >> 5);
|
||||||
|
a |= b;
|
||||||
|
*dest++ = RGB32k[0][0][a & (a>>15)];
|
||||||
|
xfrac += xstep;
|
||||||
|
yfrac += ystep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_DrawSpanMaskedAddClampP_C (void)
|
||||||
|
{
|
||||||
|
dsfixed_t xfrac;
|
||||||
|
dsfixed_t yfrac;
|
||||||
|
dsfixed_t xstep;
|
||||||
|
dsfixed_t ystep;
|
||||||
|
BYTE* dest;
|
||||||
|
const BYTE* source = ds_source;
|
||||||
|
const BYTE* colormap = ds_colormap;
|
||||||
|
int count;
|
||||||
|
int spot;
|
||||||
|
DWORD *fg2rgb = dc_srcblend;
|
||||||
|
DWORD *bg2rgb = dc_destblend;
|
||||||
|
|
||||||
|
xfrac = ds_xfrac;
|
||||||
|
yfrac = ds_yfrac;
|
||||||
|
|
||||||
|
dest = ylookup[ds_y] + ds_x1 + dc_destorg;
|
||||||
|
|
||||||
|
count = ds_x2 - ds_x1 + 1;
|
||||||
|
|
||||||
|
xstep = ds_xstep;
|
||||||
|
ystep = ds_ystep;
|
||||||
|
|
||||||
|
if (ds_xbits == 6 && ds_ybits == 6)
|
||||||
|
{
|
||||||
|
// 64x64 is the most common case by far, so special case it.
|
||||||
|
do
|
||||||
|
{
|
||||||
|
BYTE texdata;
|
||||||
|
|
||||||
|
spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6));
|
||||||
|
texdata = source[spot];
|
||||||
|
if (texdata != 0)
|
||||||
|
{
|
||||||
|
DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest];
|
||||||
|
DWORD b = a;
|
||||||
|
|
||||||
|
a |= 0x01f07c1f;
|
||||||
|
b &= 0x40100400;
|
||||||
|
a &= 0x3fffffff;
|
||||||
|
b = b - (b >> 5);
|
||||||
|
a |= b;
|
||||||
|
*dest = RGB32k[0][0][a & (a>>15)];
|
||||||
|
}
|
||||||
|
dest++;
|
||||||
|
xfrac += xstep;
|
||||||
|
yfrac += ystep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BYTE yshift = 32 - ds_ybits;
|
||||||
|
BYTE xshift = yshift - ds_xbits;
|
||||||
|
int xmask = ((1 << ds_xbits) - 1) << ds_ybits;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
BYTE texdata;
|
||||||
|
|
||||||
|
spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift);
|
||||||
|
texdata = source[spot];
|
||||||
|
if (texdata != 0)
|
||||||
|
{
|
||||||
|
DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest];
|
||||||
|
DWORD b = a;
|
||||||
|
|
||||||
|
a |= 0x01f07c1f;
|
||||||
|
b &= 0x40100400;
|
||||||
|
a &= 0x3fffffff;
|
||||||
|
b = b - (b >> 5);
|
||||||
|
a |= b;
|
||||||
|
*dest = RGB32k[0][0][a & (a>>15)];
|
||||||
|
}
|
||||||
|
dest++;
|
||||||
|
xfrac += xstep;
|
||||||
|
yfrac += ystep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// [RH] Just fill a span with a color
|
// [RH] Just fill a span with a color
|
||||||
void R_FillSpan (void)
|
void R_FillSpan (void)
|
||||||
{
|
{
|
||||||
|
@ -2040,6 +2188,8 @@ void R_InitColumnDrawers ()
|
||||||
#endif
|
#endif
|
||||||
R_DrawSpanTranslucent = R_DrawSpanTranslucentP_C;
|
R_DrawSpanTranslucent = R_DrawSpanTranslucentP_C;
|
||||||
R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_C;
|
R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_C;
|
||||||
|
R_DrawSpanAddClamp = R_DrawSpanAddClampP_C;
|
||||||
|
R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_C;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [RH] Choose column drawers in a single place
|
// [RH] Choose column drawers in a single place
|
||||||
|
|
|
@ -106,6 +106,12 @@ extern void (*R_DrawSpanTranslucent)(void);
|
||||||
// Span drawing for masked, translucent textures.
|
// Span drawing for masked, translucent textures.
|
||||||
extern void (*R_DrawSpanMaskedTranslucent)(void);
|
extern void (*R_DrawSpanMaskedTranslucent)(void);
|
||||||
|
|
||||||
|
// Span drawing for translucent, additive textures.
|
||||||
|
extern void (*R_DrawSpanAddClamp)(void);
|
||||||
|
|
||||||
|
// Span drawing for masked, translucent, additive textures.
|
||||||
|
extern void (*R_DrawSpanMaskedAddClamp)(void);
|
||||||
|
|
||||||
// [RH] Span blit into an interleaved intermediate buffer
|
// [RH] Span blit into an interleaved intermediate buffer
|
||||||
extern void (*R_DrawColumnHoriz)(void);
|
extern void (*R_DrawColumnHoriz)(void);
|
||||||
void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *spans);
|
void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *spans);
|
||||||
|
|
|
@ -596,7 +596,6 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
|
||||||
else sky = 0; // not skyflatnum so it can't be a sky
|
else sky = 0; // not skyflatnum so it can't be a sky
|
||||||
skybox = NULL;
|
skybox = NULL;
|
||||||
alpha = FRACUNIT;
|
alpha = FRACUNIT;
|
||||||
additive = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New visplane algorithm uses hash table -- killough
|
// New visplane algorithm uses hash table -- killough
|
||||||
|
@ -1047,7 +1046,7 @@ void R_DrawHeightPlanes(fixed_t height)
|
||||||
viewy = pl->viewy;
|
viewy = pl->viewy;
|
||||||
viewangle = pl->viewangle;
|
viewangle = pl->viewangle;
|
||||||
MirrorFlags = pl->MirrorFlags;
|
MirrorFlags = pl->MirrorFlags;
|
||||||
R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, false, true);
|
R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1528,31 +1527,48 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
|
||||||
else
|
else
|
||||||
plane_shade = true;
|
plane_shade = true;
|
||||||
|
|
||||||
// Additive not supported yet because the drawer function doesn't look like it can handle it.
|
|
||||||
if (spanfunc != R_FillSpan)
|
if (spanfunc != R_FillSpan)
|
||||||
{
|
{
|
||||||
if (masked)
|
if (masked)
|
||||||
{
|
{
|
||||||
if (alpha < OPAQUE)
|
if (alpha < OPAQUE || additive)
|
||||||
|
{
|
||||||
|
if (!additive)
|
||||||
{
|
{
|
||||||
spanfunc = R_DrawSpanMaskedTranslucent;
|
spanfunc = R_DrawSpanMaskedTranslucent;
|
||||||
dc_srcblend = Col2RGB8[alpha>>10];
|
dc_srcblend = Col2RGB8[alpha>>10];
|
||||||
dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10];
|
dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
spanfunc = R_DrawSpanMaskedAddClamp;
|
||||||
|
dc_srcblend = Col2RGB8_LessPrecision[alpha>>10];
|
||||||
|
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
spanfunc = R_DrawSpanMasked;
|
spanfunc = R_DrawSpanMasked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (alpha < OPAQUE)
|
if (alpha < OPAQUE || additive)
|
||||||
|
{
|
||||||
|
if (!additive)
|
||||||
{
|
{
|
||||||
spanfunc = R_DrawSpanTranslucent;
|
spanfunc = R_DrawSpanTranslucent;
|
||||||
dc_srcblend = Col2RGB8[alpha>>10];
|
dc_srcblend = Col2RGB8[alpha>>10];
|
||||||
dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10];
|
dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
spanfunc = R_DrawSpanAddClamp;
|
||||||
|
dc_srcblend = Col2RGB8_LessPrecision[alpha>>10];
|
||||||
|
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
spanfunc = R_DrawSpan;
|
spanfunc = R_DrawSpan;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue