mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
* Fixed blending in OpenGL.
* Caught a UDMF-only crash for Software (where linedef alpha is low but nonzero).
This commit is contained in:
parent
04b6911e21
commit
690244825b
7 changed files with 55 additions and 56 deletions
|
|
@ -213,15 +213,14 @@ enum EPolyFlags
|
|||
PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pixels are discarded (holes in texture)
|
||||
PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency
|
||||
PF_Environment = 0x00000004, // Poly should be drawn environment mapped. (Hurdler: used for text drawing)
|
||||
PF_Additive = 0x00000008, // Additive color blending
|
||||
PF_AdditiveSource = 0x00000010, // Source blending factor is additive. This is the opposite of regular additive blending.
|
||||
PF_Subtractive = 0x00000020, // Subtractive color blending
|
||||
PF_ReverseSubtract = 0x00000040, // Reverse subtract, used in wall splats (decals)
|
||||
PF_Multiplicative = 0x00000080, // Multiplicative color blending
|
||||
PF_Additive = 0x00000008, // Source blending factor is additive.
|
||||
PF_Subtractive = 0x00000010, // Subtractive color blending
|
||||
PF_ReverseSubtract = 0x00000020, // Reverse subtract, used in wall splats (decals)
|
||||
PF_Multiplicative = 0x00000040, // Multiplicative color blending
|
||||
PF_Invert = 0x00000100, // Polygon inverts the colours of what it's in front of
|
||||
PF_Fog = 0x20000000, // Fog blocks
|
||||
PF_NoAlphaTest = 0x40000000, // Disables alpha testing
|
||||
PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Invert|PF_Fog) & ~PF_NoAlphaTest,
|
||||
PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Invert|PF_Fog) & ~PF_NoAlphaTest,
|
||||
|
||||
// other flag bits
|
||||
PF_Occlude = 0x00000100, // Updates the depth buffer
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
|
|||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = hwrPatch->max_t;
|
||||
|
||||
flags = PF_Translucent|PF_NoDepthTest;
|
||||
flags = PF_NoDepthTest;
|
||||
|
||||
/*if (option & V_WRAPX)
|
||||
flags |= PF_ForceWrapX;
|
||||
|
|
@ -277,11 +277,10 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
|
|||
else
|
||||
Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
|
||||
|
||||
flags |= PF_Modulated;
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, flags|PF_Modulated);
|
||||
}
|
||||
else
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, flags);
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, flags|PF_Translucent);
|
||||
}
|
||||
|
||||
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
|
||||
|
|
@ -415,7 +414,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
|||
else
|
||||
v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t;
|
||||
|
||||
flags = PF_Translucent|PF_NoDepthTest;
|
||||
flags = PF_NoDepthTest;
|
||||
|
||||
/*if (option & V_WRAPX)
|
||||
flags |= PF_ForceWrapX;
|
||||
|
|
@ -441,11 +440,10 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
|||
else
|
||||
Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
|
||||
|
||||
flags |= PF_Modulated;
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, flags|PF_Modulated);
|
||||
}
|
||||
else
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, flags);
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, flags|PF_Translucent);
|
||||
}
|
||||
|
||||
void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#define DL_HIGH_QUALITY
|
||||
//#define STATICLIGHT //Hurdler: TODO!
|
||||
#define LIGHTMAPFLAGS (PF_Modulated|PF_AdditiveSource)
|
||||
#define LIGHTMAPFLAGS (PF_Modulated|PF_Additive)
|
||||
|
||||
#ifdef ALAM_LIGHTING
|
||||
static dynlights_t view_dynlights[2]; // 2 players in splitscreen mode
|
||||
|
|
@ -1056,7 +1056,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr)
|
|||
|
||||
HWR_GetPic(coronalumpnum); /// \todo use different coronas
|
||||
|
||||
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_Corona | PF_NoDepthTest);
|
||||
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Corona | PF_NoDepthTest);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1144,7 +1144,7 @@ void HWR_DrawCoronas(void)
|
|||
light[3].y = cy+size*1.33f;
|
||||
light[3].s = 0.0f; light[3].t = 1.0f;
|
||||
|
||||
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_NoDepthTest | PF_Corona);
|
||||
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_NoDepthTest | PF_Corona);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -708,12 +708,15 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast)
|
|||
{
|
||||
switch (ast)
|
||||
{
|
||||
//case AST_COPY: -- intentionally defaults to translucent
|
||||
case AST_OVERLAY:
|
||||
return PF_Masked;
|
||||
case AST_ADD:
|
||||
return PF_Additive;
|
||||
case AST_SUBTRACT:
|
||||
return PF_Subtractive;
|
||||
case AST_REVERSESUBTRACT:
|
||||
return PF_ReverseSubtract;
|
||||
case AST_REVERSESUBTRACT:
|
||||
return PF_Subtractive;
|
||||
case AST_MODULATE:
|
||||
return PF_Multiplicative;
|
||||
default:
|
||||
|
|
@ -746,11 +749,13 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
|
|||
|
||||
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf)
|
||||
{
|
||||
if (!transtablenum)
|
||||
{
|
||||
pSurf->PolyColor.s.alpha = 0xff;
|
||||
pSurf->PolyColor.s.alpha = 0xff;
|
||||
|
||||
if (style == AST_MODULATE)
|
||||
return PF_Multiplicative;
|
||||
|
||||
if (!transtablenum && !style)
|
||||
return PF_Masked;
|
||||
}
|
||||
|
||||
pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum);
|
||||
return HWR_GetBlendModeFlag(style);
|
||||
|
|
@ -1462,13 +1467,24 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
|||
case 256:
|
||||
blendmode = PF_Translucent;
|
||||
break;
|
||||
case 913:
|
||||
blendmode = PF_Multiplicative;
|
||||
Surf.PolyColor.s.alpha = 0xff;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
UINT32 blend = 0;
|
||||
transnum_t transtable = R_GetLinedefTransTable(gl_linedef);
|
||||
if (transtable != NUMTRANSMAPS)
|
||||
blendmode = HWR_TranstableToAlpha(transtable, &Surf);
|
||||
else
|
||||
blendmode = PF_Masked;
|
||||
if (transtable == NUMTRANSMAPS)
|
||||
transtable = 0;
|
||||
if (gl_linedef->special == 910)
|
||||
blend = AST_ADD;
|
||||
else if (gl_linedef->special == 911)
|
||||
blend = AST_SUBTRACT;
|
||||
else if (gl_linedef->special == 912)
|
||||
blend = AST_REVERSESUBTRACT;
|
||||
|
||||
blendmode = HWR_SurfaceBlend(blend, transtable, &Surf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -3881,16 +3897,14 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
|
|||
if (trans >= NUMTRANSMAPS)
|
||||
return; // cap
|
||||
|
||||
if (trans)
|
||||
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
else
|
||||
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
if (!trans && !blendmode)
|
||||
{
|
||||
// BP: i agree that is little better in environement but it don't
|
||||
// work properly under glide nor with fogcolor to ffffff :(
|
||||
// Hurdler: PF_Environement would be cool, but we need to fix
|
||||
// the issue with the fog before
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = HWR_GetBlendModeFlag(blendmode)|occlusion;
|
||||
blend |= occlusion;
|
||||
if (!occlusion) use_linkdraw_hack = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -4316,16 +4330,14 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
|
|||
if (trans >= NUMTRANSMAPS)
|
||||
return; // cap
|
||||
|
||||
if (trans)
|
||||
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
else
|
||||
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
if (!trans && !blendmode)
|
||||
{
|
||||
// BP: i agree that is little better in environement but it don't
|
||||
// work properly under glide nor with fogcolor to ffffff :(
|
||||
// Hurdler: PF_Environement would be cool, but we need to fix
|
||||
// the issue with the fog before
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = HWR_GetBlendModeFlag(blendmode)|occlusion;
|
||||
blend |= occlusion;
|
||||
if (!occlusion) use_linkdraw_hack = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -4443,16 +4455,14 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
|
|||
if (trans >= NUMTRANSMAPS)
|
||||
return; // cap
|
||||
|
||||
if (trans)
|
||||
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
else
|
||||
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
if (!trans && !blendmode)
|
||||
{
|
||||
// BP: i agree that is little better in environement but it don't
|
||||
// work properly under glide nor with fogcolor to ffffff :(
|
||||
// Hurdler: PF_Environement would be cool, but we need to fix
|
||||
// the issue with the fog before
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
|
||||
blend |= PF_Occlude;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6680,7 +6690,7 @@ void HWR_DoPostProcessor(player_t *player)
|
|||
|
||||
Surf.PolyColor.s.alpha = 0xc0; // match software mode
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_AdditiveSource|PF_NoTexture|PF_NoDepthTest);
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest);
|
||||
}
|
||||
|
||||
// Capture the screen for intermission and screen waving
|
||||
|
|
|
|||
|
|
@ -1401,13 +1401,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
|||
if (trans >= NUMTRANSMAPS)
|
||||
return false; // cap
|
||||
|
||||
if (trans)
|
||||
Surf.PolyFlags = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
else
|
||||
{
|
||||
Surf.PolyColor.s.alpha = 0xff;
|
||||
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
|
||||
}
|
||||
Surf.PolyFlags = HWR_SurfaceBlend(blendmode, trans, &Surf);
|
||||
}
|
||||
|
||||
// don't forget to enable the depth test because we can't do this
|
||||
|
|
|
|||
|
|
@ -1609,12 +1609,11 @@ static void SetBlendMode(FBITFIELD flags)
|
|||
case PF_Additive & PF_Blending:
|
||||
case PF_Subtractive & PF_Blending:
|
||||
case PF_ReverseSubtract & PF_Blending:
|
||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
|
||||
break;
|
||||
case PF_Environment & PF_Blending:
|
||||
pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
case PF_AdditiveSource & PF_Blending:
|
||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
|
||||
break;
|
||||
case PF_Multiplicative & PF_Blending:
|
||||
pglBlendFunc(GL_DST_COLOR, GL_ZERO);
|
||||
break;
|
||||
|
|
@ -1653,7 +1652,6 @@ static void SetBlendMode(FBITFIELD flags)
|
|||
break;
|
||||
case PF_Translucent & PF_Blending:
|
||||
case PF_Additive & PF_Blending:
|
||||
case PF_AdditiveSource & PF_Blending:
|
||||
case PF_Subtractive & PF_Blending:
|
||||
case PF_ReverseSubtract & PF_Blending:
|
||||
case PF_Environment & PF_Blending:
|
||||
|
|
@ -2783,7 +2781,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
|||
fade.alpha = byte2float[Surface->FadeColor.s.alpha];
|
||||
|
||||
flags = (Surface->PolyFlags | PF_Modulated);
|
||||
if (Surface->PolyFlags & (PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative))
|
||||
if (Surface->PolyFlags & (PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative))
|
||||
flags |= PF_Occlude;
|
||||
else if (Surface->PolyColor.s.alpha == 0xFF)
|
||||
flags |= (PF_Occlude | PF_Masked);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
transtable = 0;
|
||||
blendmode = AST_MODULATE;
|
||||
}
|
||||
if (transtable != NUMTRANSMAPS)
|
||||
if (transtable != NUMTRANSMAPS && (blendmode || transtable))
|
||||
{
|
||||
dc_transmap = R_GetBlendTable(blendmode, transtable);
|
||||
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue